From 36f281330ae797a7bab7338297f58bd9125fb8bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Tue, 19 Jan 2021 17:43:55 +0100 Subject: [PATCH] [newgrounds] fix flash file extraction (closes #1257) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … and add a 'flash' option to choose between flash and video formats. --- docs/configuration.rst | 10 ++++++++++ gallery_dl/extractor/newgrounds.py | 24 +++++++++++++++++------- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/docs/configuration.rst b/docs/configuration.rst index 47f2d2ce68..0121875419 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -1116,6 +1116,16 @@ Description the first in the list gets chosen (usually `mp3`). +extractor.newgrounds.flash +-------------------------- +Type + ``bool`` +Default + ``true`` +Description + Download original Adobe Flash animations instead of pre-rendered videos. + + extractor.newgrounds.include ---------------------------- Type diff --git a/gallery_dl/extractor/newgrounds.py b/gallery_dl/extractor/newgrounds.py index a6cc5fadb5..4fdfac9968 100644 --- a/gallery_dl/extractor/newgrounds.py +++ b/gallery_dl/extractor/newgrounds.py @@ -29,6 +29,7 @@ def __init__(self, match): Extractor.__init__(self, match) self.user = match.group(1) self.user_root = "https://{}.newgrounds.com".format(self.user) + self.flash = self.config("flash", True) def items(self): self.login() @@ -92,18 +93,22 @@ def _login_impl(self, username, password): } def extract_post(self, post_url): + + if "/art/view/" in post_url: + extract_data = self._extract_image_data + elif "/audio/listen/" in post_url: + extract_data = self._extract_audio_data + else: + extract_data = self._extract_media_data + if self.flash: + post_url += "/format/flash" + response = self.request(post_url, fatal=False) if response.status_code >= 400: return {} page = response.text extr = text.extract_from(page) - - if "/art/view/" in post_url: - data = self._extract_image_data(extr, post_url) - elif "/audio/listen/" in post_url: - data = self._extract_audio_data(extr, post_url) - else: - data = self._extract_media_data(extr, post_url) + data = extract_data(extr, post_url) data["_comment"] = extr('id="author_comments"', '') data["comment"] = text.unescape(text.remove_html( @@ -313,6 +318,11 @@ class NewgroundsMediaExtractor(NewgroundsExtractor): "user" : "zj", }, }), + # flash animation (#1257) + ("https://www.newgrounds.com/portal/view/161181/format/flash", { + "pattern": r"https://uploads\.ungrounded\.net/161000" + r"/161181_ddautta_mask__550x281_\.swf\?f1081628129", + }) ) def __init__(self, match):