@@ 1387-1413 (lines=27) @@ | ||
1384 | } |
|
1385 | ||
1386 | ||
1387 | class ButterSafe(GenericListableComic): |
|
1388 | """Class to retrieve Butter Safe comics.""" |
|
1389 | name = 'butter' |
|
1390 | long_name = 'ButterSafe' |
|
1391 | url = 'http://buttersafe.com' |
|
1392 | get_url_from_archive_element = get_href |
|
1393 | comic_link_re = re.compile('^%s/([0-9]*)/([0-9]*)/([0-9]*)/.*' % url) |
|
1394 | ||
1395 | @classmethod |
|
1396 | def get_archive_elements(cls): |
|
1397 | archive_url = urljoin_wrapper(cls.url, 'archive/') |
|
1398 | return reversed(get_soup_at_url(archive_url).find_all('a', href=cls.comic_link_re)) |
|
1399 | ||
1400 | @classmethod |
|
1401 | def get_comic_info(cls, soup, link): |
|
1402 | """Get information about a particular comics.""" |
|
1403 | url = cls.get_url_from_archive_element(link) |
|
1404 | title = link.string |
|
1405 | year, month, day = [int(s) for s in cls.comic_link_re.match(url).groups()] |
|
1406 | img = soup.find('div', id='comic').find('img') |
|
1407 | assert img['alt'] == title |
|
1408 | return { |
|
1409 | 'title': title, |
|
1410 | 'day': day, |
|
1411 | 'month': month, |
|
1412 | 'year': year, |
|
1413 | 'img': [img['src']], |
|
1414 | } |
|
1415 | ||
1416 | ||
@@ 1453-1474 (lines=22) @@ | ||
1450 | last_date = comic_date |
|
1451 | ||
1452 | ||
1453 | class AbstruseGoose(GenericListableComic): |
|
1454 | """Class to retrieve AbstruseGoose Comics.""" |
|
1455 | name = 'abstruse' |
|
1456 | long_name = 'Abstruse Goose' |
|
1457 | url = 'http://abstrusegoose.com' |
|
1458 | get_url_from_archive_element = get_href |
|
1459 | comic_url_re = re.compile('^%s/([0-9]*)$' % url) |
|
1460 | comic_img_re = re.compile('^%s/strips/.*' % url) |
|
1461 | ||
1462 | @classmethod |
|
1463 | def get_archive_elements(cls): |
|
1464 | archive_url = urljoin_wrapper(cls.url, 'archive') |
|
1465 | return get_soup_at_url(archive_url).find_all('a', href=cls.comic_url_re) |
|
1466 | ||
1467 | @classmethod |
|
1468 | def get_comic_info(cls, soup, archive_elt): |
|
1469 | comic_url = cls.get_url_from_archive_element(archive_elt) |
|
1470 | num = int(cls.comic_url_re.match(comic_url).groups()[0]) |
|
1471 | return { |
|
1472 | 'num': num, |
|
1473 | 'title': archive_elt.string, |
|
1474 | 'img': [soup.find('img', src=cls.comic_img_re)['src']] |
|
1475 | } |
|
1476 | ||
1477 | ||
@@ 2063-2086 (lines=24) @@ | ||
2060 | } |
|
2061 | ||
2062 | ||
2063 | class PoorlyDrawnLines(GenericListableComic): |
|
2064 | """Class to retrieve Poorly Drawn Lines comics.""" |
|
2065 | # Also on http://pdlcomics.tumblr.com |
|
2066 | name = 'poorlydrawn' |
|
2067 | long_name = 'Poorly Drawn Lines' |
|
2068 | url = 'https://www.poorlydrawnlines.com' |
|
2069 | _categories = ('POORLYDRAWN', ) |
|
2070 | get_url_from_archive_element = get_href |
|
2071 | ||
2072 | @classmethod |
|
2073 | def get_comic_info(cls, soup, link): |
|
2074 | """Get information about a particular comics.""" |
|
2075 | imgs = soup.find('div', class_='post').find_all('img') |
|
2076 | assert len(imgs) <= 1 |
|
2077 | return { |
|
2078 | 'img': [i['src'] for i in imgs], |
|
2079 | 'title': imgs[0].get('title', "") if imgs else "", |
|
2080 | } |
|
2081 | ||
2082 | @classmethod |
|
2083 | def get_archive_elements(cls): |
|
2084 | archive_url = urljoin_wrapper(cls.url, 'archive') |
|
2085 | url_re = re.compile('^%s/comic/.' % cls.url) |
|
2086 | return reversed(get_soup_at_url(archive_url).find_all('a', href=url_re)) |
|
2087 | ||
2088 | ||
2089 | class LoadingComics(GenericNavigableComic): |