Skip to content

Commit

Permalink
[newgrounds] support 'art-image' files (#4642)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Oct 9, 2023
1 parent 63db54b commit 15f9408
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
4 changes: 3 additions & 1 deletion gallery_dl/extractor/newgrounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ def items(self):
yield Message.Url, url, text.nameext_from_url(url, post)

for num, url in enumerate(text.extract_iter(
post["_comment"], 'data-smartload-src="', '"'), 1):
post["_images"] + post["_comment"],
'data-smartload-src="', '"'), 1):
post["num"] = num
post["_index"] = "{}_{:>02}".format(post["index"], num)
url = text.ensure_http_scheme(url)
Expand Down Expand Up @@ -135,6 +136,7 @@ def extract_post(self, post_url):
extr = text.extract_from(page)
data = extract_data(extr, post_url)

data["_images"] = extr('<div class="art-images', '\n</div>')
data["_comment"] = extr(
'id="author_comments"', '</div>').partition(">")[2]
data["comment"] = text.unescape(text.remove_html(
Expand Down
33 changes: 25 additions & 8 deletions test/results/newgrounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@
"#url" : "https://www.newgrounds.com/art/view/tomfulp/ryu-is-hawt",
"#category": ("", "newgrounds", "image"),
"#class" : newgrounds.NewgroundsImageExtractor,
"#sha1_url" : "57f182bcbbf2612690c3a54f16ffa1da5105245e",
"#urls" : "https://art.ngfiles.com/images/1993000/1993615_4474_tomfulp_ryu-is-hawt.44f81090378ae9c257a5e46a8e17cc4d.gif?f1695674895",
"#sha1_content": "8f395e08333eb2457ba8d8b715238f8910221365",

"artist" : ["tomfulp"],
"comment" : r"re:Consider this the bottom threshold for ",
"comment" : "Consider this the bottom threshold for scouted artists.In fact consider it BELOW the bottom threshold.",
"date" : "dt:2009-06-04 14:44:05",
"description": r"re:Consider this the bottom threshold for ",
"description": "Consider this the bottom threshold for scouted artists. In fact consider it BELOW the bottom threshold. ",
"favorites" : int,
"filename" : "94_tomfulp_ryu-is-hawt",
"filename" : "1993615_4474_tomfulp_ryu-is-hawt.44f81090378ae9c257a5e46a8e17cc4d",
"height" : 476,
"index" : 94,
"index" : 1993615,
"rating" : "e",
"score" : float,
"tags" : [
Expand All @@ -39,15 +39,32 @@
"#url" : "https://art.ngfiles.com/images/0/94_tomfulp_ryu-is-hawt.gif",
"#category": ("", "newgrounds", "image"),
"#class" : newgrounds.NewgroundsImageExtractor,
"#sha1_url": "57f182bcbbf2612690c3a54f16ffa1da5105245e",
"#urls" : "https://art.ngfiles.com/images/1993000/1993615_4474_tomfulp_ryu-is-hawt.44f81090378ae9c257a5e46a8e17cc4d.gif?f1695674895",
},

{
"#url" : "https://www.newgrounds.com/art/view/sailoryon/yon-dream-buster",
"#comment" : "embedded file in 'comments' (#1033)",
"#category": ("", "newgrounds", "image"),
"#class" : newgrounds.NewgroundsImageExtractor,
"#count" : 2,
"#sha1_url": "84eec95e663041a80630df72719f231e157e5f5d",
"#urls" : (
"https://art.ngfiles.com/images/1438000/1438673_sailoryon_yon-dream-buster.jpg?f1601058173",
"https://art.ngfiles.com/comments/172000/iu_172374_7112211.jpg",
),
},

{
"#url" : "https://www.newgrounds.com/art/view/zedrinbot/lewd-animation-tutorial",
"#comment" : "extra files in 'art-image-row' elements (#4642)",
"#category": ("", "newgrounds", "image"),
"#class" : newgrounds.NewgroundsImageExtractor,
"#urls" : (
"https://art.ngfiles.com/images/5091000/5091275_45067_zedrinbot_untitled-5091275.0a9d27ed2bc265a7e89478ed6ad6f86f.gif?f1696187399",
"https://art.ngfiles.com/medium_views/5091000/5091275_45071_zedrinbot_untitled-5091275.6fdc62eaef43528fb1c9bda624d30a3d.webp?f1696187437",
"https://art.ngfiles.com/medium_views/5091000/5091275_45070_zedrinbot_untitled-5091275.0d7334746374465bd448908b88d1f810.webp?f1696187435",
"https://art.ngfiles.com/medium_views/5091000/5091275_45072_zedrinbot_untitled-5091275.6fdc62eaef43528fb1c9bda624d30a3d.webp?f1696187438",
"https://art.ngfiles.com/medium_views/5091000/5091275_45073_zedrinbot_untitled-5091275.20aa05c1cd22fd058e8c68ce58f5a302.webp?f1696187439",
),
},

{
Expand Down

0 comments on commit 15f9408

Please sign in to comment.