pythondownloadflickr

Download photo Stats for a given ID from Flickr with python


I am trying to download some photos from Flickr. With My KEY and Secret, I am able to search and download using these lines of code

image_tag = 'seaside'
extras = ','.join(SIZES[0])
flickr = FlickrAPI(KEY, SECRET)
photos = flickr.walk(text=image_tag,  # it will search by image title and image tags
                            extras=extras,  # get the urls for each size we want
                            privacy_filter=1,  # search only for public photos
                            per_page=50,
                            sort='relevance',
                            safe_search = 1 )

Using this I am able to acquire the url and the photo ID but I would like to download photostats too (likes, views), but I can't find an appropriate command that starting from the ID of the photo allows me to download the stats.


Solution

  • You can find what you are looking for exactly on Flickr web page, in the API's documentation:

    https://www.flickr.com/services/api/flickr.stats.getPhotoStats.html

    Calling the method:

    flickr.stats.getPhotoStats
    

    with arguments:

    api_key, date, photo_id
    

    You will receive what you look for in the following format:

    <stats views="24" comments="4" favorites="1" />
    

    Remember to generate before your authentication token, there is a link in this same page on how to generate it, if you still didn't.