Skip to content

Commit

Permalink
[webtoons] generalize and improve comic extraction (fixes #820)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Jun 10, 2020
1 parent 1489712 commit 998d1d3
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions gallery_dl/extractor/webtoons.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class WebtoonsEpisodeExtractor(WebtoonsExtractor):
filename_fmt = "{episode}-{num:>02}.{extension}"
archive_fmt = "{title_no}_{episode}_{num}"
pattern = (BASE_PATTERN + r"/([^/?&#]+)/([^/?&#]+)/(?:[^/?&#]+))"
r"/viewer(?:\?([^#]+))")
r"/viewer(?:\?([^#'\"]+))")
test = (
(("https://www.webtoons.com/en/comedy/safely-endangered"
"/ep-572-earth/viewer?title_no=352&episode_no=572"), {
Expand Down Expand Up @@ -111,6 +111,11 @@ class WebtoonsComicExtractor(WebtoonsExtractor):
"list?title_no=1845&page=3"), {
"count": ">= 15",
}),
# (#820)
(("https://www.webtoons.com/en/challenge/scoob-and-shag/"
"list?title_no=210827&page=9"), {
"count": ">= 18",
}),
)

def __init__(self, match):
Expand Down Expand Up @@ -143,6 +148,8 @@ def items(self):
@staticmethod
def get_episode_urls(page):
"""Extract and return all episode urls in 'page'"""
pos = page.find('id="_listUl"')
return text.extract_iter(
page, '<a href="', '" class="NPI=a:list', pos)
page = text.extract(page, 'id="_listUl"', '</ul>')[0]
return [
match.group(0)
for match in WebtoonsEpisodeExtractor.pattern.finditer(page)
]

0 comments on commit 998d1d3

Please sign in to comment.