From 7a0ba370d17eb41748247cc1fc49bfe7789957cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Wed, 14 Oct 2020 20:03:29 +0200 Subject: [PATCH] [gelbooru] rewrite mp4 video URLs (fixes #1048) --- gallery_dl/extractor/booru.py | 6 +++++- gallery_dl/extractor/gelbooru.py | 9 +++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/gallery_dl/extractor/booru.py b/gallery_dl/extractor/booru.py index be0027a4..0176d769 100644 --- a/gallery_dl/extractor/booru.py +++ b/gallery_dl/extractor/booru.py @@ -51,7 +51,7 @@ class BooruExtractor(SharedConfigMixin, Extractor): for image in images: try: - url = image["file_url"] + url = self.get_file_url(image) except KeyError: continue if url.startswith("/"): @@ -86,6 +86,10 @@ class BooruExtractor(SharedConfigMixin, Extractor): """Collect metadata for extractor-job""" return {} + @staticmethod + def get_file_url(image): + return image["file_url"] + def extended_tags(self, image, page=None): """Retrieve extended tag information""" if not page: diff --git a/gallery_dl/extractor/gelbooru.py b/gallery_dl/extractor/gelbooru.py index edadd314..c32ba5c0 100644 --- a/gallery_dl/extractor/gelbooru.py +++ b/gallery_dl/extractor/gelbooru.py @@ -33,6 +33,15 @@ class GelbooruExtractor(booru.XmlParserMixin, self.session.cookies["fringeBenefits"] = "yup" self.per_page = 42 + @staticmethod + def get_file_url(image): + url = image["file_url"] + if url.startswith("https://mp4.gelbooru.com/"): + ihash = image["md5"] + return "https://img2.gelbooru.com/images/{}/{}/{}.webm".format( + ihash[0:2], ihash[2:4], ihash) + return url + def items_noapi(self): yield Message.Version, 1 data = self.get_metadata()