Fix SnafuComics.

This commit is contained in:
Tobias Gruetzmacher 2016-04-14 23:52:35 +02:00
parent 7626b1e100
commit 031a523846

View file

@ -1,39 +1,134 @@
# -*- coding: iso-8859-1 -*- # -*- coding: utf-8 -*-
# Copyright (C) 2004-2005 Tristan Seligmann and Jonathan Jacobs # Copyright (C) 2004-2005 Tristan Seligmann and Jonathan Jacobs
# Copyright (C) 2012-2014 Bastian Kleineidam # Copyright (C) 2012-2014 Bastian Kleineidam
# Copyright (C) 2015-2016 Tobias Gruetzmacher
from re import compile from __future__ import absolute_import, division, print_function
from ..scraper import make_scraper
_imageSearch = compile(r'<img src=http://\w+\.snafu-comics\.com/(comics/\d{6}_\w*\.\w{3,4})') from ..scraper import _ParserScraper
_prevSearch = compile(r'<a href="(\?comic_id=\d+)">Previous</a>') from ..helpers import indirectStarter
def add(name, host): class _Snafu(_ParserScraper):
baseUrl = 'http://%s.snafu-comics.com/' % host # Next and Previous are swapped...
classname = 'SnafuComics_%s' % name prevSearch = '//a[@class="next"]'
imageSearch = '//div[@class="comicpage"]/img'
latestSearch = '//div[@id="feed"]/a'
starter = indirectStarter
globals()[classname] = make_scraper(classname, @property
name='SnafuComics/%s' % name, def name(self):
url = baseUrl, return 'SnafuComics/' + super(_Snafu, self).name
stripUrl = baseUrl + '?comic_id=%s',
imageSearch = _imageSearch, @classmethod
prevSearch = _prevSearch, def namer(cls, image_url, page_url):
help = 'Index format: n (unpadded)', year, month, name = image_url.rsplit('/', 3)[1:]
) return "%04s_%02s_%s" % (year, month, name)
@property
def url(self):
return 'http://snafu-comics.com/swmseries/' + self.path
add('KOF', 'kof') class Braindead(_Snafu):
add('PowerPuffGirls', 'ppg') path = 'braindead'
add('Tin', 'tin')
add('TW', 'tw')
add('Sugar', 'sugar') class Bunnywith(_Snafu):
add('SF', 'sf') path = 'bunnywith'
add('Titan', 'titan')
add('EA', 'ea')
add('Zim', 'zim') class DeliverUsEvil(_Snafu):
add('Soul', 'soul') path = 'deliverusevil'
add('FT', 'ft')
add('Bunnywith', 'bunnywith')
add('Braindead', 'braindead') class DigitalPurgatory(_Snafu):
add('GrimTalesFromDownBelow', 'grim') path = 'digital-purgatory'
class EA(_Snafu):
path = 'ea'
class FT(_Snafu):
path = 'ft'
class GrimTalesFromDownBelow(_Snafu):
path = 'grimtales'
class KOF(_Snafu):
path = 'kof'
class MyPanda(_Snafu):
path = 'mypanda'
class NarutoHeroesPath(_Snafu):
path = 'naruto'
class NewSuperMarioAdventures(_Snafu):
path = 'nsma'
class PowerPuffGirls(_Snafu):
path = 'powerpuffgirls'
class PSG2(_Snafu):
path = 'psg2'
class SatansExcrement(_Snafu):
path = 'satansexcrement'
class SF(_Snafu):
path = 'sf'
class SkullBoy(_Snafu):
path = 'skullboy'
class Snafu(_Snafu):
path = 'snafu'
class Soul(_Snafu):
path = 'soul'
class Sugar(_Snafu):
path = 'sugarbits'
class SureToBeBanD(_Snafu):
path = 'stbb'
class TheLeague(_Snafu):
path = 'league'
class Tin(_Snafu):
path = 'tin'
class Titan(_Snafu):
path = 'titan'
class TrunksAndSoto(_Snafu):
path = 'trunks-and-soto'
class TW(_Snafu):
path = 'tw'
class Zim(_Snafu):
path = 'zim'