Skip to content

Commit

Permalink
merge #5094: [webtoons] fix extracting comic and episode name with co…
Browse files Browse the repository at this point in the history
…mmas
  • Loading branch information
mikf committed Jan 20, 2024
2 parents b1561a2 + df71888 commit 5bf156f
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 4 deletions.
18 changes: 14 additions & 4 deletions gallery_dl/extractor/webtoons.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,20 @@ def _init(self):

def metadata(self, page):
extr = text.extract_from(page)
keywords = extr('<meta name="keywords" content="', '"').split(", ")
title = extr('<meta property="og:title" content="', '"')
descr = extr('<meta property="og:description" content="', '"')

if extr('<div class="subj_info"', '\n'):
comic_name = extr('>', '<')
episode_name = extr('<h1 class="subj_episode" title="', '"')
else:
comic_name = episode_name = ""

if extr('<span class="tx _btnOpenEpisodeList ', '"'):
episode = extr('>#', '<')
else:
episode = ""

if extr('<div class="author_area"', '\n'):
username = extr('/creator/', '"')
author_name = extr('<span>', '</span>')
Expand All @@ -104,9 +114,9 @@ def metadata(self, page):
"title_no" : self.title_no,
"episode_no" : self.episode_no,
"title" : text.unescape(title),
"episode" : keywords[1],
"comic_name" : text.unescape(keywords[0]),
"episode_name": text.unescape(keywords[2]),
"episode" : episode,
"comic_name" : text.unescape(comic_name),
"episode_name": text.unescape(episode_name),
"username" : username,
"author_name" : text.unescape(author_name),
"description" : text.unescape(descr),
Expand Down
27 changes: 27 additions & 0 deletions test/results/webtoons.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,37 @@

"comic_name" : "I want to be a cute anime girl",
"episode_name": "209 - The story's story",
"episode" : "214",
"username" : "m9huj",
"author_name" : "Azul Crescent",
},

{
"#url" : "https://www.webtoons.com/en/canvas/i-want-to-be-a-cute-anime-girl/174-not-194-it-was-a-typo-later/viewer?title_no=349416&episode_no=179",
"#category": ("", "webtoons", "episode"),
"#class" : webtoons.WebtoonsEpisodeExtractor,
"#count" : 4,

"comic_name" : "I want to be a cute anime girl",
"episode_name": "174 (not 194, it was a typo) - Later",
"episode" : "179",
"username" : "m9huj",
"author_name" : "Azul Crescent",
},

{
"#url" : "https://www.webtoons.com/en/canvas/us-over-here/1-the-wheel/viewer?title_no=919536&episode_no=1",
"#category": ("", "webtoons", "episode"),
"#class" : webtoons.WebtoonsEpisodeExtractor,
"#count" : 59,

"comic_name" : "Us, over here",
"episode_name": "1. The Wheel",
"episode" : "1",
"username" : "i94q8",
"author_name" : "spin.ani",
},

{
"#url" : "https://www.webtoons.com/en/comedy/live-with-yourself/list?title_no=919",
"#comment" : "english",
Expand Down

0 comments on commit 5bf156f

Please sign in to comment.