From 3f513f10564a10ece8650e64d2233d8482fc14c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Fri, 5 Apr 2019 22:59:19 +0200 Subject: [PATCH] [flickr] restore image quality MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Flickr started serving images from live.staticflickr.com (see ec88ff1), but the old farmN.staticflickr.com URLs still work - at least for the time being. Filesize (and most likely quality as well) for images from live.… is severely reduced compared to images from farmN.… for non-original files, so all live URLs are replaced to point to a randomly chosen farm server. --- gallery_dl/extractor/flickr.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gallery_dl/extractor/flickr.py b/gallery_dl/extractor/flickr.py index a7df86b8..c6a75096 100644 --- a/gallery_dl/extractor/flickr.py +++ b/gallery_dl/extractor/flickr.py @@ -10,6 +10,7 @@ from .common import Extractor, Message from .. import text, oauth, util, exception +import random class FlickrExtractor(Extractor): @@ -25,12 +26,13 @@ class FlickrExtractor(Extractor): self.load_extra = self.config("metadata", False) def items(self): + farm = "//farm{}.".format(random.randint(1, 9)) info = self.data() yield Message.Version, 1 yield Message.Directory, info for photo in self.photos(): photo.update(info) - url = photo["photo"]["source"] + url = photo["photo"]["source"].replace("//live.", farm) yield Message.Url, url, text.nameext_from_url(url, photo) def data(self): @@ -94,7 +96,8 @@ class FlickrImageExtractor(FlickrExtractor): info = {"id": self.item_id} info["photo"] = size - url = size["source"] + farm = "//farm{}.".format(random.randint(1, 9)) + url = size["source"].replace("//live.", farm) text.nameext_from_url(url, info) yield Message.Version, 1