* Update webtoons.py
Added thumbnail download capability which defaults to false
* Update configuration.rst
Added documentation for webtoon thumbnail option
* extract thumbnails in GalleryExtractor.assets()
* simplify & fix flake8
* include 'type' in default filenames
* add test
* update docs
---------
Co-authored-by: Mike Fährmann <mike_faehrmann@web.de>
This commit is contained in:
@@ -5541,6 +5541,17 @@ Description
|
||||
| - Set a value to ``false`` to completely remove these extension's ``type`` parameter
|
||||
| - Omit an extension to leave its URLs unchanged
|
||||
|
||||
extractor.webtoons.thumbnails
|
||||
-----------------------------
|
||||
Type
|
||||
``bool``
|
||||
Default
|
||||
``false``
|
||||
Description
|
||||
Download the active chapter's ``thumbnail``.
|
||||
|
||||
Useful for creating CBZ archives with actual source thumbnails.
|
||||
|
||||
|
||||
extractor.weibo.gifs
|
||||
--------------------
|
||||
|
||||
@@ -785,7 +785,8 @@
|
||||
{
|
||||
"sleep-request": "0.5-1.5",
|
||||
|
||||
"quality": "original"
|
||||
"quality" : "original",
|
||||
"thumbnails": false
|
||||
},
|
||||
"weebcentral":
|
||||
{
|
||||
|
||||
@@ -44,7 +44,7 @@ class WebtoonsEpisodeExtractor(WebtoonsBase, GalleryExtractor):
|
||||
"""Extractor for an episode on webtoons.com"""
|
||||
subcategory = "episode"
|
||||
directory_fmt = ("{category}", "{comic}")
|
||||
filename_fmt = "{episode_no}-{num:>02}.{extension}"
|
||||
filename_fmt = "{episode_no}-{num:>02}{type:?-//}.{extension}"
|
||||
archive_fmt = "{title_no}_{episode_no}_{num}"
|
||||
pattern = (LANG_PATTERN + r"/([^/?#]+)/([^/?#]+)/[^/?#]+)"
|
||||
r"/viewer\?([^#'\"]+)")
|
||||
@@ -59,6 +59,7 @@ class WebtoonsEpisodeExtractor(WebtoonsBase, GalleryExtractor):
|
||||
self.title_no = params.get("title_no")
|
||||
self.episode_no = params.get("episode_no")
|
||||
self.gallery_url = "{}/{}/viewer?{}".format(self.root, path, query)
|
||||
self.thumbnails = self.config("thumbnails", False)
|
||||
|
||||
def metadata(self, page):
|
||||
extr = text.extract_from(page)
|
||||
@@ -128,6 +129,13 @@ class WebtoonsEpisodeExtractor(WebtoonsBase, GalleryExtractor):
|
||||
results.append((url, None))
|
||||
return results
|
||||
|
||||
def assets(self, page):
|
||||
if self.thumbnails:
|
||||
active = text.extr(page, 'class="on ', '</a>')
|
||||
url = text.extr(active, 'data-url="', '"')
|
||||
url = url.replace("://webtoon-phinf.", "://swebtoon-phinf.")
|
||||
return ({"url": url, "type": "thumbnail"},)
|
||||
|
||||
|
||||
class WebtoonsComicExtractor(WebtoonsBase, Extractor):
|
||||
"""Extractor for an entire comic on webtoons.com"""
|
||||
|
||||
@@ -13,8 +13,8 @@ __tests__ = (
|
||||
"#url" : "https://www.webtoons.com/en/comedy/safely-endangered/ep-572-earth/viewer?title_no=352&episode_no=572",
|
||||
"#category": ("", "webtoons", "episode"),
|
||||
"#class" : webtoons.WebtoonsEpisodeExtractor,
|
||||
"#count" : 5,
|
||||
"#results" : (
|
||||
"#count" : 5,
|
||||
"#results" : (
|
||||
"https://swebtoon-phinf.pstatic.net/20200513_191/1589322488148XfdRr_PNG/15893224850013525720.png?type=opti",
|
||||
"https://swebtoon-phinf.pstatic.net/20200513_143/1589322489499KJLvU_PNG/15893224866183525723.png?type=opti",
|
||||
"https://swebtoon-phinf.pstatic.net/20200513_281/15893224881499wbH7_PNG/15893224865073525729.png?type=opti",
|
||||
@@ -45,6 +45,20 @@ __tests__ = (
|
||||
"username" : "safelyendangered",
|
||||
},
|
||||
|
||||
{
|
||||
"#url" : "https://www.webtoons.com/en/comedy/safely-endangered/ep-572-earth/viewer?title_no=352&episode_no=572",
|
||||
"#comment" : "thumbnails (#6468 #7441)",
|
||||
"#class" : webtoons.WebtoonsEpisodeExtractor,
|
||||
"#options" : {"thumbnails": True},
|
||||
"#range" : "1",
|
||||
"#results" : "https://swebtoon-phinf.pstatic.net/20200513_37/1589322553469E5p76_PNG/thumb_15893224866533525729.png",
|
||||
"#sha1_content": "e01e70610821df6ece601393eb6fd7d80fc42f9a",
|
||||
|
||||
"count": 5,
|
||||
"num" : 0,
|
||||
"type" : "thumbnail",
|
||||
},
|
||||
|
||||
{
|
||||
"#url" : "https://www.webtoons.com/en/challenge/punderworld/happy-earth-day-/viewer?title_no=312584&episode_no=40",
|
||||
"#category": ("", "webtoons", "episode"),
|
||||
|
||||
Reference in New Issue
Block a user