reagent / fleakr
- Source
- Commits
- Network (14)
- Issues (3)
- Downloads (12)
- Wiki (1)
- Graphs
-
Tree:
72d796e
commit 72d796e97f256a027e01b89e7f82f8cc6dfac70e
tree 2e5ab10415eb566fcc362fc84e7a49ea42308988
parent 0121127ac48a0609eaeef18a2311773dcf321f4e
tree 2e5ab10415eb566fcc362fc84e7a49ea42308988
parent 0121127ac48a0609eaeef18a2311773dcf321f4e
fleakr / README.rdoc
| 72d796e9 » | reagent | 2008-12-05 | 1 | = Fleakr | |
| 866e035c » | reagent | 2008-11-02 | 2 | ||
| 72d796e9 » | reagent | 2008-12-05 | 3 | == Description | |
| 866e035c » | reagent | 2008-11-02 | 4 | ||
| 5 | A teeny tiny gem to interface with Flickr photostreams | ||||
| 6 | |||||
| 72d796e9 » | reagent | 2008-12-05 | 7 | == Installation | |
| 866e035c » | reagent | 2008-11-02 | 8 | ||
| eaeea626 » | reagent | 2008-11-29 | 9 | sudo gem install reagent-fleakr --source=http://gems.github.com | |
| caa37c17 » | reagent | 2008-11-29 | 10 | ||
| 11 | Or ... | ||||
| 12 | |||||
| 13 | $ git clone git://github.com/reagent/fleakr.git | ||||
| 14 | $ cd fleakr | ||||
| 15 | $ rake gem && sudo gem install pkg/fleakr-<version>.gem | ||||
| 866e035c » | reagent | 2008-11-02 | 16 | ||
| 72d796e9 » | reagent | 2008-12-05 | 17 | == Usage | |
| 866e035c » | reagent | 2008-11-02 | 18 | ||
| caa37c17 » | reagent | 2008-11-29 | 19 | Before doing anything, require the library: | |
| 20 | |||||
| 21 | >> require 'rubygems' | ||||
| 22 | >> require 'fleakr' | ||||
| 23 | |||||
| 24 | Then, set your API key (only need to do this once per session): | ||||
| 25 | |||||
| 0121127a » | reagent | 2008-12-05 | 26 | >> Fleakr.api_key = '<your api key here>' | |
| caa37c17 » | reagent | 2008-11-29 | 27 | ||
| 28 | Find a user by username: | ||||
| 29 | |||||
| 0121127a » | reagent | 2008-12-05 | 30 | >> user = Fleakr.user('the decapitator') | |
| 31 | => #<Fleakr::Objects::User:0x692648 @username="the decapitator", @id="21775151@N06"> | ||||
| caa37c17 » | reagent | 2008-11-29 | 32 | ||
| 1c69d9ad » | reagent | 2008-12-02 | 33 | Or by email: | |
| 34 | |||||
| 0121127a » | reagent | 2008-12-05 | 35 | >> user = Fleakr.user('user@host.com') | |
| 36 | => #<Fleakr::Objects::User:0x11f484c @username="bckspcr", @id="84481630@N00"> | ||||
| 1c69d9ad » | reagent | 2008-12-02 | 37 | ||
| 38 | Once you have a user, you can find his associated sets: | ||||
| caa37c17 » | reagent | 2008-11-29 | 39 | ||
| 40 | >> user.sets | ||||
| 0121127a » | reagent | 2008-12-05 | 41 | => [#<Fleakr::Objects::Set:0x671358 @title="The Decapitator", @description="">, | |
| 42 | #<Fleakr::Objects::Set:0x66d898 @title="londonpaper hijack", ... | ||||
| eaeea626 » | reagent | 2008-11-29 | 43 | ||
| 1c69d9ad » | reagent | 2008-12-02 | 44 | Or groups if you would like: | |
| 1614c050 » | reagent | 2008-11-30 | 45 | ||
| 46 | >> user.groups | ||||
| 0121127a » | reagent | 2008-12-05 | 47 | => [#<Fleakr::Objects::Group:0x11f2330 ..., | |
| 48 | #<Fleakr::Objects::Group:0x11f2308 ... | ||||
| 1614c050 » | reagent | 2008-11-30 | 49 | >> user.groups.first.name | |
| 50 | => "Rural Decay" | ||||
| 51 | >> user.groups.first.id | ||||
| 52 | => "14581414@N00" | ||||
| 53 | |||||
| 1c69d9ad » | reagent | 2008-12-02 | 54 | When accessing a set, you can also grab all the photos that are in that set: | |
| 11978883 » | reagent | 2008-11-29 | 55 | ||
| 56 | >> user.sets.first | ||||
| 0121127a » | reagent | 2008-12-05 | 57 | => #<Fleakr::Objects::Set:0x1195bbc @title="The Decapitator", @id="72157603480986566", @description=""> | |
| 11978883 » | reagent | 2008-11-29 | 58 | >> user.sets.first.photos.first | |
| 0121127a » | reagent | 2008-12-05 | 59 | => #<Fleakr::Objects::Photo:0x1140108 ... > | |
| 11978883 » | reagent | 2008-11-29 | 60 | >> user.sets.first.photos.first.title | |
| 61 | => "Untitled1" | ||||
| 1c69d9ad » | reagent | 2008-12-02 | 62 | ||
| 63 | If a photo interests you, save it down to a directory of your choosing: | ||||
| 64 | |||||
| 65 | >> user.sets.first.photos.first.small.save_to('/tmp') | ||||
| 66 | => #<File:/tmp/2117922283_715587b2cb_m.jpg (closed)> | ||||
| 67 | |||||
| 68 | If you can't decide on a photo and would rather just save the whole set, specify the target directory | ||||
| 69 | and the size of the images you're interested in: | ||||
| 70 | |||||
| 71 | >> user.sets.first.save_to('/tmp', :square) | ||||
| 0121127a » | reagent | 2008-12-05 | 72 | => [#<Fleakr::Objects::Photo:0x1187a1c @secret="715587b2cb" ... | |
| 1c69d9ad » | reagent | 2008-12-02 | 73 | >> Dir["/tmp/#{user.sets.first.title}/*.jpg"].map | |
| 74 | => ["/tmp/The Decapitator/2117919621_8b2d601bff_s.jpg", | ||||
| 75 | "/tmp/The Decapitator/2117921045_5fb15eff90_s.jpg", | ||||
| 76 | "/tmp/The Decapitator/2117922283_715587b2cb_s.jpg", ... | ||||
| 11978883 » | reagent | 2008-11-29 | 77 | ||
| ac1e3263 » | reagent | 2008-12-02 | 78 | If you would prefer to just search photos, you can do that with search text: | |
| 237efab4 » | reagent | 2008-12-01 | 79 | ||
| 0121127a » | reagent | 2008-12-05 | 80 | >> search = Fleakr::Objects::Search.new('ponies!!') | |
| ac1e3263 » | reagent | 2008-12-02 | 81 | >> search.results | |
| 0121127a » | reagent | 2008-12-05 | 82 | => [#<Fleakr::Objects::Photo:0x11f4e64 @title="hiroshima atomic garden", @id="3078234390">, | |
| 83 | #<Fleakr::Objects::Photo:0x11f4928 @title="PONYLOV", @id="3077360853">, ... | ||||
| ac1e3263 » | reagent | 2008-12-02 | 84 | >> search.results.first.title | |
| 85 | => "hiroshima atomic garden" | ||||
| 86 | |||||
| 87 | You can also search based on tags: | ||||
| 88 | |||||
| 0121127a » | reagent | 2008-12-05 | 89 | >> search = Fleakr::Objects::Search.new(nil, :tags => 'macro') | |
| 9c782f33 » | reagent | 2008-12-01 | 90 | >> search.results.first.title | |
| 91 | => "Demure" | ||||
| 92 | >> search.results.first.id | ||||
| 93 | => "3076049945" | ||||
| 237efab4 » | reagent | 2008-12-01 | 94 | ||
| 72d796e9 » | reagent | 2008-12-05 | 95 | == TODO | |
| 866e035c » | reagent | 2008-11-02 | 96 | ||
| caa37c17 » | reagent | 2008-11-29 | 97 | * Implement remaining bits of person, photoset, and photo-releated APIs | |
| 0121127a » | reagent | 2008-12-05 | 98 | * Provide a better searching interface | |
| 99 | * Lazily load attributes for objects that need to be accessed via secondary API call | ||||
| caa37c17 » | reagent | 2008-11-29 | 100 | ||
| 72d796e9 » | reagent | 2008-12-05 | 101 | == License | |
| 866e035c » | reagent | 2008-11-02 | 102 | ||
| 103 | Copyright (c) 2008 Patrick Reagan (reaganpr@gmail.com) | ||||
| 104 | |||||
| 105 | Permission is hereby granted, free of charge, to any person | ||||
| 106 | obtaining a copy of this software and associated documentation | ||||
| 107 | files (the "Software"), to deal in the Software without | ||||
| 108 | restriction, including without limitation the rights to use, | ||||
| 109 | copy, modify, merge, publish, distribute, sublicense, and/or sell | ||||
| 110 | copies of the Software, and to permit persons to whom the | ||||
| 111 | Software is furnished to do so, subject to the following | ||||
| 112 | conditions: | ||||
| 113 | |||||
| 114 | The above copyright notice and this permission notice shall be | ||||
| 115 | included in all copies or substantial portions of the Software. | ||||
| 116 | |||||
| 117 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||||
| 118 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||||
| 119 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||||
| 120 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||||
| 121 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||||
| 122 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||||
| 123 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||||
| 124 | OTHER DEALINGS IN THE SOFTWARE. | ||||
