11# -*- coding: utf-8 -*-
22
3- # Copyright 2025 Mike Fährmann
4- #
53# This program is free software; you can redistribute it and/or modify
64# it under the terms of the GNU General Public License version 2 as
75# published by the Free Software Foundation.
@@ -22,17 +20,17 @@ class KaliscanBase():
2220
2321 @memcache (keyarg = 1 )
2422 def manga_data (self , manga_slug , page = None ):
25- if not page :
26- url = "{ }/manga/{}" . format ( self . root , manga_slug )
23+ if page is None :
24+ url = f" { self . root } /manga/{ manga_slug } "
2725 page = self .request (url ).text
2826 extr = text .extract_from (page )
2927
28+ manga_id = text .parse_int (extr ("bookId =" , ";" ))
3029 title = text .unescape (extr ("<h1>" , "<" ))
31- alt_titles = extr ("<h2>" , "<" )
32- alt_titles = (
33- [t .strip () for t in alt_titles .split ("," )]
34- if alt_titles else []
35- )
30+ if alt_titles := extr ("<h2>" , "<" ):
31+ alt_titles = [t .strip () for t in alt_titles .split ("," )]
32+ else :
33+ alt_titles = ()
3634
3735 author = text .remove_html (extr (
3836 "Authors :</strong>" , "</p>" ))
@@ -41,13 +39,10 @@ def manga_data(self, manga_slug, page=None):
4139 genres = [g .strip (" ," ) for g in text .split_html (extr (
4240 "Genres :</strong>" , "</p>" ))]
4341
44- desc_html = extr ('class="content"' , '<div class="readmore"' )
45- description = (
46- text .remove_html (desc_html .partition (">" )[2 ]).strip ()
47- if desc_html else ""
48- )
49-
50- manga_id = text .parse_int (text .extr (page , "bookId =" , ";" ))
42+ if descr := extr ('class="content"' , '<div class="readmore"' ):
43+ descr = text .remove_html (descr [descr .find (">" )+ 1 :]).strip ()
44+ else :
45+ descr = ""
5146
5247 return {
5348 "manga" : title ,
@@ -57,7 +52,7 @@ def manga_data(self, manga_slug, page=None):
5752 "author" : author ,
5853 "status" : status ,
5954 "genres" : genres ,
60- "description" : description ,
55+ "description" : descr ,
6156 "lang" : "en" ,
6257 "language" : "English" ,
6358 }
@@ -68,10 +63,6 @@ class KaliscanChapterExtractor(KaliscanBase, ChapterExtractor):
6863 pattern = BASE_PATTERN + r"(/manga/([\w-]+)/chapter-([\d.]+))"
6964 example = "https://kaliscan.me/manga/ID-MANGA/chapter-1"
7065
71- def __init__ (self , match ):
72- ChapterExtractor .__init__ (self , match )
73- self .manga_slug = self .groups [1 ]
74-
7566 def metadata (self , page ):
7667 extr = text .extract_from (page )
7768
@@ -87,16 +78,16 @@ def metadata(self, page):
8778 "chapter" : text .parse_int (chapter ),
8879 "chapter_minor" : sep + minor ,
8980 "chapter_id" : chapter_id ,
81+ ** self .manga_data (self .groups [1 ]),
9082 }
91- data .update (self .manga_data (self .manga_slug ))
92- if manga_id :
83+ if manga_id and not data ["manga_id" ]:
9384 data ["manga_id" ] = manga_id
9485 return data
9586
9687 def images (self , page ):
9788 images_str = text .extr (page , 'var chapImages = "' , '"' )
9889 if not images_str :
99- return []
90+ return ()
10091 return [
10192 (url , None )
10293 for url in (u .strip () for u in images_str .split ("," ))
@@ -110,16 +101,12 @@ class KaliscanMangaExtractor(KaliscanBase, MangaExtractor):
110101 pattern = BASE_PATTERN + r"(/manga/([\w-]+))/?$"
111102 example = "https://kaliscan.me/manga/ID-MANGA"
112103
113- def __init__ (self , match ):
114- MangaExtractor .__init__ (self , match )
115- self .manga_slug = self .groups [1 ]
116-
117104 def chapters (self , page ):
118- data = self .manga_data (self .manga_slug , page )
105+ data = self .manga_data (self .groups [ 1 ] , page )
119106
120107 chapter_list = text .extr (page , 'id="chapter-list">' , '</ul>' )
121108 if not chapter_list :
122- return []
109+ return ()
123110
124111 results = []
125112 for li in text .extract_iter (chapter_list , "<li" , "</li>" ):
0 commit comments