Debian Codegraph @

gallery_dl/extractor/senmanga.py

raw
1 # -*- coding: utf-8 -*-
2
3 # Copyright 2016-2023 Mike Fährmann
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License version 2 as
7 # published by the Free Software Foundation.
8
9 """Extractors for https://raw.senmanga.com/"""
10
11 from .common import ChapterExtractor
12 from .. import text
13
14
15 class SenmangaChapterExtractor(ChapterExtractor):
16 """Extractor for manga chapters from raw.senmanga.com"""
17 category = "senmanga"
18 root = "https://raw.senmanga.com"
19 pattern = r"(?:https?://)?raw\.senmanga\.com(/[^/?#]+/[^/?#]+)"
20 example = "https://raw.senmanga.com/MANGA/CHAPTER"
21
22 def _init(self):
23 self.session.headers["Referer"] = self.page_url
24
25 # select "All pages" viewer
26 self.cookies.set("viewer", "1", domain="raw.senmanga.com")
27
28 def metadata(self, page):
29 title = text.extr(page, "<title>", "</title>")
30 manga, _, chapter = title.partition(" - Chapter ")
31
32 return {
33 "manga" : text.unescape(manga).replace("-", " "),
34 "chapter" : chapter.partition(" - Page ")[0],
35 "chapter_minor": "",
36 "lang" : "ja",
37 "language" : "Japanese",
38 }
39
40 def images(self, page):
41 return [
42 (text.ensure_http_scheme(url), None)
43 for url in text.extract_iter(
44 page, '<img class="picture" src="', '"')
45 ]