mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-22 10:42:34 +01:00
[foolslide] restructure; convert suitable values to int
This commit is contained in:
parent
deb2e803ba
commit
a85f06d2d1
@ -17,7 +17,7 @@ class DokireaderChapterExtractor(foolslide.FoolslideChapterExtractor):
|
||||
pattern = foolslide.chapter_pattern(r"kobato\.hologfx\.com/reader")
|
||||
test = [(("https://kobato.hologfx.com/reader/read/"
|
||||
"hitoribocchi_no_oo_seikatsu/en/3/34"), {
|
||||
"keyword": "1dc1ec8264df4126552dbe53f42c5643fd2a4cf3",
|
||||
"keyword": "998d1d523da028284b8dd4b7b54ceae4af6cb65a",
|
||||
})]
|
||||
|
||||
|
||||
@ -28,4 +28,5 @@ class DokireaderMangaExtractor(foolslide.FoolslideMangaExtractor):
|
||||
test = [(("https://kobato.hologfx.com/reader/series/"
|
||||
"boku_ha_ohimesama_ni_narenai/"), {
|
||||
"url": "1c1f5a7258ce4f631f5fc32be548d78a6a57990d",
|
||||
"keyword": "614d89a6045b85c822cbd3e67578ea7577dfc995",
|
||||
})]
|
||||
|
@ -34,28 +34,44 @@ def manga_pattern(domain_re):
|
||||
return [r"(?:https?://)?(" + domain_re + MANGA_RE]
|
||||
|
||||
|
||||
class FoolslideChapterExtractor(SharedConfigExtractor):
|
||||
"""Base class for chapter extractors for FoOlSlide based sites"""
|
||||
class FoolslideExtractor(SharedConfigExtractor):
|
||||
"""Base class for FoOlSlide extractors"""
|
||||
basecategory = "foolslide"
|
||||
scheme = "https"
|
||||
|
||||
def request(self, url):
|
||||
return SharedConfigExtractor.request(
|
||||
self, url, encoding="utf-8", method="post", data={"adult": "true"})
|
||||
|
||||
@staticmethod
|
||||
def parse_chapter_url(url, data):
|
||||
info = url.partition("/read/")[2].split("/")
|
||||
data["lang"] = info[1]
|
||||
data["language"] = util.code_to_language(info[1])
|
||||
data["volume"] = util.safe_int(info[2])
|
||||
data["chapter"] = util.safe_int(info[3])
|
||||
data["chapter_minor"] = "." + info[4] if len(info) >= 6 else ""
|
||||
return data
|
||||
|
||||
|
||||
class FoolslideChapterExtractor(FoolslideExtractor):
|
||||
"""Base class for chapter extractors for FoOlSlide based sites"""
|
||||
subcategory = "chapter"
|
||||
directory_fmt = ["{category}", "{manga}", "{chapter_string}"]
|
||||
filename_fmt = "{manga}_{chapter:>03}_{page:>03}.{extension}"
|
||||
scheme = "https"
|
||||
single = True
|
||||
|
||||
def __init__(self, match, url=None):
|
||||
SharedConfigExtractor.__init__(self)
|
||||
FoolslideExtractor.__init__(self)
|
||||
self.url = url or self.scheme + "://" + match.group(1)
|
||||
self.data = match.groupdict(default="")
|
||||
|
||||
def items(self):
|
||||
page = self.request(self.url, encoding="utf-8",
|
||||
method="post", data={"adult": "true"}).text
|
||||
page = self.request(self.url).text
|
||||
data = self.get_metadata(page)
|
||||
imgs = self.get_images(page)
|
||||
|
||||
data["count"] = len(imgs)
|
||||
data["chapter_id"] = imgs[0]["chapter_id"]
|
||||
data["chapter_id"] = util.safe_int(imgs[0]["chapter_id"])
|
||||
|
||||
yield Message.Version, 1
|
||||
yield Message.Directory, data
|
||||
@ -63,9 +79,12 @@ class FoolslideChapterExtractor(SharedConfigExtractor):
|
||||
try:
|
||||
url = image["url"]
|
||||
del image["url"]
|
||||
del image["chapter_id"]
|
||||
del image["thumb_url"]
|
||||
except KeyError:
|
||||
pass
|
||||
for key in ("height", "id", "size", "width"):
|
||||
image[key] = util.safe_int(image[key])
|
||||
data.update(image)
|
||||
text.nameext_from_url(data["filename"], data)
|
||||
yield Message.Url, url, data
|
||||
@ -75,14 +94,12 @@ class FoolslideChapterExtractor(SharedConfigExtractor):
|
||||
_ , pos = text.extract(page, '<h1 class="tbtitle dnone">', '')
|
||||
manga , pos = text.extract(page, 'title="', '"', pos)
|
||||
chapter, pos = text.extract(page, 'title="', '"', pos)
|
||||
|
||||
chapter = text.unescape(chapter)
|
||||
|
||||
self.data["manga"] = text.unescape(manga).strip()
|
||||
self.data["title"] = chapter.partition(":")[2].strip()
|
||||
self.data["language"] = util.code_to_language(self.data["lang"])
|
||||
self.data["chapter_string"] = chapter
|
||||
return self.data
|
||||
return self.parse_chapter_url(self.url, {
|
||||
"manga": text.unescape(manga).strip(),
|
||||
"title": chapter.partition(":")[2].strip(),
|
||||
"chapter_string": chapter,
|
||||
})
|
||||
|
||||
def get_images(self, page):
|
||||
"""Return a list of all images in this chapter"""
|
||||
@ -95,21 +112,15 @@ class FoolslideChapterExtractor(SharedConfigExtractor):
|
||||
return json.loads(text.extract(page, needle, ";", pos)[0])
|
||||
|
||||
|
||||
class FoolslideMangaExtractor(MangaExtractor, SharedConfigExtractor):
|
||||
class FoolslideMangaExtractor(FoolslideExtractor, MangaExtractor):
|
||||
"""Base class for manga extractors for FoOlSlide based sites"""
|
||||
scheme = "https"
|
||||
|
||||
def request(self, url):
|
||||
return MangaExtractor.request(
|
||||
self, url, encoding="utf-8", method="post", data={"adult": "true"}
|
||||
)
|
||||
|
||||
def chapters(self, page):
|
||||
"""Return a list of all chapter urls"""
|
||||
manga , pos = text.extract(page, '<h1 class="title">', '</h1>')
|
||||
author, pos = text.extract(page, '<b>Author</b>: ', '<br', pos)
|
||||
artist, pos = text.extract(page, '<b>Artist</b>: ', '<br', pos)
|
||||
manga = manga.strip()
|
||||
manga = text.unescape(manga).strip()
|
||||
|
||||
results = []
|
||||
while True:
|
||||
@ -117,15 +128,12 @@ class FoolslideMangaExtractor(MangaExtractor, SharedConfigExtractor):
|
||||
page, '<div class="title"><a href="', '"', pos)
|
||||
if not url:
|
||||
return results
|
||||
info = url.partition("/read/")[2].split("/")
|
||||
|
||||
chapter, pos = text.extract(page, 'title="', '"', pos)
|
||||
group , pos = text.extract(page, 'title="', '"', pos)
|
||||
results.append((url, {
|
||||
|
||||
results.append((url, self.parse_chapter_url(url, {
|
||||
"manga": manga, "author": author, "artist": artist,
|
||||
"group": group, "chapter_string": chapter,
|
||||
"title": chapter.partition(": ")[2] or "",
|
||||
"lang": info[1], "language": util.code_to_language(info[1]),
|
||||
"volume": int(info[2]), "chapter": int(info[3]),
|
||||
"chapter_minor": int(info[4]) if len(info) >= 6 else 0
|
||||
}))
|
||||
})))
|
||||
|
@ -18,11 +18,11 @@ class GomangaChapterExtractor(foolslide.FoolslideChapterExtractor):
|
||||
test = [
|
||||
("https://gomanga.co/reader/read/mata-kata-omou/en/0/1/page/11", {
|
||||
"url": "5088d75bb44327fc503c85b52b1d6a371b8057f2",
|
||||
"keyword": "f534cfc4c3aef87cb0439e2a37e2ebee98077e92",
|
||||
"keyword": "10624e78924c37fd39543270a6965f2082bde08f",
|
||||
}),
|
||||
("https://gomanga.co/reader/read/pastel/en/31/144/", {
|
||||
"url": "9cc2052fbf36344c573c754c5abe533a14b3e280",
|
||||
"keyword": "a2ef55d26984c64baf026382f889bb013d01dc4f",
|
||||
"keyword": "a355cd3197e70c24b84d3885e8a5ff0ac22537bf",
|
||||
}),
|
||||
]
|
||||
single = False
|
||||
@ -34,5 +34,6 @@ class GomangaMangaExtractor(foolslide.FoolslideMangaExtractor):
|
||||
pattern = foolslide.manga_pattern(r"(?:www\.)?gomanga\.co/reader")
|
||||
test = [("https://gomanga.co/reader/series/pastel/", {
|
||||
"url": "bd1c82d70838d54140a8209296e789f27ceab7cd",
|
||||
"keyword": "fb1fd14548602dbe4f6e70a633429762972c1d5d",
|
||||
})]
|
||||
single = False
|
||||
|
@ -17,10 +17,10 @@ class JaiminisboxChapterExtractor(foolslide.FoolslideChapterExtractor):
|
||||
pattern = foolslide.chapter_pattern(r"(?:www\.)?jaiminisbox\.com/reader")
|
||||
test = [
|
||||
("https://jaiminisbox.com/reader/read/uratarou/en/0/1/", {
|
||||
"keyword": "d187df3e3b6dbe09ec163626f6fd7c57133ab163",
|
||||
"keyword": "d8919bc8f0351b44e938862214e654401962b5a5",
|
||||
}),
|
||||
("https://jaiminisbox.com/reader/read/dr-stone/en/0/16/", {
|
||||
"keyword": "6b6896d98a2eb8f38e9b7f5242a547b826da2599",
|
||||
"keyword": "faa77b1f6ff462cd5e01511ab55b8c2d6ec42c3e",
|
||||
}),
|
||||
]
|
||||
|
||||
@ -31,4 +31,5 @@ class JaiminisboxMangaExtractor(foolslide.FoolslideMangaExtractor):
|
||||
pattern = foolslide.manga_pattern(r"(?:www\.)?jaiminisbox\.com/reader")
|
||||
test = [("https://jaiminisbox.com/reader/series/sora_no_kian/", {
|
||||
"url": "66612be177dc3b3fa1d1f537ef02f4f701b163ea",
|
||||
"keyword": "0908a4145bb03acc4210f5d01169988969f5acd1",
|
||||
})]
|
||||
|
@ -17,7 +17,7 @@ class KireicakeChapterExtractor(foolslide.FoolslideChapterExtractor):
|
||||
pattern = foolslide.chapter_pattern(r"reader\.kireicake\.com")
|
||||
test = [("https://reader.kireicake.com/read/wonderland/en/1/1/", {
|
||||
"url": "b2d36bc0bc67e4c461c3a4d6444a2fd339f5d07e",
|
||||
"keyword": "17d04e3bb24f6ad593463ecb7f90667f0df5326f",
|
||||
"keyword": "47e0cf69f95ab3b820bda05014aec38d3b824018",
|
||||
})]
|
||||
|
||||
|
||||
@ -27,4 +27,5 @@ class KireicakeMangaExtractor(foolslide.FoolslideMangaExtractor):
|
||||
pattern = foolslide.manga_pattern(r"reader\.kireicake\.com")
|
||||
test = [("https://reader.kireicake.com/series/wonderland/", {
|
||||
"url": "d067b649af1cc88fa8c8b698fde04a10909fd169",
|
||||
"keyword": "99caa336a9d48e27e3b8e56a0a1e6faf9fc13a51",
|
||||
})]
|
||||
|
@ -17,7 +17,7 @@ class PowermangaChapterExtractor(foolslide.FoolslideChapterExtractor):
|
||||
pattern = foolslide.chapter_pattern(r"read(?:er)?\.powermanga\.org")
|
||||
test = [("https://read.powermanga.org/read/one_piece/en/0/803/page/1", {
|
||||
"url": "e6179c1565068f99180620281f86bdd25be166b4",
|
||||
"keyword": "203ea5d0ef7759f4517316f0678f3592fc27cdbe",
|
||||
"keyword": "224cab1f946d976ddbe4ef88fa1c02303699910b",
|
||||
})]
|
||||
|
||||
|
||||
@ -27,4 +27,5 @@ class PowermangaMangaExtractor(foolslide.FoolslideMangaExtractor):
|
||||
pattern = foolslide.manga_pattern(r"read\.powermanga\.org")
|
||||
test = [("http://read.powermanga.org/series/my_hero_academia/", {
|
||||
"url": "3c7004eea7eefc8d365af3ec95ba98f8cc359553",
|
||||
"keyword": "3c4899ce96ed3ba7871f34532befd2102f10b471",
|
||||
})]
|
||||
|
@ -17,7 +17,7 @@ class SeaotterscansChapterExtractor(foolslide.FoolslideChapterExtractor):
|
||||
pattern = foolslide.chapter_pattern("reader\.seaotterscans\.com")
|
||||
test = [("https://reader.seaotterscans.com/read/100_days/en/0/5/", {
|
||||
"url": "63d46b8883cc652dfe8bd5be4492160dd31f06a8",
|
||||
"keyword": "4d92576e23ee2a5058fd150690230091ee091868",
|
||||
"keyword": "5349c2fbaa88070e6af600de17a6c4e212243e8e",
|
||||
})]
|
||||
|
||||
|
||||
@ -27,4 +27,5 @@ class SeaotterscansMangaExtractor(foolslide.FoolslideMangaExtractor):
|
||||
pattern = foolslide.manga_pattern("reader\.seaotterscans\.com")
|
||||
test = [("https://reader.seaotterscans.com/series/marry_me/", {
|
||||
"url": "fdbacabfa566a6baeb3f01bb46cbda0577bd4bbe",
|
||||
"keyword": "61d3388d73df12f64361892b47a9398df4a5947c",
|
||||
})]
|
||||
|
@ -29,12 +29,12 @@ class SensescansChapterExtractor(SensescansExtractor,
|
||||
(("http://reader.sensescans.com/read/"
|
||||
"magi__labyrinth_of_magic/en/33/319/page/1"), {
|
||||
"url": "cc192cbeed36127d374926c50c3a4bd06092b760",
|
||||
"keyword": "f80104d205e3f537ca11fef9e761393c956768f0",
|
||||
"keyword": "fcc1ff4a902f222364df9c39db2f8e7dcbcd53da",
|
||||
}),
|
||||
(("http://sensescans.com/reader/read/"
|
||||
"magi__labyrinth_of_magic/en/33/319/page/1"), {
|
||||
"url": "cc192cbeed36127d374926c50c3a4bd06092b760",
|
||||
"keyword": "f80104d205e3f537ca11fef9e761393c956768f0",
|
||||
"keyword": "fcc1ff4a902f222364df9c39db2f8e7dcbcd53da",
|
||||
}),
|
||||
]
|
||||
|
||||
@ -46,4 +46,5 @@ class SensescansMangaExtractor(SensescansExtractor,
|
||||
r"(?:/reader)?(" + foolslide.MANGA_RE)]
|
||||
test = [("http://sensescans.com/reader/series/hakkenden/", {
|
||||
"url": "2360ccb0ead0ff2f5e27b7aef7eb17b9329de2f2",
|
||||
"keyword": "122cf92c32e6428c50f56ffaf29d06b96750ed71",
|
||||
})]
|
||||
|
@ -19,12 +19,12 @@ class WorldthreeChapterExtractor(foolslide.FoolslideChapterExtractor):
|
||||
(("http://www.slide.world-three.org"
|
||||
"/read/black_bullet/en/2/7/page/1"), {
|
||||
"url": "be2f04f6e2d311b35188094cfd3e768583271584",
|
||||
"keyword": "25fd070bc93ee8ad316f5b7d1bd9011c9bcf0616",
|
||||
"keyword": "28edfeccc92f7ea29546d5616e689dcfcbac59d9",
|
||||
}),
|
||||
(("http://www.slide.world-three.org"
|
||||
"/read/idolmster_cg_shuffle/en/0/4/2/"), {
|
||||
"url": "6028ea5ca282744f925dfad92eeb98509f9cc78c",
|
||||
"keyword": "10e3dc961ac2c9395f4d1f3ad3b9ad84113e7366",
|
||||
"keyword": "5710e9c862c53d89268d68f353c1fe5836a323d1",
|
||||
}),
|
||||
]
|
||||
scheme = "http"
|
||||
@ -36,5 +36,6 @@ class WorldthreeMangaExtractor(foolslide.FoolslideMangaExtractor):
|
||||
pattern = foolslide.manga_pattern("(?:www\.)?slide\.world-three\.org")
|
||||
test = [("http://www.slide.world-three.org/series/black_bullet/", {
|
||||
"url": "5743b93512d26e6b540d90a7a5d69208b6d4a738",
|
||||
"keyword": "3a24f1088b4d7f3b798a96163f21ca251293a120",
|
||||
})]
|
||||
scheme = "http"
|
||||
|
@ -68,7 +68,6 @@ skip = [
|
||||
# temporary issues
|
||||
"luscious", # "high load"
|
||||
"pawoo",
|
||||
"seaotterscans", # "Name or service not known"
|
||||
]
|
||||
# enable selective testing for direct calls
|
||||
if __name__ == '__main__' and len(sys.argv) > 1:
|
||||
@ -77,7 +76,8 @@ if __name__ == '__main__' and len(sys.argv) > 1:
|
||||
else:
|
||||
extractors = [
|
||||
extr for extr in extractor.extractors()
|
||||
if extr.category in sys.argv
|
||||
if extr.category in sys.argv or
|
||||
hasattr(extr, "basecategory") and extr.basecategory in sys.argv
|
||||
]
|
||||
del sys.argv[1:]
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user