Flickr Module

This handles all the interacetions with the FlickrAPI module as well as dealing with mapping contacts <–> flickr accounts and local image files <–> flickr images

class py2facer.lib.flickr.Base(**kwargs)

SQL Alchemy magic.

class py2facer.lib.flickr.DbProxy(db_url, db_debug=None)

Used to share the session object between classes more easily

Parameters:
  • db_url (str) – the URL to the database to use (normally sqlite:///myfile.db)
  • db_debug (Boolean) – Set True to enable SQLAlchemy debugging
get_session()

Return a SQLAlchemy session object

Returns:Session
class py2facer.lib.flickr.FlickrAPIManager

Used as a proxy to the FlickrAPI objects. This is for unit testing the rest of the system

Variables:
  • flickrFlickrAPI instance that does the heavy lifting of actually talking to flickr.
  • logged_in – Boolean for if we’re already logged into flickr
login()

Setup the flickr object and perform the login to flickr

It is safe to call this function several times. Subsequent calls have no effect.

class py2facer.lib.flickr.FlickrContact(nsid=None, username=None, google_hash=None)

Linking information between Flickr contacts and google contacts

SQLAlchemy table for storing contact linking information between Google and flickr

Parameters:
  • nsid (str) – The flickr ID of the user
  • username (str) – The flickr username for the user
  • google_hash (str) – The hash id of the user from Google
CONTACT_ID

Used as the other_id key in an Image object

USERNAME

Used as the other_id key in an Image object

google_hash
classmethod google_to_flickr(session, ghash)
Parameters:
  • cls (FlickrContact) – The class
  • session (Session) – Session connection to use for the query
  • ghash (str) – The hash id of the user from Google
id
nsid

Flickr ID

username

Flickr username

class py2facer.lib.flickr.FlickrContactManager(db_proxy, flickr_proxy=None)

Management class for our flickr contacts. Handles the details of mapping e-mail addresses to flickr ids

Parameters:
  • dburl (str) – Database URL to use to connect
  • flickr_proxy – Proxy object to the FlickrAPI
sync_flickr(google_contacts, force_recheck=False, flickr_proxy=None)
Parameters:
  • google_contacts – The contacts that should be synced
  • force_recheck – Flag for if previously checked contacts should be rechecked
  • flickr_proxy – Proxy object to the FlickrAPI
class py2facer.lib.flickr.FlickrFace(**kwargs)

Faces that are contained in photos, with the ghash and flickr ID

At this time this table is unused. It can be used for caching later to reduce the number of queriest to Flickr, but there’s the question of “What happens if someone removes a face directly from the image?”

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

id

Primary key

image_id

Flickr image ID

class py2facer.lib.flickr.FlickrImage(photo_id=None, photo_secret=None, filename=None, checksum=None, photo_date=None, flickr_photo_date=None, flickr_title=None)

Linking information between a Flickr image and a local image

Parameters:
  • photo_id (int) – Flickr image ID
  • photo_secret (str) – Flickr photo secret id used for generating links
  • filename (str) – Local filename of the image
  • checksum (str) – psuedo image checksum
  • photo_date (datetime) – Date the photo was taken
  • flickr_photo_date (datetime) – When flickr thinks the photo was taken
  • flickr_title (str) – The title of the image on flickr
checksum
filename

Local filename of the image

flickr_photo_date

When flickr thinks the photo was taken

flickr_title
id
photo_date
photo_id

Flickr image ID

photo_secret

Flickr photo secret id used for generating links

class py2facer.lib.flickr.FlickrImageManager(db_proxy, flickr_proxy=None)

Used to manage the actual photo objects that are on flickr v.s. what is on the local computer

Parameters:
  • dburl (str) – Database URL to use to connect
  • flickr_proxy – Proxy object to the FlickrAPI
add_photo(imgs)

Add a single Image instance or a list/tuple of Image to the list of images that FlickrImageManager will work on

Parameters:imgs – single Image instance or a list of Image instances

Find the corresponding photos in flickr that match this set of photos

For now this is done by matching exactly the EXIF time of the photo, so if the user has modified this even slightly it will throw off the matching

Parameters:flickr_proxy – The flickr proxy passed into the calling func.
sync_faces(flickr_proxy=None)

Sync facial data for the Image objects for which we know the linking information.

Note

This does not attempt to generate that linking information. That means it’s possible to just run the sync form linking information that has been cached in the DB w/o querying flickr.

Parameters:flickr_proxy – The flickr proxy passed into the calling func.

Previous topic

Commands Module

Next topic

Image Module

This Page