[flickr] add 'contexts' option (#5324)
This commit is contained in:
@@ -77,6 +77,8 @@ class FlickrImageExtractor(FlickrExtractor):
|
||||
photo = self.api.photos_getInfo(self.item_id)
|
||||
if self.api.exif:
|
||||
photo.update(self.api.photos_getExif(self.item_id))
|
||||
if self.api.contexts:
|
||||
photo.update(self.api.photos_getAllContexts(self.item_id))
|
||||
|
||||
if photo["media"] == "video" and self.api.videos:
|
||||
self.api._extract_video(photo)
|
||||
@@ -268,6 +270,8 @@ class FlickrAPI(oauth.OAuth1API):
|
||||
|
||||
self.exif = extractor.config("exif", False)
|
||||
self.videos = extractor.config("videos", True)
|
||||
self.contexts = extractor.config("contexts", False)
|
||||
|
||||
self.maxsize = extractor.config("size-max")
|
||||
if isinstance(self.maxsize, str):
|
||||
for fmt, fmtname, fmtwidth in self.FORMATS:
|
||||
@@ -311,6 +315,13 @@ class FlickrAPI(oauth.OAuth1API):
|
||||
params = {"user_id": user_id}
|
||||
return self._pagination("people.getPhotos", params)
|
||||
|
||||
def photos_getAllContexts(self, photo_id):
|
||||
"""Returns all visible sets and pools the photo belongs to."""
|
||||
params = {"photo_id": photo_id}
|
||||
data = self._call("photos.getAllContexts", params)
|
||||
del data["stat"]
|
||||
return data
|
||||
|
||||
def photos_getExif(self, photo_id):
|
||||
"""Retrieves a list of EXIF/TIFF/GPS tags for a given photo."""
|
||||
params = {"photo_id": photo_id}
|
||||
@@ -444,6 +455,8 @@ class FlickrAPI(oauth.OAuth1API):
|
||||
|
||||
if self.exif:
|
||||
photo.update(self.photos_getExif(photo["id"]))
|
||||
if self.contexts:
|
||||
photo.update(self.photos_getAllContexts(photo["id"]))
|
||||
photo["id"] = text.parse_int(photo["id"])
|
||||
|
||||
if "owner" in photo:
|
||||
|
||||
Reference in New Issue
Block a user