From a53cfc845e12d9e98fefd07e43ebffaec488c18f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Wed, 30 Mar 2022 16:14:43 +0200 Subject: [PATCH] [newgrounds] warn about age-restricted posts (#2456) --- gallery_dl/extractor/newgrounds.py | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/gallery_dl/extractor/newgrounds.py b/gallery_dl/extractor/newgrounds.py index 6d0e94b5..28f1ef73 100644 --- a/gallery_dl/extractor/newgrounds.py +++ b/gallery_dl/extractor/newgrounds.py @@ -113,10 +113,16 @@ class NewgroundsExtractor(Extractor): if self.flash: url += "/format/flash" - response = self.request(url, fatal=False) - if response.status_code >= 400: - return {} - page = response.text + with self.request(url, fatal=False) as response: + if response.status_code >= 400: + return {} + page = response.text + + pos = page.find('id="adults_only"') + if pos >= 0: + msg = text.extract(page, 'class="highlight">', '<', pos)[0] + self.log.warning('"%s"', msg) + extr = text.extract_from(page) data = extract_data(extr, post_url) @@ -293,7 +299,12 @@ class NewgroundsImageExtractor(NewgroundsExtractor): ("https://www.newgrounds.com/art/view/sailoryon/yon-dream-buster", { "url": "84eec95e663041a80630df72719f231e157e5f5d", "count": 2, - }) + }), + # "adult" rated (#2456) + ("https://www.newgrounds.com/art/view/bdoneart/vampire-booty", { + "options": (("username", None),), + "count": 0, + }), ) def __init__(self, match): @@ -360,6 +371,11 @@ class NewgroundsMediaExtractor(NewgroundsExtractor): "pattern": r"https://uploads\.ungrounded\.net/alternate/1482000" r"/1482860_alternate_102516\.720p\.mp4\?\d+", }), + # "adult" rated (#2456) + ("https://www.newgrounds.com/portal/view/717744", { + "options": (("username", None),), + "count": 0, + }), ) def __init__(self, match):