# -*- coding: utf-8 -*-
# Copyright 2015-2018 Mike Fährmann
#
# 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.
"""Extract manga-chapters and entire manga from https://www.mangareader.net/"""
from .common import ChapterExtractor, MangaExtractor
from .. import text
class MangareaderBase():
"""Base class for mangareader extractors"""
category = "mangareader"
root = "https://www.mangareader.net"
@staticmethod
def parse_page(page, data):
"""Parse metadata on 'page' and add it to 'data'"""
text.extract_all(page, (
("manga" , '
'), data)
data["count"] = text.parse_int(text.extract(
chapter_page, ' of ', '<')[0]
)
return data
def get_images(self, page):
while True:
next_url, image_url, image_data = self.get_image_metadata(page)
yield image_url, image_data
if not next_url:
return
page = self.request(next_url).text
def get_image_metadata(self, page):
"""Collect next url, image-url and metadata for one manga-page"""
extr = text.extract
width = None
test , pos = extr(page, "document['pu']", '')
if test is None:
return None, None, None
if page.find("document['imgwidth']", pos, pos+200) != -1:
width , pos = extr(page, "document['imgwidth'] = ", ";", pos)
height, pos = extr(page, "document['imgheight'] = ", ";", pos)
_ , pos = extr(page, '
', '')
url, pos = extr(page, ' href="', '"', pos)
if width is None:
width , pos = extr(page, '