2016-04-13 18:01:51 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2012-12-04 06:02:40 +00:00
|
|
|
# Copyright (C) 2004-2005 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
|
|
|
|
2012-12-04 06:02:40 +00:00
|
|
|
from ..scraper import make_scraper
|
2014-07-23 18:53:59 +00:00
|
|
|
from ..util import tagre, getQueryParams
|
2012-12-04 06:02:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
_linkTag = tagre("a", "href", r'([^"]+)')
|
|
|
|
_prevSearch = compile(_linkTag + tagre("img", "src", r"previous\.gif"))
|
|
|
|
_nextSearch = compile(_linkTag + tagre("img", "src", r"next\.gif"))
|
|
|
|
_lastSearch = compile(_linkTag + tagre("img", "src", r"last\.gif"))
|
|
|
|
|
2016-04-13 18:01:51 +00:00
|
|
|
|
2012-12-04 06:02:40 +00:00
|
|
|
def add(name, shortName, imageFolder=None, lastStrip=None):
|
|
|
|
classname = 'CloneManga_%s' % name
|
|
|
|
_url = 'http://manga.clone-army.org'
|
|
|
|
baseUrl = '%s/%s.php' % (_url, shortName)
|
|
|
|
if imageFolder is None:
|
|
|
|
imageFolder = shortName
|
|
|
|
|
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-04-13 18:01:51 +00:00
|
|
|
data = self.getPage(baseUrl)
|
2013-02-11 18:43:46 +00:00
|
|
|
try:
|
2016-04-13 18:01:51 +00:00
|
|
|
url = self.fetchUrl(baseUrl, data, _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-04-13 18:01:51 +00:00
|
|
|
return self.fetchUrl(baseUrl, data, _lastSearch)
|
2013-02-11 18:43:46 +00:00
|
|
|
else:
|
2016-04-13 18:01:51 +00:00
|
|
|
data = self.getPage(url)
|
|
|
|
return self.fetchUrl(url, data, _nextSearch)
|
2012-12-04 06:02:40 +00:00
|
|
|
|
|
|
|
attrs = dict(
|
|
|
|
name='CloneManga/' + name,
|
2016-04-13 18:01:51 +00:00
|
|
|
stripUrl=baseUrl + '?page=%s',
|
2012-12-04 06:02:40 +00:00
|
|
|
imageSearch=compile(tagre("img", "src", r'((?:%s/)?%s/[^"]+)' % (_url, imageFolder), after="center")),
|
|
|
|
prevSearch=_prevSearch,
|
|
|
|
help='Index format: n',
|
|
|
|
namer=namer,
|
2013-02-05 18:51:46 +00:00
|
|
|
url=baseUrl,
|
2012-12-04 06:02:40 +00:00
|
|
|
)
|
|
|
|
if lastStrip is None:
|
|
|
|
attrs['starter'] = _starter
|
|
|
|
else:
|
2013-02-04 20:00:26 +00:00
|
|
|
attrs['url'] = attrs['stripUrl'] % lastStrip
|
2012-12-04 06:02:40 +00:00
|
|
|
globals()[classname] = make_scraper(classname, **attrs)
|
|
|
|
|
|
|
|
|
|
|
|
add('AprilAndMay', 'anm', imageFolder='AAM')
|
|
|
|
add('Kanami', 'kanami')
|
|
|
|
add('MomokaCorner', 'momoka')
|
|
|
|
add('NanasEverydayLife', 'nana', lastStrip='78')
|
|
|
|
add('PaperEleven', 'pxi', imageFolder='papereleven', lastStrip='311')
|
|
|
|
add('Tomoyo42sRoom', 't42r')
|
|
|
|
add('PennyTribute', 'penny')
|