2017-02-06 20:05:58 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2023-09-11 16:30:55 +02:00
|
|
|
# Copyright 2017-2023 Mike Fährmann
|
2017-02-06 20:05:58 +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.
|
|
|
|
|
2023-02-07 23:14:53 +01:00
|
|
|
"""Extractors for https://www.fascans.com/"""
|
2017-02-06 20:05:58 +01:00
|
|
|
|
2018-02-03 23:14:32 +01:00
|
|
|
from .common import ChapterExtractor, MangaExtractor
|
2017-05-18 15:22:25 +02:00
|
|
|
from .. import text, util
|
2017-02-06 20:05:58 +01:00
|
|
|
|
|
|
|
|
2018-02-03 23:14:32 +01:00
|
|
|
class FallenangelsChapterExtractor(ChapterExtractor):
|
2023-09-11 16:30:55 +02:00
|
|
|
"""Extractor for manga chapters from fascans.com"""
|
2017-02-06 20:05:58 +01:00
|
|
|
category = "fallenangels"
|
2019-02-08 13:45:40 +01:00
|
|
|
pattern = (r"(?:https?://)?(manga|truyen)\.fascans\.com"
|
2020-10-23 16:56:08 +02:00
|
|
|
r"/manga/([^/?#]+)/([^/?#]+)")
|
2023-09-11 16:30:55 +02:00
|
|
|
example = "https://manga.fascans.com/manga/NAME/CHAPTER/"
|
2017-04-09 11:37:21 +02:00
|
|
|
|
|
|
|
def __init__(self, match):
|
2020-10-23 16:56:08 +02:00
|
|
|
self.version, self.manga, self.chapter = match.groups()
|
2017-05-18 15:22:25 +02:00
|
|
|
url = "https://{}.fascans.com/manga/{}/{}/1".format(
|
|
|
|
self.version, self.manga, self.chapter)
|
2019-02-11 13:31:10 +01:00
|
|
|
ChapterExtractor.__init__(self, match, url)
|
2017-04-09 11:37:21 +02:00
|
|
|
|
2019-02-11 18:38:47 +01:00
|
|
|
def metadata(self, page):
|
2019-04-19 23:02:29 +02:00
|
|
|
extr = text.extract_from(page)
|
2017-05-18 15:22:25 +02:00
|
|
|
lang = "vi" if self.version == "truyen" else "en"
|
2020-10-23 16:56:08 +02:00
|
|
|
chapter, sep, minor = self.chapter.partition(".")
|
2019-04-19 23:02:29 +02:00
|
|
|
return {
|
|
|
|
"manga" : extr('name="description" content="', ' Chapter '),
|
|
|
|
"title" : extr(': ', ' - Page 1'),
|
2020-10-23 16:56:08 +02:00
|
|
|
"chapter" : chapter,
|
|
|
|
"chapter_minor": sep + minor,
|
2019-04-19 23:02:29 +02:00
|
|
|
"lang" : lang,
|
2017-05-18 15:22:25 +02:00
|
|
|
"language": util.code_to_language(lang),
|
2017-04-09 11:37:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@staticmethod
|
2019-02-11 18:38:47 +01:00
|
|
|
def images(page):
|
2018-02-03 23:14:32 +01:00
|
|
|
return [
|
|
|
|
(img["page_image"], None)
|
2023-02-07 23:14:53 +01:00
|
|
|
for img in util.json_loads(
|
2022-11-04 23:39:38 +01:00
|
|
|
text.extr(page, "var pages = ", ";")
|
2018-02-03 23:14:32 +01:00
|
|
|
)
|
|
|
|
]
|
2017-05-21 10:36:29 +02:00
|
|
|
|
|
|
|
|
|
|
|
class FallenangelsMangaExtractor(MangaExtractor):
|
|
|
|
"""Extractor for manga from fascans.com"""
|
2019-02-13 13:23:36 +01:00
|
|
|
chapterclass = FallenangelsChapterExtractor
|
2017-05-21 10:36:29 +02:00
|
|
|
category = "fallenangels"
|
2019-02-08 13:45:40 +01:00
|
|
|
pattern = r"(?:https?://)?((manga|truyen)\.fascans\.com/manga/[^/]+)/?$"
|
2023-09-11 16:30:55 +02:00
|
|
|
example = "https://manga.fascans.com/manga/NAME"
|
2017-05-21 10:36:29 +02:00
|
|
|
|
2017-09-15 20:51:40 +02:00
|
|
|
def __init__(self, match):
|
2019-02-11 18:38:47 +01:00
|
|
|
url = "https://" + match.group(1)
|
2017-09-15 20:51:40 +02:00
|
|
|
self.lang = "vi" if match.group(2) == "truyen" else "en"
|
2019-02-11 18:38:47 +01:00
|
|
|
MangaExtractor.__init__(self, match, url)
|
2017-09-15 20:51:40 +02:00
|
|
|
|
2017-05-21 10:36:29 +02:00
|
|
|
def chapters(self, page):
|
2019-04-19 23:02:29 +02:00
|
|
|
extr = text.extract_from(page)
|
2017-09-15 20:51:40 +02:00
|
|
|
results = []
|
2019-04-19 23:02:29 +02:00
|
|
|
language = util.code_to_language(self.lang)
|
|
|
|
while extr('<li style="', '"'):
|
|
|
|
vol = extr('class="volume-', '"')
|
|
|
|
url = extr('href="', '"')
|
|
|
|
cha = extr('>', '<')
|
|
|
|
title = extr('<em>', '</em>')
|
2017-09-15 20:51:40 +02:00
|
|
|
|
2019-04-19 23:02:29 +02:00
|
|
|
manga, _, chapter = cha.rpartition(" ")
|
2017-09-24 15:59:25 +02:00
|
|
|
chapter, dot, minor = chapter.partition(".")
|
2017-09-15 20:51:40 +02:00
|
|
|
results.append((url, {
|
2019-04-19 23:02:29 +02:00
|
|
|
"manga" : manga,
|
|
|
|
"title" : text.unescape(title),
|
|
|
|
"volume" : text.parse_int(vol),
|
|
|
|
"chapter" : text.parse_int(chapter),
|
2017-09-24 15:59:25 +02:00
|
|
|
"chapter_minor": dot + minor,
|
2019-04-19 23:02:29 +02:00
|
|
|
"lang" : self.lang,
|
2018-10-20 18:31:26 +02:00
|
|
|
"language": language,
|
2017-09-15 20:51:40 +02:00
|
|
|
}))
|
2019-04-19 23:02:29 +02:00
|
|
|
return results
|