2016-04-13 18:01:51 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2016-10-28 22:21:41 +00:00
|
|
|
# Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs
|
2014-01-05 15:50:57 +00:00
|
|
|
# Copyright (C) 2012-2014 Bastian Kleineidam
|
2016-04-13 18:01:51 +00:00
|
|
|
# Copyright (C) 2015-2016 Tobias Gruetzmacher
|
|
|
|
|
|
|
|
from __future__ import absolute_import, division, print_function
|
|
|
|
|
2012-12-04 06:02:40 +00:00
|
|
|
from re import compile
|
2016-04-13 18:01:51 +00:00
|
|
|
|
2016-05-20 23:18:42 +00:00
|
|
|
from ..scraper import _BasicScraper
|
2014-07-23 18:53:59 +00:00
|
|
|
from ..util import tagre, getQueryParams
|
2012-12-04 06:02:40 +00:00
|
|
|
|
|
|
|
|
2016-05-20 23:18:42 +00:00
|
|
|
class CloneManga(_BasicScraper):
|
|
|
|
_linkTag = tagre("a", "href", r'([^"]+)')
|
|
|
|
prevSearch = compile(_linkTag + tagre("img", "src", r"previous\.gif"))
|
|
|
|
nextSearch = compile(_linkTag + tagre("img", "src", r"next\.gif"))
|
|
|
|
latestSearch = compile(_linkTag + tagre("img", "src", r"last\.gif"))
|
|
|
|
help = 'Index format: n'
|
2012-12-04 06:02:40 +00:00
|
|
|
|
2016-05-20 23:18:42 +00:00
|
|
|
def __init__(self, name, shortName, imageFolder=None, lastStrip=None):
|
|
|
|
super(CloneManga, self).__init__('CloneManga/' + name)
|
2016-04-13 18:01:51 +00:00
|
|
|
|
2016-05-20 23:18:42 +00:00
|
|
|
_url = 'http://manga.clone-army.org'
|
|
|
|
self.url = '%s/%s.php' % (_url, shortName)
|
|
|
|
if imageFolder is None:
|
|
|
|
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
|
2012-12-04 06:02:40 +00:00
|
|
|
|
2016-04-21 06:20:49 +00:00
|
|
|
def namer(self, image_url, page_url):
|
|
|
|
return '%03d' % int(getQueryParams(page_url)['page'][0])
|
2012-12-04 06:02:40 +00:00
|
|
|
|
2016-04-13 18:01:51 +00:00
|
|
|
def _starter(self):
|
2012-12-04 06:02:40 +00:00
|
|
|
# first, try hopping to previous and next comic
|
2016-05-20 23:18:42 +00:00
|
|
|
data = self.getPage(self.url)
|
2013-02-11 18:43:46 +00:00
|
|
|
try:
|
2016-05-20 23:18:42 +00:00
|
|
|
url = self.fetchUrl(self.url, data, self.prevSearch)
|
2013-02-11 18:43:46 +00:00
|
|
|
except ValueError:
|
2012-12-04 06:02:40 +00:00
|
|
|
# no previous link found, try hopping to last comic
|
2016-05-20 23:18:42 +00:00
|
|
|
return self.fetchUrl(self.url, data, self.latestSearch)
|
2013-02-11 18:43:46 +00:00
|
|
|
else:
|
2016-04-13 18:01:51 +00:00
|
|
|
data = self.getPage(url)
|
2016-05-20 23:18:42 +00:00
|
|
|
return self.fetchUrl(url, data, self.nextSearch)
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def getmodules(cls):
|
|
|
|
return [
|
|
|
|
cls('AprilAndMay', 'anm', imageFolder='AAM'),
|
|
|
|
cls('Kanami', 'kanami'),
|
|
|
|
cls('MomokaCorner', 'momoka'),
|
|
|
|
cls('NanasEverydayLife', 'nana', lastStrip='78'),
|
|
|
|
cls('PaperEleven', 'pxi', imageFolder='papereleven', lastStrip='311'),
|
|
|
|
cls('Tomoyo42sRoom', 't42r'),
|
|
|
|
cls('PennyTribute', 'penny'),
|
|
|
|
]
|