2018-02-04 16:27:44 +01:00
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
2022-07-12 23:07:58 +02:00
|
|
|
|
# Copyright 2018-2022 Mike Fährmann
|
2018-02-04 16:27:44 +01: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.
|
|
|
|
|
|
2022-07-12 23:07:58 +02:00
|
|
|
|
"""Extractors for https://komikcast.me/"""
|
2018-02-04 16:27:44 +01:00
|
|
|
|
|
|
|
|
|
from .common import ChapterExtractor, MangaExtractor
|
2019-03-10 15:31:33 +01:00
|
|
|
|
from .. import text
|
2018-02-04 16:27:44 +01:00
|
|
|
|
import re
|
|
|
|
|
|
2022-07-12 23:07:58 +02:00
|
|
|
|
BASE_PATTERN = r"(?:https?://)?(?:www\.)?komikcast\.(?:me|com)"
|
|
|
|
|
|
2018-02-04 16:27:44 +01:00
|
|
|
|
|
|
|
|
|
class KomikcastBase():
|
|
|
|
|
"""Base class for komikcast extractors"""
|
|
|
|
|
category = "komikcast"
|
2022-07-12 23:07:58 +02:00
|
|
|
|
root = "https://komikcast.me"
|
2018-02-04 16:27:44 +01:00
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def parse_chapter_string(chapter_string, data=None):
|
|
|
|
|
"""Parse 'chapter_string' value and add its info to 'data'"""
|
|
|
|
|
if not data:
|
|
|
|
|
data = {}
|
|
|
|
|
|
|
|
|
|
match = re.match(
|
|
|
|
|
r"(?:(.*) Chapter )?0*(\d+)([^ ]*)(?: (?:- )?(.+))?",
|
|
|
|
|
text.unescape(chapter_string),
|
|
|
|
|
)
|
|
|
|
|
manga, chapter, data["chapter_minor"], title = match.groups()
|
|
|
|
|
|
|
|
|
|
if manga:
|
|
|
|
|
data["manga"] = manga.partition(" Chapter ")[0]
|
2021-03-28 21:12:41 +02:00
|
|
|
|
if title and not title.lower().startswith("bahasa indonesia"):
|
2018-02-04 16:27:44 +01:00
|
|
|
|
data["title"] = title.strip()
|
|
|
|
|
else:
|
|
|
|
|
data["title"] = ""
|
2018-04-20 14:53:21 +02:00
|
|
|
|
data["chapter"] = text.parse_int(chapter)
|
2018-02-04 16:27:44 +01:00
|
|
|
|
data["lang"] = "id"
|
|
|
|
|
data["language"] = "Indonesian"
|
|
|
|
|
|
|
|
|
|
return data
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class KomikcastChapterExtractor(KomikcastBase, ChapterExtractor):
|
2022-07-12 23:07:58 +02:00
|
|
|
|
"""Extractor for manga-chapters from komikcast.me"""
|
|
|
|
|
pattern = BASE_PATTERN + r"(/chapter/[^/?#]+/)"
|
2019-02-08 13:45:40 +01:00
|
|
|
|
test = (
|
2022-07-12 23:07:58 +02:00
|
|
|
|
(("https://komikcast.me/chapter"
|
|
|
|
|
"/apotheosis-chapter-02-2-bahasa-indonesia/"), {
|
|
|
|
|
"url": "74eca5c9b27b896816497f9b2d847f2a1fcfc209",
|
2019-02-19 15:12:40 +01:00
|
|
|
|
"keyword": "f3938e1aff9ad1f302f52447e9781b21f6da26d4",
|
2018-02-04 16:27:44 +01:00
|
|
|
|
}),
|
2022-07-12 23:07:58 +02:00
|
|
|
|
(("https://komikcast.me/chapter"
|
|
|
|
|
"/soul-land-ii-chapter-300-1-bahasa-indonesia/"), {
|
|
|
|
|
"url": "243a5250e210b40d17217e83b7547cefea5638bd",
|
|
|
|
|
"keyword": "cb646cfed3d45105bd645ab38b2e9f7d8c436436",
|
2019-04-26 15:14:10 +02:00
|
|
|
|
}),
|
2019-02-08 13:45:40 +01:00
|
|
|
|
)
|
2018-02-04 16:27:44 +01:00
|
|
|
|
|
2019-02-11 18:38:47 +01:00
|
|
|
|
def metadata(self, page):
|
2021-04-15 17:04:53 +02:00
|
|
|
|
info = text.extract(page, "<title>", " – Komikcast<")[0]
|
2018-02-04 16:27:44 +01:00
|
|
|
|
return self.parse_chapter_string(info)
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
2019-02-11 18:38:47 +01:00
|
|
|
|
def images(page):
|
2018-02-04 16:27:44 +01:00
|
|
|
|
readerarea = text.extract(
|
2021-03-28 21:12:41 +02:00
|
|
|
|
page, '<div class="main-reading-area', '</div')[0]
|
2018-02-04 16:27:44 +01:00
|
|
|
|
return [
|
2019-02-19 15:12:40 +01:00
|
|
|
|
(text.unescape(url), None)
|
2019-04-26 15:14:10 +02:00
|
|
|
|
for url in re.findall(r"<img[^>]* src=[\"']([^\"']+)", readerarea)
|
2018-02-04 16:27:44 +01:00
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class KomikcastMangaExtractor(KomikcastBase, MangaExtractor):
|
2022-07-12 23:07:58 +02:00
|
|
|
|
"""Extractor for manga from komikcast.me"""
|
2019-02-13 13:23:36 +01:00
|
|
|
|
chapterclass = KomikcastChapterExtractor
|
2022-07-12 23:07:58 +02:00
|
|
|
|
pattern = BASE_PATTERN + r"(/(?:komik/)?[^/?#]+)/?$"
|
2019-02-08 13:45:40 +01:00
|
|
|
|
test = (
|
2022-07-12 23:07:58 +02:00
|
|
|
|
("https://komikcast.me/komik/090-eko-to-issho/", {
|
|
|
|
|
"url": "08204f0a703ec5272121abcf0632ecacba1e588f",
|
2019-03-22 13:27:40 +01:00
|
|
|
|
"keyword": "837a7e96867344ff59d840771c04c20dc46c0ab1",
|
2018-05-29 10:35:08 +02:00
|
|
|
|
}),
|
2022-07-12 23:07:58 +02:00
|
|
|
|
("https://komikcast.me/tonari-no-kashiwagi-san/"),
|
2019-02-08 13:45:40 +01:00
|
|
|
|
)
|
2018-02-04 16:27:44 +01:00
|
|
|
|
|
|
|
|
|
def chapters(self, page):
|
|
|
|
|
results = []
|
2019-03-22 13:27:40 +01:00
|
|
|
|
data = self.metadata(page)
|
2018-02-04 16:27:44 +01:00
|
|
|
|
|
|
|
|
|
for item in text.extract_iter(
|
2021-03-28 21:12:41 +02:00
|
|
|
|
page, '<a class="chapter-link-item" href="', '</a'):
|
2018-10-02 20:38:42 +02:00
|
|
|
|
url, _, chapter_string = item.rpartition('">Chapter ')
|
2018-02-04 16:27:44 +01:00
|
|
|
|
self.parse_chapter_string(chapter_string, data)
|
|
|
|
|
results.append((url, data.copy()))
|
|
|
|
|
return results
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
2019-03-22 13:27:40 +01:00
|
|
|
|
def metadata(page):
|
2018-02-04 16:27:44 +01:00
|
|
|
|
"""Return a dict with general metadata"""
|
2021-04-15 17:04:53 +02:00
|
|
|
|
manga , pos = text.extract(page, "<title>" , " – Komikcast<")
|
2021-03-28 21:12:41 +02:00
|
|
|
|
genres, pos = text.extract(
|
|
|
|
|
page, 'class="komik_info-content-genre">', "</span>", pos)
|
2019-03-22 13:27:40 +01:00
|
|
|
|
author, pos = text.extract(page, ">Author:", "</span>", pos)
|
|
|
|
|
mtype , pos = text.extract(page, ">Type:" , "</span>", pos)
|
2018-02-04 16:27:44 +01:00
|
|
|
|
|
|
|
|
|
return {
|
2021-03-28 21:12:41 +02:00
|
|
|
|
"manga": text.unescape(manga),
|
|
|
|
|
"genres": text.split_html(genres),
|
2019-03-22 13:27:40 +01:00
|
|
|
|
"author": text.remove_html(author),
|
2018-02-04 16:27:44 +01:00
|
|
|
|
"type": text.remove_html(mtype),
|
|
|
|
|
}
|