1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-26 12:42:29 +01:00
gallery-dl/gallery_dl/extractor/senmanga.py

46 lines
1.4 KiB
Python
Raw Normal View History

2016-08-02 17:42:22 +02:00
# -*- coding: utf-8 -*-
2023-06-08 22:18:43 +02:00
# Copyright 2016-2023 Mike Fährmann
2016-08-02 17:42:22 +02: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-06-08 22:18:43 +02:00
"""Extractors for https://raw.senmanga.com/"""
2016-08-02 17:42:22 +02:00
2023-06-08 22:18:43 +02:00
from .common import ChapterExtractor
from .. import text
2016-08-02 17:42:22 +02:00
2017-02-01 00:53:19 +01:00
2023-06-08 22:18:43 +02:00
class SenmangaChapterExtractor(ChapterExtractor):
"""Extractor for manga chapters from raw.senmanga.com"""
2016-08-02 17:42:22 +02:00
category = "senmanga"
2023-06-08 22:18:43 +02:00
root = "https://raw.senmanga.com"
pattern = r"(?:https?://)?raw\.senmanga\.com(/[^/?#]+/[^/?#]+)"
example = "https://raw.senmanga.com/MANGA/CHAPTER"
2016-08-02 17:42:22 +02:00
def _init(self):
2023-06-08 22:18:43 +02:00
self.session.headers["Referer"] = self.gallery_url
2016-08-02 17:42:22 +02:00
2023-06-08 22:18:43 +02:00
# select "All pages" viewer
self.cookies.set("viewer", "1", domain="raw.senmanga.com")
2016-08-02 17:42:22 +02:00
2023-06-08 22:18:43 +02:00
def metadata(self, page):
title = text.extr(page, "<title>", "</title>")
manga, _, chapter = title.partition(" - Chapter ")
2016-08-02 17:42:22 +02:00
return {
2023-06-08 22:18:43 +02:00
"manga" : text.unescape(manga).replace("-", " "),
"chapter" : chapter.partition(" - Page ")[0],
"chapter_minor": "",
"lang" : "ja",
"language" : "Japanese",
2016-08-02 17:42:22 +02:00
}
2023-06-08 22:18:43 +02:00
def images(self, page):
return [
(text.ensure_http_scheme(url), None)
2023-06-08 22:18:43 +02:00
for url in text.extract_iter(
page, '<img class="picture" src="', '"')
]