2015-10-08 20:43:52 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2016-10-24 15:03:54 +02:00
|
|
|
# Copyright 2015, 2016 Mike Fährmann
|
2015-10-08 20:43:52 +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.
|
|
|
|
|
2016-09-12 10:20:57 +02:00
|
|
|
"""Extract manga-chapters from http://powermanga.org/"""
|
2015-10-08 20:43:52 +02:00
|
|
|
|
2016-10-24 15:03:54 +02:00
|
|
|
from .foolslide import FoolslideChapterExtractor
|
|
|
|
from .. import text
|
2017-02-01 00:53:19 +01:00
|
|
|
import re
|
|
|
|
|
2015-10-08 20:43:52 +02:00
|
|
|
|
2016-10-24 15:03:54 +02:00
|
|
|
class PowermangaChapterExtractor(FoolslideChapterExtractor):
|
2016-09-12 10:20:57 +02:00
|
|
|
"""Extractor for manga-chapters from powermanga.org"""
|
2015-11-21 04:32:32 +01:00
|
|
|
category = "powermanga"
|
|
|
|
pattern = [
|
2015-11-02 00:21:17 +01:00
|
|
|
(r"(?:https?://)?read(?:er)?\.powermanga\.org/read/"
|
|
|
|
r"(.+/([a-z]{2})/\d+/\d+)(?:/page)?"),
|
2015-11-28 20:31:37 +01:00
|
|
|
(r"(?:https?://)?(?:www\.)?(p)owermanga\.org/((?:[^-]+-)+[^-]+/?)"),
|
2015-11-21 04:32:32 +01:00
|
|
|
]
|
2016-02-18 15:58:14 +01:00
|
|
|
test = [("https://read.powermanga.org/read/one_piece/en/0/803/page/1", {
|
2015-12-13 04:36:44 +01:00
|
|
|
"url": "e6179c1565068f99180620281f86bdd25be166b4",
|
2016-10-28 00:35:48 +02:00
|
|
|
"keyword": "51cabad8995727334e5ca9773c18d709b3868f02",
|
2015-12-13 04:36:44 +01:00
|
|
|
})]
|
2015-10-08 20:43:52 +02:00
|
|
|
|
|
|
|
def __init__(self, match):
|
2015-11-28 20:31:37 +01:00
|
|
|
if match.group(1) == "p":
|
2017-02-01 00:53:19 +01:00
|
|
|
url = "https://powermanga.org/" + match.group(2)
|
|
|
|
page = self.request(url).text
|
2015-11-28 20:31:37 +01:00
|
|
|
pos = page.index("class='small-button smallblack'>Download</a>")
|
|
|
|
url = text.extract(page, "<a href='", "'", pos)[0]
|
|
|
|
match = re.match(self.pattern[0], url)
|
2015-11-21 04:19:23 +01:00
|
|
|
extra = "er" if "://reader" in match.string else ""
|
2016-10-24 15:03:54 +02:00
|
|
|
url = "https://read" + extra + ".powermanga.org/read/" + match.group(1)
|
|
|
|
FoolslideChapterExtractor.__init__(self, url, match.group(2))
|