|
@@ 5411-5426 (lines=16) @@
|
| 5408 |
|
"""Generic class to handle the logic common to comics from tapastic.com.""" |
| 5409 |
|
_categories = ('TAPASTIC', ) |
| 5410 |
|
|
| 5411 |
|
@classmethod |
| 5412 |
|
def get_comic_info(cls, soup, archive_elt): |
| 5413 |
|
"""Get information about a particular comics.""" |
| 5414 |
|
timestamp = int(archive_elt['publishDate']) / 1000.0 |
| 5415 |
|
day = datetime.datetime.fromtimestamp(timestamp).date() |
| 5416 |
|
imgs = soup.find_all('img', class_='art-image') |
| 5417 |
|
if not imgs: |
| 5418 |
|
# print("Comic %s is being uploaded, retry later" % cls.get_url_from_archive_element(archive_elt)) |
| 5419 |
|
return None |
| 5420 |
|
assert len(imgs) > 0, imgs |
| 5421 |
|
return { |
| 5422 |
|
'day': day.day, |
| 5423 |
|
'year': day.year, |
| 5424 |
|
'month': day.month, |
| 5425 |
|
'img': [i['src'] for i in imgs], |
| 5426 |
|
'title': archive_elt['title'], |
| 5427 |
|
} |
| 5428 |
|
|
| 5429 |
|
@classmethod |
|
@@ 1043-1056 (lines=14) @@
|
| 1040 |
|
"""Get link to first comics.""" |
| 1041 |
|
return get_soup_at_url(cls.url).find('a', class_='comic_nav_link first_comic_link') |
| 1042 |
|
|
| 1043 |
|
@classmethod |
| 1044 |
|
def get_comic_info(cls, soup, link): |
| 1045 |
|
"""Get information about a particular comics.""" |
| 1046 |
|
title = soup.find("h1", class_="comic_title").string |
| 1047 |
|
date_str = soup.find("span", class_="comic_date").string |
| 1048 |
|
day = string_to_date(date_str, "%B %d, %Y") |
| 1049 |
|
imgs = soup.find_all("img", class_="comic") |
| 1050 |
|
assert all(i['alt'] == i['title'] == title for i in imgs) |
| 1051 |
|
return { |
| 1052 |
|
'title': title, |
| 1053 |
|
'img': [i['src'] for i in imgs if i["src"]], |
| 1054 |
|
'day': day.day, |
| 1055 |
|
'month': day.month, |
| 1056 |
|
'year': day.year |
| 1057 |
|
} |
| 1058 |
|
|
| 1059 |
|
|