Skip to content

Commit

Permalink
[webtoons] Use swebtoon-phinf.pstatic.net instead of webtoon-phinf.ps…
Browse files Browse the repository at this point in the history
…tatic.net

This trick to avoid having to set a Referer header comes from
Webtoon's RSS feeds. The two URLs below are equivalent in content:

https://webtoon-phinf.pstatic.net/20210929_153/1632867980912DmcGK_JPEG/16328679808882705182.jpg?type=q90
https://swebtoon-phinf.pstatic.net/20210929_153/1632867980912DmcGK_JPEG/16328679808882705182.jpg?type=q90

The URL with the domain "webtoon-phinf.pstatic.net" needs a Referer
header, and the domain "swebtoon-phinf.pstatic.net" does not. This
is because of the environment "swebtoon" images live in, one without
explicit network control: RSS feeds on sites such as Feedly. This change should
make it easier for gallery-dl developers to embed Webtoon comics without
worrying about headers.
  • Loading branch information
SuperSonicHub1 committed Nov 7, 2021
1 parent efa178c commit 5e2dab4
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions gallery_dl/extractor/webtoons.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ def __init__(self, match):
url = "{}/{}/viewer?{}".format(self.root, self.path, query)
GalleryExtractor.__init__(self, match, url)
self.setup_agegate_cookies()
self.session.headers["Referer"] = url

query = text.parse_query(query)
self.title_no = query.get("title_no")
Expand All @@ -88,7 +87,7 @@ def metadata(self, page):
@staticmethod
def images(page):
return [
(url, None)
(url.replace("webtoon-phinf.pstatic.net", "swebtoon-phinf.pstatic.net"), None)
for url in text.extract_iter(
page, 'class="_images" data-url="', '"')
]
Expand Down

0 comments on commit 5e2dab4

Please sign in to comment.