dosage/dosagelib/plugins/smackjeeves.py

42 lines
1.3 KiB
Python
Raw Normal View History

2012-11-21 20:57:26 +00:00
# -*- coding: iso-8859-1 -*-
# Copyright (C) 2004-2005 Tristan Seligmann and Jonathan Jacobs
# Copyright (C) 2012 Bastian Kleineidam
from re import compile
2012-11-26 06:13:32 +00:00
from ..scraper import make_scraper
2012-11-21 20:57:26 +00:00
from ..helpers import bounceStarter
from ..util import tagre
2012-12-02 17:35:06 +00:00
_imageSearch = compile(tagre("img", "src", r'(http://(?:www|img2)\.smackjeeves\.com/images/uploaded/comics/[^"]+)'))
_linkSearch = tagre("a", "href", r'([^"]*/comics/\d+/[^"]*)')
2012-12-05 20:52:52 +00:00
_prevSearch = compile(_linkSearch + '(?:<img[^>]*alt="< Previous"|&lt; Back|. previous)')
_nextSearch = compile(_linkSearch + '(?:<img[^>]*alt="Next >"|Next &gt;|next )')
2012-11-21 20:57:26 +00:00
2012-11-26 06:13:32 +00:00
def add(name):
classname = 'SmackJeeves/' + name
2012-11-21 20:57:26 +00:00
# XXX mature content can be viewed directly with:
# http://www.smackjeeves.com/mature.php?ref=<percent-encoded-url>
2012-11-26 06:13:32 +00:00
baseUrl = 'http://%s.smackjeeves.com/comics/' % name
2012-11-21 20:57:26 +00:00
2012-11-26 06:13:32 +00:00
@classmethod
def namer(cls, imageUrl, pageUrl):
return pageUrl.split('/')[-2]
2012-11-21 20:57:26 +00:00
2012-11-26 06:13:32 +00:00
globals()[classname] = make_scraper(classname,
2012-12-02 17:35:06 +00:00
starter=bounceStarter(baseUrl, _nextSearch),
stripUrl = baseUrl + '%s/',
imageSearch = _imageSearch,
prevSearch = _prevSearch,
2012-11-26 06:13:32 +00:00
help = 'Index format: nnnn (some increasing number)',
namer = namer,
)
2012-11-21 20:57:26 +00:00
2012-11-26 06:13:32 +00:00
add('20galaxies')
add('axe13')
add('beartholomew')
add('bliss')
add('durian')
add('heard')
add('mpmcomic')
add('nlmo-project')