[mangastream] adapt to domain-change to readms.net

This commit is contained in:
Mike Fährmann
2017-04-01 21:42:36 +02:00
parent e9b445a0f8
commit 91ad8ac2b3

View File

@@ -1,15 +1,16 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright 2015 Mike Fährmann # Copyright 2015-2017 Mike Fährmann
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation. # published by the Free Software Foundation.
"""Extract manga-chapters from https://www.mangastream.com/""" """Extract manga-chapters from https://mangastream.com/"""
from .common import AsynchronousExtractor, Message from .common import AsynchronousExtractor, Message
from .. import text from .. import text
from urllib.parse import urljoin
class MangastreamChapterExtractor(AsynchronousExtractor): class MangastreamChapterExtractor(AsynchronousExtractor):
@@ -18,26 +19,26 @@ class MangastreamChapterExtractor(AsynchronousExtractor):
subcategory = "chapter" subcategory = "chapter"
directory_fmt = ["{category}", "{manga}", "c{chapter} - {title}"] directory_fmt = ["{category}", "{manga}", "c{chapter} - {title}"]
filename_fmt = "{manga}_c{chapter}_{page:>03}.{extension}" filename_fmt = "{manga}_c{chapter}_{page:>03}.{extension}"
pattern = [(r"(?:https?://)?(?:www\.)?(?:readms|mangastream)\.com/" pattern = [(r"(?:https?://)?(?:www\.)?(?:readms|mangastream)\.(?:com|net)/"
r"r(?:ead)?/([^/]*/([^/]+)/(\d+))")] r"r(?:ead)?/([^/]*/([^/]+)/(\d+))")]
url_base = "https://mangastream.com/r/" root = "https://readms.net/r/"
def __init__(self, match): def __init__(self, match):
AsynchronousExtractor.__init__(self) AsynchronousExtractor.__init__(self)
self.part, self.chapter, self.ch_id = match.groups() self.part, self.chapter, self.ch_id = match.groups()
def items(self): def items(self):
page = self.request(self.url_base + self.part).text page = self.request(self.root + self.part).text
data = self.get_job_metadata(page) data = self.get_job_metadata(page)
next_url = None next_url = None
yield Message.Version, 1 yield Message.Version, 1
yield Message.Directory, data yield Message.Directory, data
for i in range(int(data["count"])): for data["page"] in range(1, int(data["count"])+1):
if next_url: if next_url:
page = self.request(next_url).text page = self.request(next_url).text
next_url, image_url = self.get_page_metadata(page) next_url, image_url = self.get_page_metadata(page)
text.nameext_from_url(image_url, data) text.nameext_from_url(image_url, data)
data["page"] = i+1 image_url = urljoin(self.root, image_url)
yield Message.Url, image_url, data.copy() yield Message.Url, image_url, data.copy()
def get_job_metadata(self, page): def get_job_metadata(self, page):