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

[flickr] restore image quality

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.
This commit is contained in:
Mike Fährmann 2019-04-05 22:59:19 +02:00
parent 060859cc68
commit 3f513f1056
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

View File

@ -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