~dosage-dev/dosage/test-mode

« back to all changes in this revision

Viewing changes to dosage/plugins/z.py

  • Committer: ns
  • Date: 2009-12-01 06:47:33 UTC
  • Revision ID: ns@ww1aviationlinks.cjb.net-20091201064733-wqy9o7lggwhd36o3
repairĀ forĀ Lint

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
import urllib
2
 
from re import compile
3
 
 
4
 
from dosage.helpers import BasicScraper, indirectStarter
5
 
 
6
 
 
7
 
class Zapiro(BasicScraper):
8
 
    baseUrl = 'http://www.mg.co.za/zapiro/default.aspx'
9
 
    imageUrl = 'http://www.mg.co.za/zapiro/imagePage.aspx?YearId=%s|MonthId=%s|DayId=%s'
10
 
    imageSearch = compile(r'<img src=(http://www.mg.co.za/ContentImages/\d+/\d{2}-...\d{2}x\.gif) border=0 />')
11
 
    prevSearch = compile(r'href="((?:/zapiro/)?[iI]magePage.aspx\?YearId=\d{4}\|MonthId=\d{1,2}\|DayId=\d{1,2})"')
12
 
    latestSearch = compile(r'<a href="(imagePage.aspx\?YearId=\d{4}\|MonthId=\d{1,2}\|DayId=\d{1,2})">')
13
 
    help = 'Index format: yyyy-mm-dd'
14
 
 
15
 
    starter = indirectStarter('http://www.mg.co.za/zapiro/default.aspx', compile(r'<a href="(imagePage.aspx\?YearId=\d{4}\|MonthId=\d{1,2}\|DayId=\d{1,2})">'))
16
 
 
17
 
    def setStrip(self, index):
18
 
        self.currentUrl = self.imageUrl % tuple(map(int, index.split('-')))
19
 
 
20
 
    def namer(cls, imageUrl, pageUrl):
21
 
        values = [a.split('=') for a in urllib.splitquery(pageUrl)[-1].split('|')]
22
 
        d = dict([(name, int(value)) for name, value in values])
23
 
        return 'zapiro-%(YearId)02d%(MonthId)02d%(DayId)02d' % d
24
 
 
25
 
 
26
 
class ZombieHunters(BasicScraper):
27
 
    latestUrl = 'http://www.thezombiehunters.com/'
28
 
    imageUrl = 'http://www.thezombiehunters.com/index.php?strip_id=%s'
29
 
    imageSearch = compile(r'"(.+?strips/.+?)"')
30
 
    prevSearch = compile(r'"(.+?)">\r\n.+?Pre')
31
 
    help = 'Index format: n(unpadded)'