Skip to content

Commit

Permalink
[flickr] use "download" URLs (#6360)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Nov 9, 2024
1 parent 1ddbcda commit 0e18fa3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
11 changes: 9 additions & 2 deletions gallery_dl/extractor/flickr.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def items(self):
self.log.debug("", exc_info=exc)
else:
photo.update(data)
url = photo["url"]
url = self._file_url(photo)
yield Message.Directory, photo
yield Message.Url, url, text.nameext_from_url(url, photo)

Expand All @@ -57,6 +57,13 @@ def metadata(self):
def photos(self):
"""Return an iterable with all relevant photo objects"""

def _file_url(self, photo):
if "video" in photo:
return photo["url"]

path, _, ext = photo["url"].rpartition(".")
return path + "_d." + ext


class FlickrImageExtractor(FlickrExtractor):
"""Extractor for individual images from flickr.com"""
Expand Down Expand Up @@ -98,7 +105,7 @@ def items(self):
if isinstance(value, dict):
location[key] = value["_content"]

url = photo["url"]
url = self._file_url(photo)
yield Message.Directory, photo
yield Message.Url, url, text.nameext_from_url(url, photo)

Expand Down
9 changes: 5 additions & 4 deletions test/results/flickr.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"contexts": True,
"exif": True,
},
"#urls" : "https://live.staticflickr.com/7463/16089302239_de18cd8017_b_d.jpg",
"#pattern" : flickr.FlickrImageExtractor.pattern,
"#sha1_content": [
"3133006c6d657fe54cf7d4c46b82abbcb0efaf9f",
Expand All @@ -28,7 +29,7 @@
"description": str,
"exif" : list,
"extension" : "jpg",
"filename" : "16089302239_de18cd8017_b",
"filename" : "16089302239_de18cd8017_b_d",
"id" : 16089302239,
"height" : 683,
"label" : "Large",
Expand Down Expand Up @@ -59,10 +60,10 @@
},

{
"#url" : "https://www.flickr.com/photos/145617051@N08/46733161535",
"#category": ("", "flickr", "image"),
"#url" : "https://www.flickr.com/photos/eliasroviello/52713899383/",
"#comment" : "video",
"#class" : flickr.FlickrImageExtractor,
"#count" : 1,
"#pattern" : r"https://live.staticflickr\.com/video/52713899383/51dfffef79/1080p\.mp4\?s=ey.+",

"media": "video",
},
Expand Down

0 comments on commit 0e18fa3

Please sign in to comment.