|
@@ 1361-1387 (lines=27) @@
|
| 1358 |
|
} |
| 1359 |
|
|
| 1360 |
|
|
| 1361 |
|
class ButterSafe(GenericListableComic): |
| 1362 |
|
"""Class to retrieve Butter Safe comics.""" |
| 1363 |
|
name = 'butter' |
| 1364 |
|
long_name = 'ButterSafe' |
| 1365 |
|
url = 'http://buttersafe.com' |
| 1366 |
|
get_url_from_archive_element = get_href |
| 1367 |
|
comic_link_re = re.compile('^%s/([0-9]*)/([0-9]*)/([0-9]*)/.*' % url) |
| 1368 |
|
|
| 1369 |
|
@classmethod |
| 1370 |
|
def get_archive_elements(cls): |
| 1371 |
|
archive_url = urljoin_wrapper(cls.url, 'archive/') |
| 1372 |
|
return reversed(get_soup_at_url(archive_url).find_all('a', href=cls.comic_link_re)) |
| 1373 |
|
|
| 1374 |
|
@classmethod |
| 1375 |
|
def get_comic_info(cls, soup, link): |
| 1376 |
|
"""Get information about a particular comics.""" |
| 1377 |
|
url = cls.get_url_from_archive_element(link) |
| 1378 |
|
title = link.string |
| 1379 |
|
year, month, day = [int(s) for s in cls.comic_link_re.match(url).groups()] |
| 1380 |
|
img = soup.find('div', id='comic').find('img') |
| 1381 |
|
assert img['alt'] == title |
| 1382 |
|
return { |
| 1383 |
|
'title': title, |
| 1384 |
|
'day': day, |
| 1385 |
|
'month': month, |
| 1386 |
|
'year': year, |
| 1387 |
|
'img': [img['src']], |
| 1388 |
|
} |
| 1389 |
|
|
| 1390 |
|
|
|
@@ 1427-1448 (lines=22) @@
|
| 1424 |
|
last_date = comic_date |
| 1425 |
|
|
| 1426 |
|
|
| 1427 |
|
class AbstruseGoose(GenericListableComic): |
| 1428 |
|
"""Class to retrieve AbstruseGoose Comics.""" |
| 1429 |
|
name = 'abstruse' |
| 1430 |
|
long_name = 'Abstruse Goose' |
| 1431 |
|
url = 'http://abstrusegoose.com' |
| 1432 |
|
get_url_from_archive_element = get_href |
| 1433 |
|
comic_url_re = re.compile('^%s/([0-9]*)$' % url) |
| 1434 |
|
comic_img_re = re.compile('^%s/strips/.*' % url) |
| 1435 |
|
|
| 1436 |
|
@classmethod |
| 1437 |
|
def get_archive_elements(cls): |
| 1438 |
|
archive_url = urljoin_wrapper(cls.url, 'archive') |
| 1439 |
|
return get_soup_at_url(archive_url).find_all('a', href=cls.comic_url_re) |
| 1440 |
|
|
| 1441 |
|
@classmethod |
| 1442 |
|
def get_comic_info(cls, soup, archive_elt): |
| 1443 |
|
comic_url = cls.get_url_from_archive_element(archive_elt) |
| 1444 |
|
num = int(cls.comic_url_re.match(comic_url).groups()[0]) |
| 1445 |
|
return { |
| 1446 |
|
'num': num, |
| 1447 |
|
'title': archive_elt.string, |
| 1448 |
|
'img': [soup.find('img', src=cls.comic_img_re)['src']] |
| 1449 |
|
} |
| 1450 |
|
|
| 1451 |
|
|
|
@@ 2037-2060 (lines=24) @@
|
| 2034 |
|
} |
| 2035 |
|
|
| 2036 |
|
|
| 2037 |
|
class PoorlyDrawnLines(GenericListableComic): |
| 2038 |
|
"""Class to retrieve Poorly Drawn Lines comics.""" |
| 2039 |
|
# Also on http://pdlcomics.tumblr.com |
| 2040 |
|
name = 'poorlydrawn' |
| 2041 |
|
long_name = 'Poorly Drawn Lines' |
| 2042 |
|
url = 'http://poorlydrawnlines.com' |
| 2043 |
|
_categories = ('POORLYDRAWN', ) |
| 2044 |
|
get_url_from_archive_element = get_href |
| 2045 |
|
|
| 2046 |
|
@classmethod |
| 2047 |
|
def get_comic_info(cls, soup, link): |
| 2048 |
|
"""Get information about a particular comics.""" |
| 2049 |
|
imgs = soup.find('div', class_='post').find_all('img') |
| 2050 |
|
assert len(imgs) <= 1 |
| 2051 |
|
return { |
| 2052 |
|
'img': [i['src'] for i in imgs], |
| 2053 |
|
'title': imgs[0].get('title', "") if imgs else "", |
| 2054 |
|
} |
| 2055 |
|
|
| 2056 |
|
@classmethod |
| 2057 |
|
def get_archive_elements(cls): |
| 2058 |
|
archive_url = urljoin_wrapper(cls.url, 'archive') |
| 2059 |
|
url_re = re.compile('^%s/comic/.' % cls.url) |
| 2060 |
|
return reversed(get_soup_at_url(archive_url).find_all('a', href=url_re)) |
| 2061 |
|
|
| 2062 |
|
|
| 2063 |
|
class LoadingComics(GenericNavigableComic): |