@@ -2653,6 +2653,19 @@ Description
|
|||||||
See `flickr.photos.getExif <https://www.flickr.com/services/api/flickr.photos.getExif.html>`__ for details.
|
See `flickr.photos.getExif <https://www.flickr.com/services/api/flickr.photos.getExif.html>`__ for details.
|
||||||
|
|
||||||
|
|
||||||
|
extractor.flickr.info
|
||||||
|
---------------------
|
||||||
|
Type
|
||||||
|
``bool``
|
||||||
|
Default
|
||||||
|
``false``
|
||||||
|
Description
|
||||||
|
For each photo, retrieve its "full" metadata as provided by
|
||||||
|
`flickr.photos.getInfo <https://www.flickr.com/services/api/flickr.photos.getInfo.html>`__
|
||||||
|
|
||||||
|
Note: This requires 1 additional API call per photo.
|
||||||
|
|
||||||
|
|
||||||
extractor.flickr.metadata
|
extractor.flickr.metadata
|
||||||
-------------------------
|
-------------------------
|
||||||
Type
|
Type
|
||||||
|
|||||||
@@ -278,6 +278,7 @@
|
|||||||
|
|
||||||
"contexts": false,
|
"contexts": false,
|
||||||
"exif" : false,
|
"exif" : false,
|
||||||
|
"info" : false,
|
||||||
"metadata": false,
|
"metadata": false,
|
||||||
"size-max": null,
|
"size-max": null,
|
||||||
"videos" : true
|
"videos" : true
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ class FlickrImageExtractor(FlickrExtractor):
|
|||||||
|
|
||||||
photo = self.api.photos_getInfo(item_id)
|
photo = self.api.photos_getInfo(item_id)
|
||||||
|
|
||||||
self.api._extract_metadata(photo)
|
self.api._extract_metadata(photo, False)
|
||||||
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:
|
||||||
@@ -279,9 +279,10 @@ class FlickrAPI(oauth.OAuth1API):
|
|||||||
def __init__(self, extractor):
|
def __init__(self, extractor):
|
||||||
oauth.OAuth1API.__init__(self, extractor)
|
oauth.OAuth1API.__init__(self, extractor)
|
||||||
|
|
||||||
self.exif = extractor.config("exif", False)
|
|
||||||
self.videos = extractor.config("videos", True)
|
self.videos = extractor.config("videos", True)
|
||||||
self.contexts = extractor.config("contexts", False)
|
self.meta_exif = extractor.config("exif", False)
|
||||||
|
self.meta_info = extractor.config("info", False)
|
||||||
|
self.meta_contexts = extractor.config("contexts", False)
|
||||||
|
|
||||||
self.maxsize = extractor.config("size-max")
|
self.maxsize = extractor.config("size-max")
|
||||||
if isinstance(self.maxsize, str):
|
if isinstance(self.maxsize, str):
|
||||||
@@ -522,8 +523,24 @@ class FlickrAPI(oauth.OAuth1API):
|
|||||||
photo["width"] = photo["height"] = 0
|
photo["width"] = photo["height"] = 0
|
||||||
return photo
|
return photo
|
||||||
|
|
||||||
def _extract_metadata(self, photo):
|
def _extract_metadata(self, photo, info=True):
|
||||||
if self.exif:
|
if info and self.meta_info:
|
||||||
|
try:
|
||||||
|
photo.update(self.photos_getInfo(photo["id"]))
|
||||||
|
photo["user"] = photo["owner"]
|
||||||
|
photo["title"] = photo["title"]["_content"]
|
||||||
|
photo["comments"] = text.parse_int(
|
||||||
|
photo["comments"]["_content"])
|
||||||
|
photo["description"] = photo["description"]["_content"]
|
||||||
|
photo["tags"] = [t["raw"] for t in photo["tags"]["tag"]]
|
||||||
|
photo["views"] = text.parse_int(photo["views"])
|
||||||
|
photo["id"] = text.parse_int(photo["id"])
|
||||||
|
except Exception as exc:
|
||||||
|
self.log.warning(
|
||||||
|
"Unable to retrieve 'info' data for %s (%s: %s)",
|
||||||
|
photo["id"], exc.__class__.__name__, exc)
|
||||||
|
|
||||||
|
if self.meta_exif:
|
||||||
try:
|
try:
|
||||||
photo.update(self.photos_getExif(photo["id"]))
|
photo.update(self.photos_getExif(photo["id"]))
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
@@ -531,7 +548,7 @@ class FlickrAPI(oauth.OAuth1API):
|
|||||||
"Unable to retrieve 'exif' data for %s (%s: %s)",
|
"Unable to retrieve 'exif' data for %s (%s: %s)",
|
||||||
photo["id"], exc.__class__.__name__, exc)
|
photo["id"], exc.__class__.__name__, exc)
|
||||||
|
|
||||||
if self.contexts:
|
if self.meta_contexts:
|
||||||
try:
|
try:
|
||||||
photo.update(self.photos_getAllContexts(photo["id"]))
|
photo.update(self.photos_getAllContexts(photo["id"]))
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ __tests__ = (
|
|||||||
"media" : "photo",
|
"media" : "photo",
|
||||||
"pool" : list,
|
"pool" : list,
|
||||||
"set" : list,
|
"set" : list,
|
||||||
|
"safety_level": "0",
|
||||||
|
"tags" : list,
|
||||||
"url" : str,
|
"url" : str,
|
||||||
"views" : int,
|
"views" : int,
|
||||||
"width" : 1024,
|
"width" : 1024,
|
||||||
@@ -164,8 +166,19 @@ __tests__ = (
|
|||||||
"#url" : "https://www.flickr.com/photos/shona_s/favorites",
|
"#url" : "https://www.flickr.com/photos/shona_s/favorites",
|
||||||
"#category": ("", "flickr", "favorite"),
|
"#category": ("", "flickr", "favorite"),
|
||||||
"#class" : flickr.FlickrFavoriteExtractor,
|
"#class" : flickr.FlickrFavoriteExtractor,
|
||||||
"#pattern" : flickr.FlickrImageExtractor.pattern,
|
"#options" : {"info": True},
|
||||||
"#count" : 4,
|
"#urls" : (
|
||||||
|
"https://live.staticflickr.com/7322/8719105033_4a21140220_o_d.jpg",
|
||||||
|
"https://live.staticflickr.com/7376/8720226282_eae0faefd1_o_d.jpg",
|
||||||
|
"https://live.staticflickr.com/7460/8720245516_ab06f80353_o_d.jpg",
|
||||||
|
"https://live.staticflickr.com/8268/8705102120_64349ebac2_o_d.jpg",
|
||||||
|
),
|
||||||
|
|
||||||
|
"dates" : dict,
|
||||||
|
"license" : "0",
|
||||||
|
"license_name": "All Rights Reserved",
|
||||||
|
"notes" : dict,
|
||||||
|
"safety_level": "0",
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user