1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-22 10:42:34 +01:00

[flickr] add 'exif' option

This commit is contained in:
Mike Fährmann 2023-07-01 19:19:39 +02:00
parent 3845c0256d
commit c45a913bfd
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
3 changed files with 27 additions and 2 deletions

View File

@ -1541,6 +1541,18 @@ Description
from `linking your Flickr account to gallery-dl <OAuth_>`__. from `linking your Flickr account to gallery-dl <OAuth_>`__.
extractor.flickr.exif
---------------------
Type
``bool``
Default
``false``
Description
Fetch `exif` and `camera` metadata for each photo.
Note: This requires 1 additional API call per photo.
extractor.flickr.metadata extractor.flickr.metadata
------------------------- -------------------------
Type Type

View File

@ -108,8 +108,10 @@
}, },
"flickr": "flickr":
{ {
"videos": true, "exif": false,
"size-max": null "metadata": false,
"size-max": null,
"videos": true
}, },
"furaffinity": "furaffinity":
{ {

View File

@ -106,6 +106,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 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)
@ -323,6 +325,7 @@ 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.maxsize = extractor.config("size-max") self.maxsize = extractor.config("size-max")
if isinstance(self.maxsize, str): if isinstance(self.maxsize, str):
@ -367,6 +370,11 @@ class FlickrAPI(oauth.OAuth1API):
params = {"user_id": user_id} params = {"user_id": user_id}
return self._pagination("people.getPhotos", params) return self._pagination("people.getPhotos", params)
def photos_getExif(self, photo_id):
"""Retrieves a list of EXIF/TIFF/GPS tags for a given photo."""
params = {"photo_id": photo_id}
return self._call("photos.getExif", params)["photo"]
def photos_getInfo(self, photo_id): def photos_getInfo(self, photo_id):
"""Get information about a photo.""" """Get information about a photo."""
params = {"photo_id": photo_id} params = {"photo_id": photo_id}
@ -488,6 +496,9 @@ class FlickrAPI(oauth.OAuth1API):
photo["views"] = text.parse_int(photo["views"]) photo["views"] = text.parse_int(photo["views"])
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:
photo.update(self.photos_getExif(photo["id"]))
photo["id"] = text.parse_int(photo["id"]) photo["id"] = text.parse_int(photo["id"])
if "owner" in photo: if "owner" in photo: