2020-02-21 23:40:32 +01:00
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
|
|
# Copyright 2020 Mike Fährmann
|
|
|
|
|
#
|
|
|
|
|
# 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.
|
|
|
|
|
|
2020-05-28 01:55:32 +02:00
|
|
|
|
"""Extractors for https://hiperdex.com/"""
|
2020-02-21 23:40:32 +01:00
|
|
|
|
|
|
|
|
|
from .common import ChapterExtractor, MangaExtractor
|
|
|
|
|
from .. import text
|
|
|
|
|
from ..cache import memcache
|
|
|
|
|
import re
|
|
|
|
|
|
|
|
|
|
|
2020-05-28 01:55:32 +02:00
|
|
|
|
BASE_PATTERN = r"(?:https?://)?(?:www\.)?hiperdex\.(?:com|net|info)"
|
2020-05-11 23:37:47 +02:00
|
|
|
|
|
|
|
|
|
|
2020-02-21 23:40:32 +01:00
|
|
|
|
class HiperdexBase():
|
|
|
|
|
"""Base class for hiperdex extractors"""
|
|
|
|
|
category = "hiperdex"
|
2020-05-28 01:55:32 +02:00
|
|
|
|
root = "https://hiperdex.com"
|
2020-02-21 23:40:32 +01:00
|
|
|
|
|
|
|
|
|
@memcache(keyarg=1)
|
|
|
|
|
def manga_data(self, manga, page=None):
|
|
|
|
|
if not page:
|
|
|
|
|
url = "{}/manga/{}/".format(self.root, manga)
|
|
|
|
|
page = self.request(url).text
|
|
|
|
|
extr = text.extract_from(page)
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
"manga" : text.unescape(extr(
|
|
|
|
|
"<title>", "<").rpartition("&")[0].strip()),
|
|
|
|
|
"score" : text.parse_float(extr(
|
|
|
|
|
'id="averagerate">', '<')),
|
|
|
|
|
"author" : text.remove_html(extr(
|
|
|
|
|
'class="author-content">', '</div>')),
|
|
|
|
|
"artist" : text.remove_html(extr(
|
|
|
|
|
'class="artist-content">', '</div>')),
|
|
|
|
|
"genre" : text.split_html(extr(
|
|
|
|
|
'class="genres-content">', '</div>'))[::2],
|
|
|
|
|
"type" : extr(
|
|
|
|
|
'class="summary-content">', '<').strip(),
|
|
|
|
|
"release": text.parse_int(text.remove_html(extr(
|
|
|
|
|
'class="summary-content">', '</div>'))),
|
|
|
|
|
"status" : extr(
|
|
|
|
|
'class="summary-content">', '<').strip(),
|
|
|
|
|
"description": text.remove_html(text.unescape(extr(
|
|
|
|
|
'class="description-summary">', '</div>'))),
|
|
|
|
|
"language": "English",
|
|
|
|
|
"lang" : "en",
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def chapter_data(self, chapter):
|
|
|
|
|
chapter, _, minor = chapter.partition("-")
|
|
|
|
|
data = {
|
|
|
|
|
"chapter" : text.parse_int(chapter),
|
2020-02-29 00:18:54 +01:00
|
|
|
|
"chapter_minor": "." + minor if minor and minor != "end" else "",
|
2020-02-21 23:40:32 +01:00
|
|
|
|
}
|
|
|
|
|
data.update(self.manga_data(self.manga.lower()))
|
|
|
|
|
return data
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class HiperdexChapterExtractor(HiperdexBase, ChapterExtractor):
|
2020-05-28 01:55:32 +02:00
|
|
|
|
"""Extractor for manga chapters from hiperdex.com"""
|
2020-10-22 23:12:59 +02:00
|
|
|
|
pattern = BASE_PATTERN + r"(/manga/([^/?#]+)/([^/?#]+))"
|
2020-04-16 20:39:56 +02:00
|
|
|
|
test = (
|
2020-05-28 01:55:32 +02:00
|
|
|
|
("https://hiperdex.com/manga/domestic-na-kanojo/154-5/", {
|
|
|
|
|
"pattern": r"https://hiperdex.(com|net|info)/wp-content/uploads"
|
2020-04-16 20:39:56 +02:00
|
|
|
|
r"/WP-manga/data/manga_\w+/[0-9a-f]{32}/\d+\.webp",
|
|
|
|
|
"count": 9,
|
|
|
|
|
"keyword": {
|
|
|
|
|
"artist" : "Sasuga Kei",
|
|
|
|
|
"author" : "Sasuga Kei",
|
|
|
|
|
"chapter": 154,
|
|
|
|
|
"chapter_minor": ".5",
|
|
|
|
|
"description": "re:Natsuo Fujii is in love with his teacher, ",
|
|
|
|
|
"genre" : list,
|
|
|
|
|
"manga" : "Domestic na Kanojo",
|
|
|
|
|
"release": 2014,
|
|
|
|
|
"score" : float,
|
|
|
|
|
"type" : "Manga",
|
|
|
|
|
},
|
|
|
|
|
}),
|
2020-04-27 20:42:31 +02:00
|
|
|
|
("https://hiperdex.net/manga/domestic-na-kanojo/154-5/"),
|
2020-05-28 01:55:32 +02:00
|
|
|
|
("https://hiperdex.info/manga/domestic-na-kanojo/154-5/"),
|
2020-04-16 20:39:56 +02:00
|
|
|
|
)
|
2020-02-21 23:40:32 +01:00
|
|
|
|
|
|
|
|
|
def __init__(self, match):
|
|
|
|
|
path, self.manga, self.chapter = match.groups()
|
|
|
|
|
ChapterExtractor.__init__(self, match, self.root + path + "/")
|
|
|
|
|
|
|
|
|
|
def metadata(self, _):
|
|
|
|
|
return self.chapter_data(self.chapter)
|
|
|
|
|
|
|
|
|
|
def images(self, page):
|
|
|
|
|
return [
|
|
|
|
|
(url.strip(), None)
|
2020-04-03 21:25:25 +02:00
|
|
|
|
for url in re.findall(
|
|
|
|
|
r'id="image-\d+"\s+(?:data-)?src="([^"]+)', page)
|
2020-02-21 23:40:32 +01:00
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class HiperdexMangaExtractor(HiperdexBase, MangaExtractor):
|
2020-05-28 01:55:32 +02:00
|
|
|
|
"""Extractor for manga from hiperdex.com"""
|
2020-02-21 23:40:32 +01:00
|
|
|
|
chapterclass = HiperdexChapterExtractor
|
2020-10-22 23:12:59 +02:00
|
|
|
|
pattern = BASE_PATTERN + r"(/manga/([^/?#]+))/?$"
|
2020-04-16 20:39:56 +02:00
|
|
|
|
test = (
|
2020-05-28 01:55:32 +02:00
|
|
|
|
("https://hiperdex.com/manga/youre-not-that-special/", {
|
2020-04-16 20:39:56 +02:00
|
|
|
|
"count": 51,
|
|
|
|
|
"pattern": HiperdexChapterExtractor.pattern,
|
|
|
|
|
"keyword": {
|
|
|
|
|
"artist" : "Bolp",
|
|
|
|
|
"author" : "Abyo4",
|
|
|
|
|
"chapter": int,
|
|
|
|
|
"chapter_minor": "",
|
|
|
|
|
"description": "re:I didn’t think much of the creepy girl in ",
|
|
|
|
|
"genre" : list,
|
|
|
|
|
"manga" : "You’re Not That Special!",
|
|
|
|
|
"release": 2019,
|
|
|
|
|
"score" : float,
|
|
|
|
|
"status" : "Completed",
|
|
|
|
|
"type" : "Manhwa",
|
|
|
|
|
},
|
|
|
|
|
}),
|
2020-04-27 20:42:31 +02:00
|
|
|
|
("https://hiperdex.net/manga/youre-not-that-special/"),
|
2020-05-28 01:55:32 +02:00
|
|
|
|
("https://hiperdex.info/manga/youre-not-that-special/"),
|
2020-04-16 20:39:56 +02:00
|
|
|
|
)
|
2020-02-21 23:40:32 +01:00
|
|
|
|
|
|
|
|
|
def __init__(self, match):
|
|
|
|
|
path, self.manga = match.groups()
|
|
|
|
|
MangaExtractor.__init__(self, match, self.root + path + "/")
|
|
|
|
|
|
|
|
|
|
def chapters(self, page):
|
|
|
|
|
self.manga_data(self.manga, page)
|
|
|
|
|
results = []
|
2020-04-12 02:27:13 +02:00
|
|
|
|
|
|
|
|
|
shortlink = text.extract(page, "rel='shortlink' href='", "'")[0]
|
|
|
|
|
data = {
|
|
|
|
|
"action": "manga_get_chapters",
|
|
|
|
|
"manga" : shortlink.rpartition("=")[2],
|
|
|
|
|
}
|
|
|
|
|
url = self.root + "/wp-admin/admin-ajax.php"
|
|
|
|
|
page = self.request(url, method="POST", data=data).text
|
|
|
|
|
|
|
|
|
|
for url in text.extract_iter(page, 'href="', '"', 320):
|
|
|
|
|
chapter = url.rpartition("/")[2]
|
|
|
|
|
results.append((url, self.chapter_data(chapter)))
|
2020-02-21 23:40:32 +01:00
|
|
|
|
|
|
|
|
|
return results
|
2020-04-12 02:32:37 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class HiperdexArtistExtractor(HiperdexBase, MangaExtractor):
|
2020-05-28 01:55:32 +02:00
|
|
|
|
"""Extractor for an artists's manga on hiperdex.com"""
|
2020-04-12 02:32:37 +02:00
|
|
|
|
subcategory = "artist"
|
|
|
|
|
categorytransfer = False
|
|
|
|
|
chapterclass = HiperdexMangaExtractor
|
|
|
|
|
reverse = False
|
2020-10-22 23:12:59 +02:00
|
|
|
|
pattern = BASE_PATTERN + r"(/manga-a(?:rtist|uthor)/([^/?#]+))"
|
2020-04-12 02:32:37 +02:00
|
|
|
|
test = (
|
|
|
|
|
("https://hiperdex.com/manga-artist/beck-ho-an/"),
|
2020-04-27 20:42:31 +02:00
|
|
|
|
("https://hiperdex.net/manga-artist/beck-ho-an/"),
|
2020-05-28 01:55:32 +02:00
|
|
|
|
("https://hiperdex.info/manga-artist/beck-ho-an/"),
|
2020-04-12 02:32:37 +02:00
|
|
|
|
("https://hiperdex.com/manga-author/viagra/", {
|
|
|
|
|
"pattern": HiperdexMangaExtractor.pattern,
|
|
|
|
|
"count": ">= 6",
|
|
|
|
|
}),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def __init__(self, match):
|
|
|
|
|
MangaExtractor.__init__(self, match, self.root + match.group(1) + "/")
|
|
|
|
|
|
|
|
|
|
def chapters(self, page):
|
|
|
|
|
results = []
|
|
|
|
|
for info in text.extract_iter(page, 'id="manga-item-', '<img'):
|
|
|
|
|
url = text.extract(info, 'href="', '"')[0]
|
|
|
|
|
results.append((url, {}))
|
|
|
|
|
return results
|