[hiperdex] fix extraction (#3768)

This commit is contained in:
Mike Fährmann
2023-03-15 14:28:03 +01:00
parent e7898936df
commit 17bd053d94
2 changed files with 13 additions and 23 deletions

View File

@@ -309,7 +309,7 @@ Consider all sites to be NSFW unless otherwise known.
</tr> </tr>
<tr> <tr>
<td>Hiperdex</td> <td>Hiperdex</td>
<td>https://1sthiperdex.com/</td> <td>https://hiperdex.com/</td>
<td>Artists, Chapters, Manga</td> <td>Artists, Chapters, Manga</td>
<td></td> <td></td>
</tr> </tr>

View File

@@ -6,7 +6,7 @@
# it under the terms of the GNU General Public License version 2 as # it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation. # published by the Free Software Foundation.
"""Extractors for https://1sthiperdex.com/""" """Extractors for https://hiperdex.com/"""
from .common import ChapterExtractor, MangaExtractor from .common import ChapterExtractor, MangaExtractor
from .. import text from .. import text
@@ -20,7 +20,7 @@ BASE_PATTERN = (r"((?:https?://)?(?:www\.)?"
class HiperdexBase(): class HiperdexBase():
"""Base class for hiperdex extractors""" """Base class for hiperdex extractors"""
category = "hiperdex" category = "hiperdex"
root = "https://1sthiperdex.com" root = "https://hiperdex.com"
@memcache(keyarg=1) @memcache(keyarg=1)
def manga_data(self, manga, page=None): def manga_data(self, manga, page=None):
@@ -31,7 +31,7 @@ class HiperdexBase():
return { return {
"manga" : text.unescape(extr( "manga" : text.unescape(extr(
"<title>", "<").rpartition("&")[0].strip()), "<title>", "<").rpartition(" - ")[0].strip()),
"score" : text.parse_float(extr( "score" : text.parse_float(extr(
'id="averagerate">', '<')), 'id="averagerate">', '<')),
"author" : text.remove_html(extr( "author" : text.remove_html(extr(
@@ -65,10 +65,10 @@ class HiperdexBase():
class HiperdexChapterExtractor(HiperdexBase, ChapterExtractor): class HiperdexChapterExtractor(HiperdexBase, ChapterExtractor):
"""Extractor for manga chapters from 1sthiperdex.com""" """Extractor for manga chapters from hiperdex.com"""
pattern = BASE_PATTERN + r"(/manga/([^/?#]+)/([^/?#]+))" pattern = BASE_PATTERN + r"(/manga/([^/?#]+)/([^/?#]+))"
test = ( test = (
("https://1sthiperdex.com/manga/domestic-na-kanojo/154-5/", { ("https://hiperdex.com/manga/domestic-na-kanojo/154-5/", {
"pattern": r"https://(1st)?hiperdex\d?.(com|net|info)" "pattern": r"https://(1st)?hiperdex\d?.(com|net|info)"
r"/wp-content/uploads/WP-manga/data" r"/wp-content/uploads/WP-manga/data"
r"/manga_\w+/[0-9a-f]{32}/\d+\.webp", r"/manga_\w+/[0-9a-f]{32}/\d+\.webp",
@@ -86,7 +86,7 @@ class HiperdexChapterExtractor(HiperdexBase, ChapterExtractor):
"type" : "Manga", "type" : "Manga",
}, },
}), }),
("https://hiperdex.com/manga/domestic-na-kanojo/154-5/"), ("https://1sthiperdex.com/manga/domestic-na-kanojo/154-5/"),
("https://hiperdex2.com/manga/domestic-na-kanojo/154-5/"), ("https://hiperdex2.com/manga/domestic-na-kanojo/154-5/"),
("https://hiperdex.net/manga/domestic-na-kanojo/154-5/"), ("https://hiperdex.net/manga/domestic-na-kanojo/154-5/"),
("https://hiperdex.info/manga/domestic-na-kanojo/154-5/"), ("https://hiperdex.info/manga/domestic-na-kanojo/154-5/"),
@@ -109,11 +109,11 @@ class HiperdexChapterExtractor(HiperdexBase, ChapterExtractor):
class HiperdexMangaExtractor(HiperdexBase, MangaExtractor): class HiperdexMangaExtractor(HiperdexBase, MangaExtractor):
"""Extractor for manga from 1sthiperdex.com""" """Extractor for manga from hiperdex.com"""
chapterclass = HiperdexChapterExtractor chapterclass = HiperdexChapterExtractor
pattern = BASE_PATTERN + r"(/manga/([^/?#]+))/?$" pattern = BASE_PATTERN + r"(/manga/([^/?#]+))/?$"
test = ( test = (
("https://1sthiperdex.com/manga/youre-not-that-special/", { ("https://hiperdex.com/manga/youre-not-that-special/", {
"count": 51, "count": 51,
"pattern": HiperdexChapterExtractor.pattern, "pattern": HiperdexChapterExtractor.pattern,
"keyword": { "keyword": {
@@ -130,7 +130,7 @@ class HiperdexMangaExtractor(HiperdexBase, MangaExtractor):
"type" : "Manhwa", "type" : "Manhwa",
}, },
}), }),
("https://hiperdex.com/manga/youre-not-that-special/"), ("https://1sthiperdex.com/manga/youre-not-that-special/"),
("https://hiperdex2.com/manga/youre-not-that-special/"), ("https://hiperdex2.com/manga/youre-not-that-special/"),
("https://hiperdex.net/manga/youre-not-that-special/"), ("https://hiperdex.net/manga/youre-not-that-special/"),
("https://hiperdex.info/manga/youre-not-that-special/"), ("https://hiperdex.info/manga/youre-not-that-special/"),
@@ -145,19 +145,9 @@ class HiperdexMangaExtractor(HiperdexBase, MangaExtractor):
self.manga_data(self.manga, page) self.manga_data(self.manga, page)
results = [] results = []
shortlink = text.extr(page, "rel='shortlink' href='", "'") for html in text.extract_iter(
data = { page, '<li class="wp-manga-chapter', '</li>'):
"action" : "manga_get_reading_nav", url = text.extr(html, 'href="', '"')
"manga" : shortlink.rpartition("=")[2],
"chapter" : "",
"volume_id": "",
"style" : "list",
"type" : "manga",
}
url = self.root + "/wp-admin/admin-ajax.php"
page = self.request(url, method="POST", data=data).text
for url in text.extract_iter(page, 'data-redirect="', '"'):
chapter = url.rpartition("/")[2] chapter = url.rpartition("/")[2]
results.append((url, self.chapter_data(chapter))) results.append((url, self.chapter_data(chapter)))