Fix CloneManga modules.

This commit is contained in:
Tobias Gruetzmacher 2017-02-13 23:41:45 +01:00
parent ebbb27d05d
commit abb72a3a24

View file

@ -1,61 +1,46 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs # Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs
# Copyright (C) 2012-2014 Bastian Kleineidam # Copyright (C) 2012-2014 Bastian Kleineidam
# Copyright (C) 2015-2016 Tobias Gruetzmacher # Copyright (C) 2015-2017 Tobias Gruetzmacher
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
from re import compile from ..helpers import indirectStarter, xpath_class
from ..scraper import _ParserScraper
from ..scraper import _BasicScraper from ..util import getQueryParams
from ..util import tagre, getQueryParams
class CloneManga(_BasicScraper): class CloneManga(_ParserScraper):
_linkTag = tagre("a", "href", r'([^"]+)') baseUrl = 'http://manga.clone-army.org'
prevSearch = compile(_linkTag + tagre("img", "src", r"previous\.gif")) imageSearch = '//div[%s]//img' % xpath_class('subsectionContainer')
nextSearch = compile(_linkTag + tagre("img", "src", r"next\.gif")) prevSearch = '//a[span[text()="<<"]]'
latestSearch = compile(_linkTag + tagre("img", "src", r"last\.gif")) latestSearch = '//a[span[text()=">|"]]'
starter = indirectStarter
help = 'Index format: n' help = 'Index format: n'
def __init__(self, name, shortName, imageFolder=None, lastStrip=None): def __init__(self, name, shortName, endOfLife=False):
super(CloneManga, self).__init__('CloneManga/' + name) super(CloneManga, self).__init__('CloneManga/' + name)
self.stripUrl = '%s/viewer.php?page=%%s&lang=&series=%s&HUDoff=' % (
_url = 'http://manga.clone-army.org' self.baseUrl, shortName)
self.url = '%s/%s.php' % (_url, shortName) self.url = self.stripUrl % '1'
if imageFolder is None: self.endOfLife = endOfLife
imageFolder = shortName
self.stripUrl = self.url + '?page=%s'
self.imageSearch = compile(tagre("img", "src", r'((?:%s/)?%s/[^"]+)' % (_url, imageFolder), after="center"))
if lastStrip is None:
self.starter = self._starter
else:
self.url = self.stripUrl % lastStrip
def namer(self, image_url, page_url): def namer(self, image_url, page_url):
return '%03d' % int(getQueryParams(page_url)['page'][0]) return '%03d' % int(getQueryParams(page_url)['page'][0])
def _starter(self):
# first, try hopping to previous and next comic
data = self.getPage(self.url)
try:
url = self.fetchUrl(self.url, data, self.prevSearch)
except ValueError:
# no previous link found, try hopping to last comic
return self.fetchUrl(self.url, data, self.latestSearch)
else:
data = self.getPage(url)
return self.fetchUrl(url, data, self.nextSearch)
@classmethod @classmethod
def getmodules(cls): def getmodules(cls):
return [ return (
cls('AprilAndMay', 'anm', imageFolder='AAM'), cls('ACaptainsWorries', 'captains_worries'),
cls('Kanami', 'kanami'), cls('AHimehornsDailyLife', 'himehorn'),
cls('MomokaCorner', 'momoka'), cls('AprilAndMay', 'anm', endOfLife=True),
cls('NanasEverydayLife', 'nana', lastStrip='78'), cls('DollAndMaker', 'maria_doll', endOfLife=True),
cls('PaperEleven', 'pxi', imageFolder='papereleven', lastStrip='311'), cls('Kanami', 'kanami', endOfLife=True),
cls('MomokaCorner', 'momoka', endOfLife=True),
cls('MyShutInVampirePrincess', 'snax'),
cls('NanasEverydayLife', 'nana', endOfLife=True),
cls('NNN', 'nnn', endOfLife=True),
cls('PaperEleven', 'pxi', endOfLife=True),
cls('PennyTribute', 'penny', endOfLife=True),
cls('Tomoyo42sRoom', 't42r'), cls('Tomoyo42sRoom', 't42r'),
cls('PennyTribute', 'penny'), )
]