2016-10-23 17:51:12 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
improved foolslide-based extractors
- this includes dokireader, fallenangels, jaiminisbox, powermanga,
sensescans, worldthree, yonkouprod, gomanga, yomanga
- added 'chapter_string', 'chapter_id', 'chapter_minor' and 'count'
keywords
- changed the 'chapter' keyword to always be just a number
- changed the default directory format
2017-02-16 23:42:30 +01:00
|
|
|
# Copyright 2016-2017 Mike Fährmann
|
2016-10-23 17:51:12 +02:00
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License version 2 as
|
|
|
|
# published by the Free Software Foundation.
|
|
|
|
|
2017-04-11 21:03:40 +02:00
|
|
|
"""Base classes for extractors for FoOlSlide based sites"""
|
2016-10-23 17:51:12 +02:00
|
|
|
|
2017-08-29 22:42:48 +02:00
|
|
|
from .common import SharedConfigExtractor, MangaExtractor, Message
|
2017-03-28 13:12:44 +02:00
|
|
|
from .. import text, util
|
2016-10-23 17:51:12 +02:00
|
|
|
import json
|
improved foolslide-based extractors
- this includes dokireader, fallenangels, jaiminisbox, powermanga,
sensescans, worldthree, yonkouprod, gomanga, yomanga
- added 'chapter_string', 'chapter_id', 'chapter_minor' and 'count'
keywords
- changed the 'chapter' keyword to always be just a number
- changed the default directory format
2017-02-16 23:42:30 +01:00
|
|
|
|
|
|
|
|
|
|
|
CHAPTER_RE = (
|
|
|
|
r"/read/[^/]+"
|
|
|
|
r"/(?P<lang>[a-z]{2})"
|
|
|
|
r"/(?P<volume>\d+)"
|
|
|
|
r"/(?P<chapter>\d+)"
|
|
|
|
r"(?:/(?P<chapter_minor>\d+))?)"
|
|
|
|
)
|
|
|
|
|
2017-04-11 21:03:40 +02:00
|
|
|
MANGA_RE = (
|
|
|
|
r"/series/[^/]+/?$)"
|
|
|
|
)
|
|
|
|
|
improved foolslide-based extractors
- this includes dokireader, fallenangels, jaiminisbox, powermanga,
sensescans, worldthree, yonkouprod, gomanga, yomanga
- added 'chapter_string', 'chapter_id', 'chapter_minor' and 'count'
keywords
- changed the 'chapter' keyword to always be just a number
- changed the default directory format
2017-02-16 23:42:30 +01:00
|
|
|
|
|
|
|
def chapter_pattern(domain_re):
|
|
|
|
return [r"(?:https?://)?(" + domain_re + CHAPTER_RE]
|
2016-10-23 17:51:12 +02:00
|
|
|
|
2017-02-01 00:53:19 +01:00
|
|
|
|
2017-04-11 21:03:40 +02:00
|
|
|
def manga_pattern(domain_re):
|
|
|
|
return [r"(?:https?://)?(" + domain_re + MANGA_RE]
|
|
|
|
|
|
|
|
|
2017-08-29 22:42:48 +02:00
|
|
|
class FoolslideChapterExtractor(SharedConfigExtractor):
|
2017-04-11 21:03:40 +02:00
|
|
|
"""Base class for chapter extractors for FoOlSlide based sites"""
|
2017-08-29 22:42:48 +02:00
|
|
|
basecategory = "foolslide"
|
2016-10-23 17:51:12 +02:00
|
|
|
subcategory = "chapter"
|
improved foolslide-based extractors
- this includes dokireader, fallenangels, jaiminisbox, powermanga,
sensescans, worldthree, yonkouprod, gomanga, yomanga
- added 'chapter_string', 'chapter_id', 'chapter_minor' and 'count'
keywords
- changed the 'chapter' keyword to always be just a number
- changed the default directory format
2017-02-16 23:42:30 +01:00
|
|
|
directory_fmt = ["{category}", "{manga}", "{chapter_string}"]
|
2016-10-28 00:35:48 +02:00
|
|
|
filename_fmt = "{manga}_{chapter:>03}_{page:>03}.{extension}"
|
improved foolslide-based extractors
- this includes dokireader, fallenangels, jaiminisbox, powermanga,
sensescans, worldthree, yonkouprod, gomanga, yomanga
- added 'chapter_string', 'chapter_id', 'chapter_minor' and 'count'
keywords
- changed the 'chapter' keyword to always be just a number
- changed the default directory format
2017-02-16 23:42:30 +01:00
|
|
|
scheme = "https"
|
2017-01-10 00:05:08 +01:00
|
|
|
single = True
|
2016-10-23 17:51:12 +02:00
|
|
|
|
improved foolslide-based extractors
- this includes dokireader, fallenangels, jaiminisbox, powermanga,
sensescans, worldthree, yonkouprod, gomanga, yomanga
- added 'chapter_string', 'chapter_id', 'chapter_minor' and 'count'
keywords
- changed the 'chapter' keyword to always be just a number
- changed the default directory format
2017-02-16 23:42:30 +01:00
|
|
|
def __init__(self, match, url=None):
|
2017-08-29 22:42:48 +02:00
|
|
|
SharedConfigExtractor.__init__(self)
|
improved foolslide-based extractors
- this includes dokireader, fallenangels, jaiminisbox, powermanga,
sensescans, worldthree, yonkouprod, gomanga, yomanga
- added 'chapter_string', 'chapter_id', 'chapter_minor' and 'count'
keywords
- changed the 'chapter' keyword to always be just a number
- changed the default directory format
2017-02-16 23:42:30 +01:00
|
|
|
self.url = url or self.scheme + "://" + match.group(1)
|
|
|
|
self.data = match.groupdict(default="")
|
2016-10-23 17:51:12 +02:00
|
|
|
|
|
|
|
def items(self):
|
|
|
|
page = self.request(self.url, encoding="utf-8",
|
|
|
|
method="post", data={"adult": "true"}).text
|
2017-04-11 21:03:40 +02:00
|
|
|
data = self.get_metadata(page)
|
improved foolslide-based extractors
- this includes dokireader, fallenangels, jaiminisbox, powermanga,
sensescans, worldthree, yonkouprod, gomanga, yomanga
- added 'chapter_string', 'chapter_id', 'chapter_minor' and 'count'
keywords
- changed the 'chapter' keyword to always be just a number
- changed the default directory format
2017-02-16 23:42:30 +01:00
|
|
|
imgs = self.get_images(page)
|
|
|
|
|
|
|
|
data["count"] = len(imgs)
|
|
|
|
data["chapter_id"] = imgs[0]["chapter_id"]
|
|
|
|
|
2016-10-23 17:51:12 +02:00
|
|
|
yield Message.Version, 1
|
|
|
|
yield Message.Directory, data
|
improved foolslide-based extractors
- this includes dokireader, fallenangels, jaiminisbox, powermanga,
sensescans, worldthree, yonkouprod, gomanga, yomanga
- added 'chapter_string', 'chapter_id', 'chapter_minor' and 'count'
keywords
- changed the 'chapter' keyword to always be just a number
- changed the default directory format
2017-02-16 23:42:30 +01:00
|
|
|
for data["page"], image in enumerate(imgs, 1):
|
2016-10-23 17:51:12 +02:00
|
|
|
try:
|
|
|
|
url = image["url"]
|
|
|
|
del image["url"]
|
|
|
|
del image["thumb_url"]
|
|
|
|
except KeyError:
|
|
|
|
pass
|
|
|
|
data.update(image)
|
|
|
|
text.nameext_from_url(data["filename"], data)
|
|
|
|
yield Message.Url, url, data
|
|
|
|
|
2017-04-11 21:03:40 +02:00
|
|
|
def get_metadata(self, page):
|
2016-10-23 17:51:12 +02:00
|
|
|
"""Collect metadata for extractor-job"""
|
improved foolslide-based extractors
- this includes dokireader, fallenangels, jaiminisbox, powermanga,
sensescans, worldthree, yonkouprod, gomanga, yomanga
- added 'chapter_string', 'chapter_id', 'chapter_minor' and 'count'
keywords
- changed the 'chapter' keyword to always be just a number
- changed the default directory format
2017-02-16 23:42:30 +01:00
|
|
|
_ , pos = text.extract(page, '<h1 class="tbtitle dnone">', '')
|
|
|
|
manga , pos = text.extract(page, 'title="', '"', pos)
|
|
|
|
chapter, pos = text.extract(page, 'title="', '"', pos)
|
2016-10-28 00:35:48 +02:00
|
|
|
|
improved foolslide-based extractors
- this includes dokireader, fallenangels, jaiminisbox, powermanga,
sensescans, worldthree, yonkouprod, gomanga, yomanga
- added 'chapter_string', 'chapter_id', 'chapter_minor' and 'count'
keywords
- changed the 'chapter' keyword to always be just a number
- changed the default directory format
2017-02-16 23:42:30 +01:00
|
|
|
chapter = text.unescape(chapter)
|
|
|
|
|
2017-06-22 17:03:34 +02:00
|
|
|
self.data["manga"] = text.unescape(manga).strip()
|
2017-08-21 18:29:50 +02:00
|
|
|
self.data["title"] = chapter.partition(":")[2].strip()
|
2017-03-28 13:12:44 +02:00
|
|
|
self.data["language"] = util.code_to_language(self.data["lang"])
|
improved foolslide-based extractors
- this includes dokireader, fallenangels, jaiminisbox, powermanga,
sensescans, worldthree, yonkouprod, gomanga, yomanga
- added 'chapter_string', 'chapter_id', 'chapter_minor' and 'count'
keywords
- changed the 'chapter' keyword to always be just a number
- changed the default directory format
2017-02-16 23:42:30 +01:00
|
|
|
self.data["chapter_string"] = chapter
|
|
|
|
return self.data
|
2016-10-23 17:51:12 +02:00
|
|
|
|
2017-01-10 00:05:08 +01:00
|
|
|
def get_images(self, page):
|
2016-10-23 17:51:12 +02:00
|
|
|
"""Return a list of all images in this chapter"""
|
2017-01-10 00:05:08 +01:00
|
|
|
if self.single:
|
|
|
|
pos = 0
|
|
|
|
needle = "var pages = "
|
|
|
|
else:
|
|
|
|
pos = page.find("[{")
|
|
|
|
needle = " = "
|
|
|
|
return json.loads(text.extract(page, needle, ";", pos)[0])
|
2017-04-11 21:03:40 +02:00
|
|
|
|
|
|
|
|
2017-08-29 22:42:48 +02:00
|
|
|
class FoolslideMangaExtractor(MangaExtractor, SharedConfigExtractor):
|
2017-04-11 21:03:40 +02:00
|
|
|
"""Base class for manga extractors for FoOlSlide based sites"""
|
|
|
|
scheme = "https"
|
|
|
|
|
2017-05-20 11:27:43 +02:00
|
|
|
def request(self, url):
|
|
|
|
return MangaExtractor.request(
|
|
|
|
self, url, encoding="utf-8", method="post", data={"adult": "true"}
|
|
|
|
)
|
2017-04-11 21:03:40 +02:00
|
|
|
|
2017-05-20 11:27:43 +02:00
|
|
|
def chapters(self, page):
|
2017-04-11 21:03:40 +02:00
|
|
|
"""Return a list of all chapter urls"""
|
2017-09-12 16:44:38 +02:00
|
|
|
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()
|
|
|
|
|
|
|
|
results = []
|
|
|
|
while True:
|
|
|
|
url, pos = text.extract(
|
|
|
|
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, {
|
|
|
|
"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
|
|
|
|
}))
|