[kaliscan] update/simplify
This commit is contained in:
@@ -1,7 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright 2025 Mike Fährmann
|
|
||||||
#
|
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# 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
|
# 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.
|
||||||
@@ -22,17 +20,17 @@ class KaliscanBase():
|
|||||||
|
|
||||||
@memcache(keyarg=1)
|
@memcache(keyarg=1)
|
||||||
def manga_data(self, manga_slug, page=None):
|
def manga_data(self, manga_slug, page=None):
|
||||||
if not page:
|
if page is None:
|
||||||
url = "{}/manga/{}".format(self.root, manga_slug)
|
url = f"{self.root}/manga/{manga_slug}"
|
||||||
page = self.request(url).text
|
page = self.request(url).text
|
||||||
extr = text.extract_from(page)
|
extr = text.extract_from(page)
|
||||||
|
|
||||||
|
manga_id = text.parse_int(extr("bookId =", ";"))
|
||||||
title = text.unescape(extr("<h1>", "<"))
|
title = text.unescape(extr("<h1>", "<"))
|
||||||
alt_titles = extr("<h2>", "<")
|
if alt_titles := extr("<h2>", "<"):
|
||||||
alt_titles = (
|
alt_titles = [t.strip() for t in alt_titles.split(",")]
|
||||||
[t.strip() for t in alt_titles.split(",")]
|
else:
|
||||||
if alt_titles else []
|
alt_titles = ()
|
||||||
)
|
|
||||||
|
|
||||||
author = text.remove_html(extr(
|
author = text.remove_html(extr(
|
||||||
"Authors :</strong>", "</p>"))
|
"Authors :</strong>", "</p>"))
|
||||||
@@ -41,13 +39,10 @@ class KaliscanBase():
|
|||||||
genres = [g.strip(" ,") for g in text.split_html(extr(
|
genres = [g.strip(" ,") for g in text.split_html(extr(
|
||||||
"Genres :</strong>", "</p>"))]
|
"Genres :</strong>", "</p>"))]
|
||||||
|
|
||||||
desc_html = extr('class="content"', '<div class="readmore"')
|
if descr := extr('class="content"', '<div class="readmore"'):
|
||||||
description = (
|
descr = text.remove_html(descr[descr.find(">")+1:]).strip()
|
||||||
text.remove_html(desc_html.partition(">")[2]).strip()
|
else:
|
||||||
if desc_html else ""
|
descr = ""
|
||||||
)
|
|
||||||
|
|
||||||
manga_id = text.parse_int(text.extr(page, "bookId =", ";"))
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"manga" : title,
|
"manga" : title,
|
||||||
@@ -57,7 +52,7 @@ class KaliscanBase():
|
|||||||
"author" : author,
|
"author" : author,
|
||||||
"status" : status,
|
"status" : status,
|
||||||
"genres" : genres,
|
"genres" : genres,
|
||||||
"description" : description,
|
"description" : descr,
|
||||||
"lang" : "en",
|
"lang" : "en",
|
||||||
"language" : "English",
|
"language" : "English",
|
||||||
}
|
}
|
||||||
@@ -68,10 +63,6 @@ class KaliscanChapterExtractor(KaliscanBase, ChapterExtractor):
|
|||||||
pattern = BASE_PATTERN + r"(/manga/([\w-]+)/chapter-([\d.]+))"
|
pattern = BASE_PATTERN + r"(/manga/([\w-]+)/chapter-([\d.]+))"
|
||||||
example = "https://kaliscan.me/manga/ID-MANGA/chapter-1"
|
example = "https://kaliscan.me/manga/ID-MANGA/chapter-1"
|
||||||
|
|
||||||
def __init__(self, match):
|
|
||||||
ChapterExtractor.__init__(self, match)
|
|
||||||
self.manga_slug = self.groups[1]
|
|
||||||
|
|
||||||
def metadata(self, page):
|
def metadata(self, page):
|
||||||
extr = text.extract_from(page)
|
extr = text.extract_from(page)
|
||||||
|
|
||||||
@@ -87,16 +78,16 @@ class KaliscanChapterExtractor(KaliscanBase, ChapterExtractor):
|
|||||||
"chapter" : text.parse_int(chapter),
|
"chapter" : text.parse_int(chapter),
|
||||||
"chapter_minor": sep + minor,
|
"chapter_minor": sep + minor,
|
||||||
"chapter_id" : chapter_id,
|
"chapter_id" : chapter_id,
|
||||||
|
**self.manga_data(self.groups[1]),
|
||||||
}
|
}
|
||||||
data.update(self.manga_data(self.manga_slug))
|
if manga_id and not data["manga_id"]:
|
||||||
if manga_id:
|
|
||||||
data["manga_id"] = manga_id
|
data["manga_id"] = manga_id
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def images(self, page):
|
def images(self, page):
|
||||||
images_str = text.extr(page, 'var chapImages = "', '"')
|
images_str = text.extr(page, 'var chapImages = "', '"')
|
||||||
if not images_str:
|
if not images_str:
|
||||||
return []
|
return ()
|
||||||
return [
|
return [
|
||||||
(url, None)
|
(url, None)
|
||||||
for url in (u.strip() for u in images_str.split(","))
|
for url in (u.strip() for u in images_str.split(","))
|
||||||
@@ -110,16 +101,12 @@ class KaliscanMangaExtractor(KaliscanBase, MangaExtractor):
|
|||||||
pattern = BASE_PATTERN + r"(/manga/([\w-]+))/?$"
|
pattern = BASE_PATTERN + r"(/manga/([\w-]+))/?$"
|
||||||
example = "https://kaliscan.me/manga/ID-MANGA"
|
example = "https://kaliscan.me/manga/ID-MANGA"
|
||||||
|
|
||||||
def __init__(self, match):
|
|
||||||
MangaExtractor.__init__(self, match)
|
|
||||||
self.manga_slug = self.groups[1]
|
|
||||||
|
|
||||||
def chapters(self, page):
|
def chapters(self, page):
|
||||||
data = self.manga_data(self.manga_slug, page)
|
data = self.manga_data(self.groups[1], page)
|
||||||
|
|
||||||
chapter_list = text.extr(page, 'id="chapter-list">', '</ul>')
|
chapter_list = text.extr(page, 'id="chapter-list">', '</ul>')
|
||||||
if not chapter_list:
|
if not chapter_list:
|
||||||
return []
|
return ()
|
||||||
|
|
||||||
results = []
|
results = []
|
||||||
for li in text.extract_iter(chapter_list, "<li", "</li>"):
|
for li in text.extract_iter(chapter_list, "<li", "</li>"):
|
||||||
|
|||||||
@@ -113,6 +113,7 @@ CATEGORY_MAP = {
|
|||||||
"itchio" : "itch.io",
|
"itchio" : "itch.io",
|
||||||
"jpgfish" : "JPG Fish",
|
"jpgfish" : "JPG Fish",
|
||||||
"kabeuchi" : "かべうち",
|
"kabeuchi" : "かべうち",
|
||||||
|
"kaliscan" : "KaliScan",
|
||||||
"mangafire" : "MangaFire",
|
"mangafire" : "MangaFire",
|
||||||
"mangareader" : "MangaReader",
|
"mangareader" : "MangaReader",
|
||||||
"mangataro" : "MangaTaro",
|
"mangataro" : "MangaTaro",
|
||||||
|
|||||||
Reference in New Issue
Block a user