dosage/dosagelib/plugins/z.py

84 lines
2.8 KiB
Python
Raw Normal View History

# -*- 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
2017-05-21 22:30:31 +00:00
# Copyright (C) 2015-2017 Tobias Gruetzmacher
from __future__ import absolute_import, division, print_function
2012-11-21 20:57:26 +00:00
from re import compile, escape
from ..scraper import _BasicScraper, _ParserScraper
2012-11-26 06:13:32 +00:00
from ..util import tagre
2017-02-13 21:41:17 +00:00
from ..helpers import bounceStarter, xpath_class
2017-05-21 23:17:05 +00:00
from .common import _WPNavi
2012-06-20 19:58:13 +00:00
class ZapComic(_ParserScraper):
url = 'http://www.zapcomic.com/'
css = True
imageSearch = 'img.comic-item'
prevSearch = 'a.previous-comic-link'
2012-12-07 23:45:18 +00:00
2016-05-16 21:16:29 +00:00
class Zapiro(_ParserScraper):
url = 'http://mg.co.za/zapiro/'
starter = bounceStarter
2017-05-21 22:30:31 +00:00
imageSearch = '//div[@id="cartoon"]/img'
2016-10-31 05:57:47 +00:00
prevSearch = '//a[%s]' % xpath_class('left')
nextSearch = '//a[%s]' % xpath_class('right')
2012-06-20 19:58:13 +00:00
def namer(self, image_url, page_url):
2016-05-16 21:16:29 +00:00
parts = page_url.rsplit('/', 1)
return parts[1]
2012-12-04 06:02:40 +00:00
2012-06-20 19:58:13 +00:00
2017-05-21 23:17:05 +00:00
class ZenPencils(_WPNavi):
url = 'https://zenpencils.com/'
multipleImagesPerStrip = True
firstStripUrl = url + 'comic/1-ralph-waldo-emerson-make-them-cry/'
starter = bounceStarter
prevSearch = '//a[%s]' % xpath_class('navi-prev')
nextSearch = '//a[%s]' % xpath_class('navi-next')
2013-04-09 17:38:47 +00:00
2012-06-20 19:58:13 +00:00
class ZombieHunters(_BasicScraper):
url = 'http://www.thezombiehunters.com/'
stripUrl = url + '?strip_id=%s'
2013-04-10 21:57:09 +00:00
firstStripUrl = stripUrl % '1'
2012-11-26 06:13:32 +00:00
imageSearch = compile(tagre("img", "src", r'(/istrip_files/strips/[^"]+)'))
prevSearch = compile(tagre("a", "href", r'(\?strip_id=\d+)') + tagre("img", "id", "prevcomic"))
2012-06-20 19:58:13 +00:00
help = 'Index format: n(unpadded)'
2013-03-07 22:51:55 +00:00
class Zwarwald(_BasicScraper):
url = "http://www.zwarwald.de/"
rurl = escape(url)
2013-03-07 22:51:55 +00:00
stripUrl = url + 'index.php/page/%s/'
2013-03-08 21:33:05 +00:00
# anything before page 495 seems to be flash
firstStripUrl = stripUrl % '495'
lang = 'de'
2013-04-10 18:14:43 +00:00
imageSearch = (
compile(tagre("img", "src", r'(%simages/\d+/\d+/[^"]+)' % rurl)),
compile(tagre("img", "src", r'(http://wp1163540\.wp190\.webpack\.hosteurope\.de/wordpress/images/\d+/\d+/[^"]+)')),
)
prevSearch = compile(tagre("a", "href", r'(%sindex\.php/page/\d+/)' % rurl) +
tagre("img", "src",
r'http://zwarwald\.de/images/prev\.jpg',
quote="'"))
2013-03-07 22:51:55 +00:00
help = 'Index format: number'
def shouldSkipUrl(self, url, data):
2013-03-08 21:33:05 +00:00
"""Some pages have flash content."""
return url in (
self.stripUrl % "112",
self.stripUrl % "222",
self.stripUrl % "223",
self.stripUrl % "246",
self.stripUrl % "368",
self.stripUrl % '495',
)
def namer(self, image_url, page_url):
prefix, year, month, name = image_url.rsplit('/', 3)
2013-03-08 21:33:05 +00:00
return "%s_%s_%s" % (year, month, name)