Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A small, yet powerful, gem to interface with Flickr photostreams
Ruby
tag: 0.3.0

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
test
.gitignore
README.rdoc
Rakefile
fleakr.gemspec

README.rdoc

Fleakr

Description

A teeny tiny gem to interface with Flickr photostreams

Installation

Stable

sudo gem install fleakr

Bleeding Edge

sudo gem install reagent-fleakr --source=http://gems.github.com

Or …

$ git clone git://github.com/reagent/fleakr.git
$ cd fleakr
$ rake gem && sudo gem install pkg/fleakr-<version>.gem

Usage

Before doing anything, require the library:

>> require 'rubygems'
>> require 'fleakr'

Then, set your API key (only need to do this once per session):

>> Fleakr.api_key = '<your api key here>'

Find a user by username:

>> user = Fleakr.user('the decapitator')
=> #<Fleakr::Objects::User:0x692648 @username="the decapitator", @id="21775151@N06">

Or by email:

>> user = Fleakr.user('user@host.com')
=> #<Fleakr::Objects::User:0x11f484c @username="bckspcr", @id="84481630@N00">

Once you have a user, you can find his associated sets:

>> user.sets
=> [#<Fleakr::Objects::Set:0x671358 @title="The Decapitator", @description="">, 
    #<Fleakr::Objects::Set:0x66d898 @title="londonpaper hijack", ...

Or contacts:

>> user.contacts.first
=> #<Fleakr::Objects::User:0x19039bc @username=".schill",
    @id="12289718@N00", @icon_farm="1", @icon_server="4">

Or groups if you would like:

>> user.groups
=> [#<Fleakr::Objects::Group:0x11f2330 ..., 
    #<Fleakr::Objects::Group:0x11f2308 ...
>> user.groups.first.name
=> "Rural Decay"
>> user.groups.first.id
=> "14581414@N00"

Groups also contain photos:

>> user.groups.last.photos.first.title
=> "Welcome To The Machine"

When accessing a set, you can also grab all the photos that are in that set:

>> user.sets.first
=> #<Fleakr::Objects::Set:0x1195bbc @title="The Decapitator", @id="72157603480986566", @description="">
>> user.sets.first.photos.first
=> #<Fleakr::Objects::Photo:0x1140108 ... >
>> user.sets.first.photos.first.title
=> "Untitled1"

If a photo interests you, save it down to a directory of your choosing:

>> user.sets.first.photos.first.small.save_to('/tmp')
=> #<File:/tmp/2117922283_715587b2cb_m.jpg (closed)>

If you can't decide on a photo and would rather just save the whole set, specify the target directory and the size of the images you're interested in:

>> user.sets.first.save_to('/tmp', :square)
=> [#<Fleakr::Objects::Photo:0x1187a1c @secret="715587b2cb" ...
>> Dir["/tmp/#{user.sets.first.title}/*.jpg"].map
=> ["/tmp/The Decapitator/2117919621_8b2d601bff_s.jpg", 
    "/tmp/The Decapitator/2117921045_5fb15eff90_s.jpg", 
    "/tmp/The Decapitator/2117922283_715587b2cb_s.jpg", ...

If you would prefer to just search photos, you can do that with search text:

>> photos = Fleakr.search('ponies!!')
=> [#<Fleakr::Objects::Photo:0x11f4e64 @title="hiroshima atomic garden", @id="3078234390">, 
    #<Fleakr::Objects::Photo:0x11f4928 @title="PONYLOV", @id="3077360853">, ...
>> photos.first.title
=> "hiroshima atomic garden"

You can also search based on tags:

>> photos = Fleakr.search(:tags => 'macro')
>> photos.first.title
=> "Demure"
>> photos.first.id
=> "3076049945"

Searches can also be scoped to other entities in the system (namely Users and Groups):

>> user.groups.first.search('awesome')
=> [#<Fleakr::Objects::Photo:0x18cb4cc @server_id="2012", @id="2181921273",
     @farm_id="3", @title="", @secret="634eda7521">, ... 
>> user.search('serpent')
=> [#<Fleakr::Objects::Photo:0x18a6960 @server_id="41", @id="81370156",
    @farm_id="1", @title="Clear and Serpent Danger", @secret="013091582a">]

TODO

  • Implement remaining bits of person, photoset, and photo-releated APIs

  • Provide a better searching interface

  • Lazily load attributes for objects that need to be accessed via secondary API call

License

Copyright © 2008 Patrick Reagan (reaganpr@gmail.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Something went wrong with that request. Please try again.