[flickr] make exif and context metadata extraction non-fatal (#6002)
This commit is contained in:
@@ -75,11 +75,8 @@ class FlickrImageExtractor(FlickrExtractor):
|
|||||||
|
|
||||||
def items(self):
|
def items(self):
|
||||||
photo = self.api.photos_getInfo(self.item_id)
|
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))
|
|
||||||
|
|
||||||
|
self.api._extract_metadata(photo)
|
||||||
if photo["media"] == "video" and self.api.videos:
|
if photo["media"] == "video" and self.api.videos:
|
||||||
self.api._extract_video(photo)
|
self.api._extract_video(photo)
|
||||||
else:
|
else:
|
||||||
@@ -407,6 +404,8 @@ class FlickrAPI(oauth.OAuth1API):
|
|||||||
self.log.debug("Server response: %s", data)
|
self.log.debug("Server response: %s", data)
|
||||||
if data["code"] == 1:
|
if data["code"] == 1:
|
||||||
raise exception.NotFoundError(self.extractor.subcategory)
|
raise exception.NotFoundError(self.extractor.subcategory)
|
||||||
|
elif data["code"] == 2:
|
||||||
|
raise exception.AuthorizationError(msg)
|
||||||
elif data["code"] == 98:
|
elif data["code"] == 98:
|
||||||
raise exception.AuthenticationError(msg)
|
raise exception.AuthenticationError(msg)
|
||||||
elif data["code"] == 99:
|
elif data["code"] == 99:
|
||||||
@@ -453,10 +452,7 @@ class FlickrAPI(oauth.OAuth1API):
|
|||||||
photo["date"] = text.parse_timestamp(photo["dateupload"])
|
photo["date"] = text.parse_timestamp(photo["dateupload"])
|
||||||
photo["tags"] = photo["tags"].split()
|
photo["tags"] = photo["tags"].split()
|
||||||
|
|
||||||
if self.exif:
|
self._extract_metadata(photo)
|
||||||
photo.update(self.photos_getExif(photo["id"]))
|
|
||||||
if self.contexts:
|
|
||||||
photo.update(self.photos_getAllContexts(photo["id"]))
|
|
||||||
photo["id"] = text.parse_int(photo["id"])
|
photo["id"] = text.parse_int(photo["id"])
|
||||||
|
|
||||||
if "owner" in photo:
|
if "owner" in photo:
|
||||||
@@ -512,6 +508,23 @@ class FlickrAPI(oauth.OAuth1API):
|
|||||||
photo["width"] = photo["height"] = 0
|
photo["width"] = photo["height"] = 0
|
||||||
return photo
|
return photo
|
||||||
|
|
||||||
|
def _extract_metadata(self, photo):
|
||||||
|
if self.exif:
|
||||||
|
try:
|
||||||
|
photo.update(self.photos_getExif(photo["id"]))
|
||||||
|
except Exception as exc:
|
||||||
|
self.log.warning(
|
||||||
|
"Unable to retrieve 'exif' data for %s (%s: %s)",
|
||||||
|
photo["id"], exc.__class__.__name__, exc)
|
||||||
|
|
||||||
|
if self.contexts:
|
||||||
|
try:
|
||||||
|
photo.update(self.api.photos_getAllContexts(photo["id"]))
|
||||||
|
except Exception as exc:
|
||||||
|
self.log.warning(
|
||||||
|
"Unable to retrieve 'contexts' data for %s (%s: %s)",
|
||||||
|
photo["id"], exc.__class__.__name__, exc)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _clean_info(info):
|
def _clean_info(info):
|
||||||
info["title"] = info["title"]["_content"]
|
info["title"] = info["title"]["_content"]
|
||||||
|
|||||||
Reference in New Issue
Block a user