Search code examples
pythonapiflickr

problems in Flickr api tags photo search with AND condition


I am trying to get some photos using :

http://www.flickr.com/services/api/flickr.photos.search.html having both the tags:

"abc" and "def" using the following code:

import flickr.py
photos = flickr.photos_search(tags= ["abc", "def"], tag_mode = all, per_page=10)

but it's returning photos with the OR condition, the tag_mode = all condition is not working

Thank you,


Solution

  • It seems like the method in the flickr.py will use

    tag_mode=%3Cbuilt-in+function+all%3E
    

    making the API not recognized and use the default any method

    The root cause should be inside this function:

    def _doget(method, auth=False, **params):
    

    due to the use of all which is a keyword in python, urlencode(all) will convert it to %3Cbuilt-in+function+all%3E

    So the solution to your problem is to change

    photos = flickr.photos_search(tags= ["abc", "def"], tag_mode = all, per_page=10)
    

    to

    photos = flickr.photos_search(tags= ['abc', 'def'], tag_mode = 'all', per_page=10)