1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-25 20:22:36 +01:00
gallery-dl/gallery_dl/extractor/fallenangels.py

85 lines
2.9 KiB
Python
Raw Normal View History

2017-02-06 20:05:58 +01:00
# -*- coding: utf-8 -*-
# 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.
"""Extractors for https://www.fascans.com/"""
2017-02-06 20:05:58 +01:00
from .common import ChapterExtractor, MangaExtractor
from .. import text, util
2017-02-06 20:05:58 +01:00
class FallenangelsChapterExtractor(ChapterExtractor):
"""Extractor for manga chapters from fascans.com"""
2017-02-06 20:05:58 +01:00
category = "fallenangels"
pattern = (r"(?:https?://)?(manga|truyen)\.fascans\.com"
r"/manga/([^/?#]+)/([^/?#]+)")
example = "https://manga.fascans.com/manga/NAME/CHAPTER/"
def __init__(self, match):
self.version, self.manga, self.chapter = match.groups()
url = "https://{}.fascans.com/manga/{}/{}/1".format(
self.version, self.manga, self.chapter)
ChapterExtractor.__init__(self, match, url)
def metadata(self, page):
extr = text.extract_from(page)
lang = "vi" if self.version == "truyen" else "en"
chapter, sep, minor = self.chapter.partition(".")
return {
"manga" : extr('name="description" content="', ' Chapter '),
"title" : extr(': ', ' - Page 1'),
"chapter" : chapter,
"chapter_minor": sep + minor,
"lang" : lang,
"language": util.code_to_language(lang),
}
@staticmethod
def images(page):
return [
(img["page_image"], None)
for img in util.json_loads(
text.extr(page, "var pages = ", ";")
)
]
2017-05-21 10:36:29 +02:00
class FallenangelsMangaExtractor(MangaExtractor):
"""Extractor for manga from fascans.com"""
chapterclass = FallenangelsChapterExtractor
2017-05-21 10:36:29 +02:00
category = "fallenangels"
pattern = r"(?:https?://)?((manga|truyen)\.fascans\.com/manga/[^/]+)/?$"
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):
url = "https://" + match.group(1)
2017-09-15 20:51:40 +02:00
self.lang = "vi" if match.group(2) == "truyen" else "en"
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):
extr = text.extract_from(page)
2017-09-15 20:51:40 +02:00
results = []
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
manga, _, chapter = cha.rpartition(" ")
chapter, dot, minor = chapter.partition(".")
2017-09-15 20:51:40 +02:00
results.append((url, {
"manga" : manga,
"title" : text.unescape(title),
"volume" : text.parse_int(vol),
"chapter" : text.parse_int(chapter),
"chapter_minor": dot + minor,
"lang" : self.lang,
2018-10-20 18:31:26 +02:00
"language": language,
2017-09-15 20:51:40 +02:00
}))
return results