2016-09-22 17:20:57 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2022-02-06 21:39:24 +01:00
|
|
|
# Copyright 2015-2022 Mike Fährmann
|
2016-09-22 17:20:57 +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.
|
|
|
|
|
2021-03-29 02:12:29 +02:00
|
|
|
"""Extractors for https://dynasty-scans.com/"""
|
2016-09-22 17:20:57 +02:00
|
|
|
|
2021-11-19 22:48:49 +01:00
|
|
|
from .common import ChapterExtractor, MangaExtractor, Extractor, Message
|
2018-04-20 14:53:21 +02:00
|
|
|
from .. import text
|
2016-09-22 17:20:57 +02:00
|
|
|
import json
|
2019-02-11 18:38:47 +01:00
|
|
|
import re
|
2016-09-22 17:20:57 +02:00
|
|
|
|
2019-02-18 12:24:13 +01:00
|
|
|
BASE_PATTERN = r"(?:https?://)?(?:www\.)?dynasty-scans\.com"
|
|
|
|
|
|
|
|
|
|
|
|
class DynastyscansBase():
|
|
|
|
"""Base class for dynastyscans extractors"""
|
2016-09-22 17:20:57 +02:00
|
|
|
category = "dynastyscans"
|
2019-02-18 12:24:13 +01:00
|
|
|
root = "https://dynasty-scans.com"
|
|
|
|
|
|
|
|
def _parse_image_page(self, image_id):
|
|
|
|
url = "{}/images/{}".format(self.root, image_id)
|
2019-04-19 23:02:29 +02:00
|
|
|
extr = text.extract_from(self.request(url).text)
|
2019-02-18 12:24:13 +01:00
|
|
|
|
2019-04-19 23:02:29 +02:00
|
|
|
date = extr("class='create_at'>", "</span>")
|
|
|
|
tags = extr("class='tags'>", "</span>")
|
|
|
|
src = extr("class='btn-group'>", "</div>")
|
|
|
|
url = extr(' src="', '"')
|
2019-02-18 12:24:13 +01:00
|
|
|
|
|
|
|
src = text.extract(src, 'href="', '"')[0] if "Source<" in src else ""
|
|
|
|
|
|
|
|
return {
|
2019-04-19 23:02:29 +02:00
|
|
|
"url" : self.root + url,
|
2019-02-18 12:24:13 +01:00
|
|
|
"image_id": text.parse_int(image_id),
|
2021-03-29 02:12:29 +02:00
|
|
|
"tags" : text.split_html(tags),
|
2019-04-19 23:02:29 +02:00
|
|
|
"date" : text.remove_html(date),
|
|
|
|
"source" : text.unescape(src),
|
2019-02-18 12:24:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class DynastyscansChapterExtractor(DynastyscansBase, ChapterExtractor):
|
|
|
|
"""Extractor for manga-chapters from dynasty-scans.com"""
|
2020-10-22 23:12:59 +02:00
|
|
|
pattern = BASE_PATTERN + r"(/chapters/[^/?#]+)"
|
2019-02-08 13:45:40 +01:00
|
|
|
test = (
|
2017-02-01 00:53:19 +01:00
|
|
|
(("http://dynasty-scans.com/chapters/"
|
|
|
|
"hitoribocchi_no_oo_seikatsu_ch33"), {
|
2017-11-06 20:56:49 +01:00
|
|
|
"url": "dce64e8c504118f1ab4135c00245ea12413896cb",
|
2021-11-21 22:50:52 +01:00
|
|
|
"keyword": "b67599703c27316a2fe4f11c3232130a1904e032",
|
2016-09-22 17:20:57 +02:00
|
|
|
}),
|
2017-02-01 00:53:19 +01:00
|
|
|
(("http://dynasty-scans.com/chapters/"
|
|
|
|
"new_game_the_spinoff_special_13"), {
|
2017-11-06 20:56:49 +01:00
|
|
|
"url": "dbe5bbb74da2edcfb1832895a484e2a40bc8b538",
|
2021-11-21 22:50:52 +01:00
|
|
|
"keyword": "6b674eb3a274999153f6be044973b195008ced2f",
|
2016-09-22 17:20:57 +02:00
|
|
|
}),
|
2019-02-08 13:45:40 +01:00
|
|
|
)
|
2016-09-22 17:20:57 +02:00
|
|
|
|
2019-02-11 18:38:47 +01:00
|
|
|
def metadata(self, page):
|
2019-04-19 23:02:29 +02:00
|
|
|
extr = text.extract_from(page)
|
2016-09-22 17:20:57 +02:00
|
|
|
match = re.match(
|
2017-10-10 17:14:39 +02:00
|
|
|
(r"(?:<a[^>]*>)?([^<]+)(?:</a>)?" # manga name
|
|
|
|
r"(?: ch(\d+)([^:<]*))?" # chapter info
|
|
|
|
r"(?:: (.+))?"), # title
|
2019-04-19 23:02:29 +02:00
|
|
|
extr("<h3 id='chapter-title'><b>", "</b>"),
|
2016-09-22 17:20:57 +02:00
|
|
|
)
|
2019-04-19 23:02:29 +02:00
|
|
|
author = extr(" by ", "</a>")
|
|
|
|
group = extr('"icon-print"></i> ', '</span>')
|
2017-10-10 17:14:39 +02:00
|
|
|
|
2016-09-22 17:20:57 +02:00
|
|
|
return {
|
2019-04-19 23:02:29 +02:00
|
|
|
"manga" : text.unescape(match.group(1)),
|
|
|
|
"chapter" : text.parse_int(match.group(2)),
|
2017-10-10 17:14:39 +02:00
|
|
|
"chapter_minor": match.group(3) or "",
|
2019-04-19 23:02:29 +02:00
|
|
|
"title" : text.unescape(match.group(4) or ""),
|
|
|
|
"author" : text.remove_html(author),
|
|
|
|
"group" : (text.remove_html(group) or
|
|
|
|
text.extract(group, ' alt="', '"')[0] or ""),
|
2021-11-21 22:50:52 +01:00
|
|
|
"date" : text.parse_datetime(extr(
|
|
|
|
'"icon-calendar"></i> ', '<'), "%b %d, %Y"),
|
2019-04-19 23:02:29 +02:00
|
|
|
"lang" : "en",
|
2016-09-22 17:20:57 +02:00
|
|
|
"language": "English",
|
|
|
|
}
|
|
|
|
|
2019-02-11 18:38:47 +01:00
|
|
|
def images(self, page):
|
2016-09-22 17:20:57 +02:00
|
|
|
data = text.extract(page, "var pages = ", ";\n")[0]
|
2018-02-03 23:14:32 +01:00
|
|
|
return [
|
|
|
|
(self.root + img["image"], None)
|
|
|
|
for img in json.loads(data)
|
|
|
|
]
|
2019-02-18 12:24:13 +01:00
|
|
|
|
|
|
|
|
2021-11-19 22:48:49 +01:00
|
|
|
class DynastyscansMangaExtractor(DynastyscansBase, MangaExtractor):
|
|
|
|
chapterclass = DynastyscansChapterExtractor
|
|
|
|
reverse = False
|
|
|
|
pattern = BASE_PATTERN + r"(/series/[^/?#]+)"
|
|
|
|
test = ("https://dynasty-scans.com/series/hitoribocchi_no_oo_seikatsu", {
|
|
|
|
"pattern": DynastyscansChapterExtractor.pattern,
|
|
|
|
"count": ">= 100",
|
|
|
|
})
|
|
|
|
|
|
|
|
def chapters(self, page):
|
|
|
|
return [
|
|
|
|
(self.root + path, {})
|
|
|
|
for path in text.extract_iter(page, '<dd>\n<a href="', '"')
|
|
|
|
]
|
|
|
|
|
|
|
|
|
2019-02-18 12:24:13 +01:00
|
|
|
class DynastyscansSearchExtractor(DynastyscansBase, Extractor):
|
|
|
|
"""Extrator for image search results on dynasty-scans.com"""
|
|
|
|
subcategory = "search"
|
|
|
|
directory_fmt = ("{category}", "Images")
|
|
|
|
filename_fmt = "{image_id}.{extension}"
|
|
|
|
archive_fmt = "i_{image_id}"
|
2019-04-26 21:15:42 +02:00
|
|
|
pattern = BASE_PATTERN + r"/images/?(?:\?([^#]+))?$"
|
|
|
|
test = (
|
|
|
|
("https://dynasty-scans.com/images?with[]=4930&with[]=5211", {
|
2022-02-06 21:39:24 +01:00
|
|
|
"url": "22cf0fb64e12b29e79b0a3d26666086a48f9916a",
|
|
|
|
"keyword": "11cbc555a15528d25567977b8808e10369c4c3ee",
|
2019-04-26 21:15:42 +02:00
|
|
|
}),
|
|
|
|
("https://dynasty-scans.com/images", {
|
|
|
|
"range": "1",
|
|
|
|
"count": 1,
|
|
|
|
}),
|
|
|
|
)
|
2019-02-18 12:24:13 +01:00
|
|
|
|
|
|
|
def __init__(self, match):
|
|
|
|
Extractor.__init__(self, match)
|
2019-04-26 21:15:42 +02:00
|
|
|
self.query = match.group(1) or ""
|
2019-02-18 12:24:13 +01:00
|
|
|
|
|
|
|
def items(self):
|
|
|
|
yield Message.Directory, {}
|
|
|
|
for image_id in self.images():
|
2019-04-26 22:25:54 +02:00
|
|
|
image = self._parse_image_page(image_id)
|
|
|
|
url = image["url"]
|
|
|
|
yield Message.Url, url, text.nameext_from_url(url, image)
|
2019-02-18 12:24:13 +01:00
|
|
|
|
|
|
|
def images(self):
|
2019-04-26 21:15:42 +02:00
|
|
|
url = self.root + "/images?" + self.query.replace("[]", "%5B%5D")
|
2019-02-18 12:24:13 +01:00
|
|
|
params = {"page": 1}
|
|
|
|
|
|
|
|
while True:
|
|
|
|
page = self.request(url, params=params).text
|
|
|
|
yield from text.extract_iter(page, '"/images/', '"')
|
|
|
|
if 'rel="next"' not in page:
|
|
|
|
return
|
|
|
|
params["page"] += 1
|
|
|
|
|
|
|
|
|
2019-04-26 22:25:54 +02:00
|
|
|
class DynastyscansImageExtractor(DynastyscansSearchExtractor):
|
2019-02-18 12:24:13 +01:00
|
|
|
"""Extractor for individual images on dynasty-scans.com"""
|
|
|
|
subcategory = "image"
|
|
|
|
pattern = BASE_PATTERN + r"/images/(\d+)"
|
|
|
|
test = ("https://dynasty-scans.com/images/1245", {
|
|
|
|
"url": "15e54bd94148a07ed037f387d046c27befa043b2",
|
2021-09-03 01:01:59 +02:00
|
|
|
"keyword": "0d8976c2d6fbc9ed6aa712642631b96e456dc37f",
|
2019-02-18 12:24:13 +01:00
|
|
|
})
|
|
|
|
|
2019-04-26 22:25:54 +02:00
|
|
|
def images(self):
|
|
|
|
return (self.query,)
|