IU Technology Architecture Lodge
Random and not so random thoughts from Raymond Yee, primarily on the scholarly and educational use of the Web, libraries, educational technology, and information management

 
Home

Print friendly version

Scholar's Box Essay Series

Current Projects

Presentations and Papers

Work on Educational Technology Interop

RY's wiki

RY's personal blog

About This Site

About Raymond Yee

Interactive University

Contact RY

My blogroll

RSS 2.0 feed for this site

 
 

IU Technology Architecture Lodge

Permanent link to archive for 11/15/04. Monday, November 15, 2004

Changing Permissions on Flickr Images Via the API #
I wrote a Python script to change the privacy settings of a photoset of images. I tend to set my photos to visible to only myself or to my friends and family before then making them publicly available. The Flickr user interface allows changes to images one at a time, which works ok for small sets of images. But I have been creating sets with dozens of photos, making privacy shifts extremely tedious. While I await the addition of batch operations to the flickr interface, I decided to do some programming with the Flickr API Services.

If you want to play with the flickr API, you will need to request a key. There are both SOAP and REST interfaces to Flickr.

Also, there are two Python libraries that use these interfaces. (FlickrClient - micampe.it and flickr.py (James Clarke). There seems to be a basic tradeoff between the two modules: completeness of the first vs convenience of the latter. I quickly decided on the first library because the lightweight wrapper gave access to the entire API.

I will post here my little script. (It's not the most elegant solution -- but shows how one can use FlickrClient - micampe.it

  1 
  2 
  3 
  4 
  5 
  6 
  7 
  8 
  9 
 10 
 11 
 12 
 13 
 14 
 15 
 16 
 17 
 18 
 19 
 20 
 21 
 22 
 23 
 24 
 25 
 26 
 27 
 28 
 29 

API_KEY = 'INSERT YOUR API KEY HERE'
USER_EMAIL = "INSERT EMAIL HERE"

USER_PASSWORD = "INSERT PASSWORD HERE" USER_ID = "INSERT FLICKR ID HERE"

def makeSetPublic(photoSetID,flAll):

# general intention is to change the pictures in the photoset public. #if flAll is false, then leave as private those that aren't for view by family and friends. photoset = client.flickr_photosets_getPhotos(photoset_id=photoSetID, email=USER_EMAIL, password=USER_PASSWORD)

for photo in photoset: photo_id = photo('id')

photo_secret = photo('secret') photoInfo = getPhotoInfo(photo_id)

is_public = photoInfo.visibility("ispublic") is_friend = photoInfo.visibility("isfriend")

is_family = photoInfo.visibility("isfamily") perm_comment = photoInfo.permissions("permcomment")

perm_addmeta = photoInfo.permissions("permaddmeta") print "id:%s title:%s public:%s friend:%s family:%s" % (photo_id, str(photoInfo.title), is_public, is_friend, is_friend)

# change the permissions to public unless we want to keep those not already for family and friends as private if flAll: setPhotoPerm(photo_id,is_public=1,is_friend=1, is_family=1, perm_comment=perm_comment, perm_addmeta=perm_addmeta)

else: if is_friend == '1' and is_family == '1':

setPhotoPerm(photo_id,is_public=1,is_friend=1, is_family=1, perm_comment=perm_comment, perm_addmeta=perm_addmeta)

I will also throw in a few RESTful ways of accessing the Flickr API (substitute the appropriate parameters):


 
Posted by Raymond Yee on 11/15/04; 5:46:51 PM
from the Web Technology dept.

Discuss

 
November 2004
Sun
Mon
Tue
Wed
Thu
Fri
Sat
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 
Oct   Dec




Last update: Monday, November 15, 2004 at 5:46:51 PM.

This site is using the Vanilla Manila 1999 theme.
The opinions or statements expressed herein should not be taken as a position of or endorsement by the University of California, Berkeley. Nor should the opinions or statements expressed herein be taken as a position of or endorsement of the University of California, Berkeley. Links on these pages to commercial sites do not represent endorsement by the University of California or its affiliates.