[mangahere] support sub-chapters (e.g. ch4.5)
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
"""Extract manga pages from http://www.mangahere.co/"""
|
"""Extract manga pages from http://www.mangahere.co/"""
|
||||||
|
|
||||||
from .common import AsynchronousExtractor, Message
|
from .common import Extractor, AsynchronousExtractor, Message
|
||||||
from .. import text
|
from .. import text
|
||||||
import re
|
import re
|
||||||
|
|
||||||
@@ -43,23 +43,22 @@ class MangaHereMangaExtractor(Extractor):
|
|||||||
class MangaHereChapterExtractor(AsynchronousExtractor):
|
class MangaHereChapterExtractor(AsynchronousExtractor):
|
||||||
|
|
||||||
category = "mangahere"
|
category = "mangahere"
|
||||||
directory_fmt = ["{category}", "{manga}", "c{chapter:>03}"]
|
directory_fmt = ["{category}", "{manga}", "c{chapter:>03}{chapter-minor}"]
|
||||||
filename_fmt = "{manga}_c{chapter:>03}_{page:>03}.{extension}"
|
filename_fmt = "{manga}_c{chapter:>03}{chapter-minor}_{page:>03}.{extension}"
|
||||||
pattern = [r"(?:https?://)?(?:www\.)?mangahere\.co/manga/([^/]+(?:/v0*(\d+))?/c0*(\d+))"]
|
pattern = [(r"(?:https?://)?(?:www\.)?mangahere\.co/manga/"
|
||||||
|
r"([^/]+(?:/v0*(\d+))?/c0*(\d+)(\.\d+)?)")]
|
||||||
url_fmt = "http://www.mangahere.co/manga/{}/{}.html"
|
url_fmt = "http://www.mangahere.co/manga/{}/{}.html"
|
||||||
|
|
||||||
def __init__(self, match):
|
def __init__(self, match):
|
||||||
AsynchronousExtractor.__init__(self)
|
AsynchronousExtractor.__init__(self)
|
||||||
self.part = match.group(1)
|
self.part, self.volume, self.chapter, self.chminor = match.groups()
|
||||||
self.volume = match.group(2)
|
|
||||||
self.chapter = match.group(3)
|
|
||||||
|
|
||||||
def items(self):
|
def items(self):
|
||||||
page = self.request(self.url_fmt.format(self.part, 1)).text
|
page = self.request(self.url_fmt.format(self.part, 1)).text
|
||||||
data = self.get_job_metadata(page)
|
data = self.get_job_metadata(page)
|
||||||
yield Message.Version, 1
|
yield Message.Version, 1
|
||||||
yield Message.Directory, data.copy()
|
yield Message.Directory, data.copy()
|
||||||
for i, url in zip(range(int(data["count"])), (self.get_image_urls(page))):
|
for i, url in zip(range(int(data["count"])), self.get_image_urls(page)):
|
||||||
data["page"] = i+1
|
data["page"] = i+1
|
||||||
text.nameext_from_url(url, data)
|
text.nameext_from_url(url, data)
|
||||||
yield Message.Url, url, data.copy()
|
yield Message.Url, url, data.copy()
|
||||||
@@ -71,13 +70,14 @@ class MangaHereChapterExtractor(AsynchronousExtractor):
|
|||||||
_ , pos = text.extract(page, '<select class="wid60"', '', pos)
|
_ , pos = text.extract(page, '<select class="wid60"', '', pos)
|
||||||
_ , pos = text.extract(page, '</select>', '', pos)
|
_ , pos = text.extract(page, '</select>', '', pos)
|
||||||
count, pos = text.extract(page, '>', '<', pos-30)
|
count, pos = text.extract(page, '>', '<', pos-30)
|
||||||
manga = re.match(r"(.+) \d+ - Read .+ Chapter \d+ Online", manga).group(1)
|
manga = re.match(r"(.+) \d+(\.\d+)? - Read .+ Chapter \d+(\.\d+)? Online", manga).group(1)
|
||||||
return {
|
return {
|
||||||
"category": self.category,
|
"category": self.category,
|
||||||
"manga": text.unescape(manga),
|
"manga": text.unescape(manga),
|
||||||
# "title": TODO,
|
# "title": TODO,
|
||||||
"volume": self.volume or "",
|
"volume": self.volume or "",
|
||||||
"chapter": self.chapter,
|
"chapter": self.chapter,
|
||||||
|
"chapter-minor": self.chminor or "",
|
||||||
"chapter-id": chid,
|
"chapter-id": chid,
|
||||||
"count": count,
|
"count": count,
|
||||||
"lang": "en",
|
"lang": "en",
|
||||||
|
|||||||
Reference in New Issue
Block a user