Completed
Push — master ( fcff78...37f97a )
by De
01:03
created

comics.py (24 issues)

Code
1
#! /usr/bin/python3
2
# vim: set expandtab tabstop=4 shiftwidth=4 :
3
"""Module to retrieve webcomics"""
4
5
from comic_abstract import GenericComic, get_date_for_comic
6
import re
7
from datetime import date, timedelta
8
import datetime
9
from urlfunctions import get_soup_at_url, urljoin_wrapper,\
10
    convert_iri_to_plain_ascii_uri, load_json_at_url, urlopen_wrapper
11
import json
12
import locale
13
import urllib
14
15
DEFAULT_LOCAL = 'en_GB.UTF-8'
16
17
18
class Xkcd(GenericComic):
19
    """Class to retrieve Xkcd comics."""
20
    name = 'xkcd'
21
    long_name = 'xkcd'
22
    url = 'http://xkcd.com'
23
24
    @classmethod
25
    def get_next_comic(cls, last_comic):
26
        """Generator to get the next comic. Implementation of GenericComic's abstract method."""
27
        first_num = last_comic['num'] if last_comic else 0
28
        last_num = load_json_at_url(
29
            urljoin_wrapper(cls.url, 'info.0.json'))['num']
30
31
        for num in range(first_num + 1, last_num + 1):
32
            if num != 404:
33
                json_url = urljoin_wrapper(cls.url, '%d/info.0.json' % num)
34
                comic = load_json_at_url(json_url)
35
                comic['img'] = [comic['img']]
36
                comic['prefix'] = '%d-' % num
37
                comic['json_url'] = json_url
38
                comic['url'] = urljoin_wrapper(cls.url, str(num))
39
                comic['day'] = int(comic['day'])
40
                comic['month'] = int(comic['month'])
41
                comic['year'] = int(comic['year'])
42
                assert comic['num'] == num
43
                yield comic
44
45
46
# Helper functions corresponding to get_url_from_link/get_url_from_archive_element
47
48
49
@classmethod
50
def get_href(cls, link):
51
    """Implementation of get_url_from_link/get_url_from_archive_element."""
52
    return link['href']
53
54
55
@classmethod
56
def join_cls_url_to_href(cls, link):
57
    """Implementation of get_url_from_link/get_url_from_archive_element."""
58
    return urljoin_wrapper(cls.url, link['href'])
59
60
61
class GenericNavigableComic(GenericComic):
62
    """Generic class for "navigable" comics : with first/next arrows.
63
64
    This class applies to comic where previous and next comics can be
65
    accessed from a given comic. Once given a starting point (either
66
    the first comic or the last comic retrieved), it will handle the
67
    navigation, the retrieval of the soup object and the setting of
68
    the 'url' attribute on retrieved comics. This limits a lot the
69
    amount of boilerplate code in the different implementation classes.
70
71
    The method `get_next_comic` methods is implemented in terms of new
72
    more specialized methods to be implemented/overridden:
73
        - get_first_comic_link
74
        - get_navi_link
75
        - get_comic_info
76
        - get_url_from_link
77
    """
78
    _categories = ('NAVIGABLE', )
79
80
    @classmethod
81
    def get_first_comic_link(cls):
82
        """Get link to first comics.
83
84
        Sometimes this can be retrieved of any comic page, sometimes on
85
        the archive page, sometimes it doesn't exist at all and one has
86
        to iterate backward to find it before hardcoding the result found.
87
        """
88
        raise NotImplementedError
89
90
    @classmethod
91
    def get_navi_link(cls, last_soup, next_):
92
        """Get link to next (or previous - for dev purposes) comic."""
93
        raise NotImplementedError
94
95
    @classmethod
96
    def get_comic_info(cls, soup, link):
97
        """Get information about a particular comics."""
98
        raise NotImplementedError
99
100
    @classmethod
101
    def get_url_from_link(cls, link):
102
        """Get url corresponding to a link. Default implementation is similar to get_href."""
103
        return link['href']
104
105
    @classmethod
106
    def get_next_link(cls, last_soup):
107
        """Get link to next comic."""
108
        return cls.get_navi_link(last_soup, True)
109
110
    @classmethod
111
    def get_prev_link(cls, last_soup):
112
        """Get link to previous comic."""
113
        return cls.get_navi_link(last_soup, False)
114
115
    @classmethod
116
    def get_next_comic(cls, last_comic):
117
        """Generic implementation of get_next_comic for navigable comics."""
118
        url = last_comic['url'] if last_comic else None
119
        next_comic = \
120
            cls.get_next_link(get_soup_at_url(url)) \
121
            if url else \
122
            cls.get_first_comic_link()
123
        cls.log("next/first comic will be %s (url is %s)" % (str(next_comic), url))
124
        while next_comic:
125
            prev_url, url = url, cls.get_url_from_link(next_comic)
126
            if prev_url == url:
127
                cls.log("got same url %s" % url)
128
                break
129
            cls.log("about to get %s (%s)" % (url, str(next_comic)))
130
            soup = get_soup_at_url(url)
131
            comic = cls.get_comic_info(soup, next_comic)
132
            if comic is not None:
133
                assert 'url' not in comic
134
                comic['url'] = url
135
                yield comic
136
            next_comic = cls.get_next_link(soup)
137
            cls.log("next comic will be %s" % str(next_comic))
138
139
    @classmethod
140
    def check_first_link(cls):
141
        """Check that navigation to first comic seems to be working - for dev purposes."""
142
        cls.log("about to check first link")
143
        ok = True
144
        firstlink = cls.get_first_comic_link()
145
        if firstlink is None:
146
            print("From %s : no first link" % cls.url)
147
            ok = False
148
        else:
149
            firsturl = cls.get_url_from_link(firstlink)
150
            try:
151
                get_soup_at_url(firsturl)
152
            except urllib.error.HTTPError:
153
                print("From %s : invalid first url" % cls.url)
154
                ok = False
155
        cls.log("checked first link -> returned %d" % ok)
156
        return ok
157
158
    @classmethod
159
    def check_prev_next_links(cls, url):
160
        """Check that navigation to prev/next from a given URL seems to be working - for dev purposes."""
161
        cls.log("about to check prev/next from %s" % url)
162
        ok = True
163
        if url is None:
164
            prevlink, nextlink = None, None
165
        else:
166
            soup = get_soup_at_url(url)
167
            prevlink, nextlink = cls.get_prev_link(soup), cls.get_next_link(soup)
168
        if prevlink is None and nextlink is None:
169
            print("From %s : no previous nor next" % url)
170
            ok = False
171
        else:
172
            if prevlink:
173
                prevurl = cls.get_url_from_link(prevlink)
174
                prevsoup = get_soup_at_url(prevurl)
175
                prevnext = cls.get_url_from_link(cls.get_next_link(prevsoup))
176
                if prevnext != url:
177
                    print("From %s, going backward then forward leads to %s" % (url, prevnext))
178
                    ok = False
179
            if nextlink:
180
                nexturl = cls.get_url_from_link(nextlink)
181
                if nexturl != url:
182
                    nextsoup = get_soup_at_url(nexturl)
183
                    nextprev = cls.get_url_from_link(cls.get_prev_link(nextsoup))
184
                    if nextprev != url:
185
                        print("From %s, going forward then backward leads to %s" % (url, nextprev))
186
                        ok = False
187
        cls.log("checked prev/next from %s -> returned %d" % (url, ok))
188
        return ok
189
190
    @classmethod
191
    def check_navigation(cls, url):
192
        """Check that navigation functions seem to be working - for dev purposes."""
193
        cls.log("about to check navigation from %s" % url)
194
        first = cls.check_first_link()
195
        prevnext = cls.check_prev_next_links(url)
196
        ok = first and prevnext
197
        cls.log("checked navigation from %s -> returned %d" % (url, ok))
198
        return ok
199
200
201
class GenericListableComic(GenericComic):
202
    """Generic class for "listable" comics : with a list of comics (aka 'archive')
203
204
    The method `get_next_comic` methods is implemented in terms of new
205
    more specialized methods to be implemented/overridden:
206
        - get_archive_elements
207
        - get_url_from_archive_element
208
        - get_comic_info
209
    """
210
    _categories = ('LISTABLE', )
211
212
    @classmethod
213
    def get_archive_elements(cls):
214
        """Get the archive elements (iterable)."""
215
        raise NotImplementedError
216
217
    @classmethod
218
    def get_url_from_archive_element(cls, archive_elt):
219
        """Get url corresponding to an archive element."""
220
        raise NotImplementedError
221
222
    @classmethod
223
    def get_comic_info(cls, soup, archive_elt):
224
        """Get information about a particular comics."""
225
        raise NotImplementedError
226
227
    @classmethod
228
    def get_next_comic(cls, last_comic):
229
        """Generic implementation of get_next_comic for listable comics."""
230
        waiting_for_url = last_comic['url'] if last_comic else None
231
        for archive_elt in cls.get_archive_elements():
232
            url = cls.get_url_from_archive_element(archive_elt)
233
            cls.log("considering %s" % url)
234
            if waiting_for_url and waiting_for_url == url:
235
                waiting_for_url = None
236
            elif waiting_for_url is None:
237
                cls.log("about to get %s (%s)" % (url, str(archive_elt)))
238
                soup = get_soup_at_url(url)
239
                comic = cls.get_comic_info(soup, archive_elt)
240
                if comic is not None:
241
                    assert 'url' not in comic
242
                    comic['url'] = url
243
                    yield comic
244
        if waiting_for_url is not None:
245
            print("Did not find %s : there might be a problem" % waiting_for_url)
246
247
# Helper functions corresponding to get_first_comic_link/get_navi_link
248
249
250
@classmethod
251
def get_link_rel_next(cls, last_soup, next_):
252
    """Implementation of get_navi_link."""
253
    return last_soup.find('link', rel='next' if next_ else 'prev')
254
255
256
@classmethod
257
def get_a_rel_next(cls, last_soup, next_):
258
    """Implementation of get_navi_link."""
259
    return last_soup.find('a', rel='next' if next_ else 'prev')
260
261
262
@classmethod
263
def get_a_navi_navinext(cls, last_soup, next_):
264
    """Implementation of get_navi_link."""
265
    return last_soup.find('a', class_='navi navi-next' if next_ else 'navi navi-prev')
266
267
268
@classmethod
269
def get_a_navi_comicnavnext_navinext(cls, last_soup, next_):
270
    """Implementation of get_navi_link."""
271
    return last_soup.find('a', class_='navi comic-nav-next navi-next' if next_ else 'navi comic-nav-previous navi-prev')
272
273
274
@classmethod
275
def get_a_comicnavbase_comicnavnext(cls, last_soup, next_):
276
    """Implementation of get_navi_link."""
277
    return last_soup.find('a', class_='comic-nav-base comic-nav-next' if next_ else 'comic-nav-base comic-nav-previous')
278
279
280
@classmethod
281
def get_a_navi_navifirst(cls):
282
    """Implementation of get_first_comic_link."""
283
    return get_soup_at_url(cls.url).find('a', class_='navi navi-first')
284
285
286
@classmethod
287
def get_div_navfirst_a(cls):
288
    """Implementation of get_first_comic_link."""
289
    return get_soup_at_url(cls.url).find('div', class_="nav-first").find('a')
290
291
292
@classmethod
293
def get_a_comicnavbase_comicnavfirst(cls):
294
    """Implementation of get_first_comic_link."""
295
    return get_soup_at_url(cls.url).find('a', class_='comic-nav-base comic-nav-first')
296
297
298
@classmethod
299
def simulate_first_link(cls):
300
    """Implementation of get_first_comic_link creating a link-like object from
301
    an URL provided by the class."""
302
    return {'href': cls.first_url}
303
304
305
@classmethod
306
def navigate_to_first_comic(cls):
307
    """Implementation of get_first_comic_link navigating from a user provided
308
    URL to the first comic.
309
310
    Sometimes, the first comic cannot be reached directly so to start
311
    from the first comic one has to go to the previous comic until
312
    there is no previous comics. Once this URL is reached, it
313
    is better to hardcode it but for development purposes, it
314
    is convenient to have an automatic way to find it.
315
    """
316
    url = input("Get starting URL: ")
317
    print(url)
318
    comic = cls.get_prev_link(get_soup_at_url(url))
319
    while comic:
320
        url = cls.get_url_from_link(comic)
321
        print(url)
322
        comic = cls.get_prev_link(get_soup_at_url(url))
323
    return {'href': url}
324
325
326
class GenericEmptyComic(GenericComic):
327
    """Generic class for comics where nothing is to be done.
328
329
    It can be useful to deactivate temporarily comics that do not work
330
    properly by replacing `def MyComic(GenericWhateverComic)` with
331
    `def MyComic(GenericEmptyComic, GenericWhateverComic)`."""
332
    _categories = ('EMPTY', )
333
334
    @classmethod
335
    def get_next_comic(cls, last_comic):
336
        """Implementation of get_next_comic returning no comics."""
337
        cls.log("comic is considered as empty - returning no comic")
338 View Code Duplication
        return []
0 ignored issues
show
This code seems to be duplicated in your project.
Loading history...
339
340
341
class ExtraFabulousComics(GenericNavigableComic):
342
    """Class to retrieve Extra Fabulous Comics."""
343
    name = 'efc'
344
    long_name = 'Extra Fabulous Comics'
345
    url = 'http://extrafabulouscomics.com'
346
    get_first_comic_link = get_a_navi_navifirst
347
    get_navi_link = get_link_rel_next
348
349
    @classmethod
350
    def get_comic_info(cls, soup, link):
351
        """Get information about a particular comics."""
352
        img_src_re = re.compile('^%s/wp-content/uploads/' % cls.url)
353
        imgs = soup.find_all('img', src=img_src_re)
354
        title = soup.find('meta', property='og:title')['content']
355
        date_str = soup.find('meta', property='article:published_time')['content'][:10]
356
        day = string_to_date(date_str, "%Y-%m-%d")
357
        return {
358
            'title': title,
359
            'img': [i['src'] for i in imgs],
360
            'month': day.month,
361
            'year': day.year,
362
            'day': day.day,
363
            'prefix': title + '-'
364
        }
365
366
367
class GenericLeMondeBlog(GenericNavigableComic):
368
    """Generic class to retrieve comics from Le Monde blogs."""
369
    _categories = ('LEMONDE', 'FRANCAIS')
370
    get_navi_link = get_link_rel_next
371
    get_first_comic_link = simulate_first_link
372
    first_url = NotImplemented
373
374
    @classmethod
375
    def get_comic_info(cls, soup, link):
376
        """Get information about a particular comics."""
377
        url2 = soup.find('link', rel='shortlink')['href']
378
        title = soup.find('meta', property='og:title')['content']
379
        date_str = soup.find("span", class_="entry-date").string
380
        day = string_to_date(date_str, "%d %B %Y", "fr_FR.utf8")
381
        imgs = soup.find_all('meta', property='og:image')
382
        return {
383
            'title': title,
384
            'url2': url2,
385
            'img': [convert_iri_to_plain_ascii_uri(i['content']) for i in imgs],
386
            'month': day.month,
387
            'year': day.year,
388
            'day': day.day,
389
        }
390
391
392
class ZepWorld(GenericLeMondeBlog):
393
    """Class to retrieve Zep World comics."""
394
    name = "zep"
395
    long_name = "Zep World"
396
    url = "http://zepworld.blog.lemonde.fr"
397
    first_url = "http://zepworld.blog.lemonde.fr/2014/10/31/bientot-le-blog-de-zep/"
398
399
400
class Vidberg(GenericLeMondeBlog):
401
    """Class to retrieve Vidberg comics."""
402
    name = 'vidberg'
403
    long_name = "Vidberg - l'actu en patates"
404
    url = "http://vidberg.blog.lemonde.fr"
405
    # Not the first but I didn't find an efficient way to retrieve it
406
    first_url = "http://vidberg.blog.lemonde.fr/2012/02/09/revue-de-campagne-la-campagne-du-modem-semballe/"
407
408
409
class Plantu(GenericLeMondeBlog):
410
    """Class to retrieve Plantu comics."""
411
    name = 'plantu'
412
    long_name = "Plantu"
413
    url = "http://plantu.blog.lemonde.fr"
414
    first_url = "http://plantu.blog.lemonde.fr/2014/10/28/stress-test-a-bruxelles/"
415
416
417
class XavierGorce(GenericLeMondeBlog):
418
    """Class to retrieve Xavier Gorce comics."""
419
    name = 'gorce'
420
    long_name = "Xavier Gorce"
421
    url = "http://xaviergorce.blog.lemonde.fr"
422
    first_url = "http://xaviergorce.blog.lemonde.fr/2015/01/09/distinction/"
423
424
425
class CartooningForPeace(GenericLeMondeBlog):
426
    """Class to retrieve Cartooning For Peace comics."""
427
    name = 'forpeace'
428
    long_name = "Cartooning For Peace"
429
    url = "http://cartooningforpeace.blog.lemonde.fr"
430
    first_url = "http://cartooningforpeace.blog.lemonde.fr/2014/12/15/bado/"
431
432
433
class Aurel(GenericLeMondeBlog):
434
    """Class to retrieve Aurel comics."""
435
    name = 'aurel'
436
    long_name = "Aurel"
437
    url = "http://aurel.blog.lemonde.fr"
438
    first_url = "http://aurel.blog.lemonde.fr/2014/09/29/le-senat-repasse-a-droite/"
439
440
441
class LesCulottees(GenericLeMondeBlog):
442
    """Class to retrieve Les Culottees comics."""
443
    name = 'culottees'
444
    long_name = 'Les Culottees'
445
    url = "http://lesculottees.blog.lemonde.fr"
446
    first_url = "http://lesculottees.blog.lemonde.fr/2016/01/11/clementine-delait-femme-a-barbe/"
447
448
449
class UneAnneeAuLycee(GenericLeMondeBlog):
450
    """Class to retrieve Une Annee Au Lycee comics."""
451
    name = 'lycee'
452
    long_name = 'Une Annee au Lycee'
453
    url = 'http://uneanneeaulycee.blog.lemonde.fr'
454
    first_url = "http://uneanneeaulycee.blog.lemonde.fr/2016/06/13/la-semaine-du-bac-est-arrivee/"
455
456
457
class Rall(GenericNavigableComic):
458
    """Class to retrieve Ted Rall comics."""
459
    # Also on http://www.gocomics.com/tedrall
460
    name = 'rall'
461
    long_name = "Ted Rall"
462
    url = "http://rall.com/comic"
463
    _categories = ('RALL', )
464
    get_navi_link = get_link_rel_next
465
    get_first_comic_link = simulate_first_link
466
    # Not the first but I didn't find an efficient way to retrieve it
467
    first_url = "http://rall.com/2014/01/30/los-angeles-times-cartoon-well-miss-those-california-flowers"
468
469
    @classmethod
470
    def get_comic_info(cls, soup, link):
471
        """Get information about a particular comics."""
472
        title = soup.find('meta', property='og:title')['content']
473
        author = soup.find("span", class_="author vcard").find("a").string
474
        date_str = soup.find("span", class_="entry-date").string
475
        day = string_to_date(date_str, "%B %d, %Y")
476
        desc = soup.find('meta', property='og:description')['content']
477
        imgs = soup.find('div', class_='entry-content').find_all('img')
478
        imgs = imgs[:-7]  # remove social media buttons
479
        return {
480
            'title': title,
481
            'author': author,
482
            'month': day.month,
483
            'year': day.year,
484
            'day': day.day,
485
            'description': desc,
486
            'img': [i['src'] for i in imgs],
487
        }
488
489
490
class Dilem(GenericNavigableComic):
491
    """Class to retrieve Ali Dilem comics."""
492
    name = 'dilem'
493
    long_name = 'Ali Dilem'
494
    url = 'http://information.tv5monde.com/dilem'
495
    _categories = ('FRANCAIS', )
496
    get_url_from_link = join_cls_url_to_href
497
    get_first_comic_link = simulate_first_link
498
    first_url = "http://information.tv5monde.com/dilem/2004-06-26"
499
500
    @classmethod
501
    def get_navi_link(cls, last_soup, next_):
502
        """Get link to next or previous comic."""
503
        # prev is next / next is prev
504
        li = last_soup.find('li', class_='prev' if next_ else 'next')
505
        return li.find('a') if li else None
506
507
    @classmethod
508
    def get_comic_info(cls, soup, link):
509
        """Get information about a particular comics."""
510
        short_url = soup.find('link', rel='shortlink')['href']
511
        title = soup.find('meta', attrs={'name': 'twitter:title'})['content']
512
        imgs = soup.find_all('meta', property='og:image')
513
        date_str = soup.find('span', property='dc:date')['content']
514
        date_str = date_str[:10]
515
        day = string_to_date(date_str, "%Y-%m-%d")
516
        return {
517
            'short_url': short_url,
518
            'title': title,
519
            'img': [i['content'] for i in imgs],
520
            'day': day.day,
521
            'month': day.month,
522
            'year': day.year,
523
        }
524
525
526
class SpaceAvalanche(GenericNavigableComic):
527
    """Class to retrieve Space Avalanche comics."""
528
    name = 'avalanche'
529
    long_name = 'Space Avalanche'
530
    url = 'http://www.spaceavalanche.com'
531
    get_navi_link = get_link_rel_next
532
533
    @classmethod
534
    def get_first_comic_link(cls):
535
        """Get link to first comics."""
536
        return {'href': "http://www.spaceavalanche.com/2009/02/02/irish-sea/", 'title': "Irish Sea"}
537
538
    @classmethod
539
    def get_comic_info(cls, soup, link):
540
        """Get information about a particular comics."""
541
        url_date_re = re.compile('.*/([0-9]*)/([0-9]*)/([0-9]*)/.*$')
542
        title = link['title']
543
        url = cls.get_url_from_link(link)
544
        year, month, day = [int(s)
545
                            for s in url_date_re.match(url).groups()]
546
        imgs = soup.find("div", class_="entry").find_all("img")
547
        return {
548
            'title': title,
549
            'day': day,
550
            'month': month,
551
            'year': year,
552
            'img': [i['src'] for i in imgs],
553
        }
554
555
556
class ZenPencils(GenericNavigableComic):
557
    """Class to retrieve ZenPencils comics."""
558
    # Also on http://zenpencils.tumblr.com
559
    # Also on http://www.gocomics.com/zen-pencils
560
    name = 'zenpencils'
561
    long_name = 'Zen Pencils'
562
    url = 'http://zenpencils.com'
563
    _categories = ('ZENPENCILS', )
564
    get_navi_link = get_link_rel_next
565
    get_first_comic_link = simulate_first_link
566
    first_url = "http://zenpencils.com/comic/1-ralph-waldo-emerson-make-them-cry/"
567
568
    @classmethod
569
    def get_comic_info(cls, soup, link):
570
        """Get information about a particular comics."""
571
        imgs = soup.find('div', id='comic').find_all('img')
572
        # imgs2 = soup.find_all('meta', property='og:image')
573
        post = soup.find('div', class_='post-content')
574
        author = post.find("span", class_="post-author").find("a").string
575
        title = soup.find('meta', property='og:title')['content']
576
        date_str = post.find('span', class_='post-date').string
577
        day = string_to_date(date_str, "%B %d, %Y")
578
        assert imgs
579
        assert all(i['alt'] == i['title'] for i in imgs)
580
        assert all(i['alt'] in (title, "") for i in imgs)
581
        desc = soup.find('meta', property='og:description')['content']
582
        return {
583
            'title': title,
584
            'description': desc,
585
            'author': author,
586
            'day': day.day,
587
            'month': day.month,
588
            'year': day.year,
589
            'img': [urljoin_wrapper(cls.url, i['src']) for i in imgs],
590
        }
591
592
593
class ItsTheTie(GenericNavigableComic):
594
    """Class to retrieve It's the tie comics."""
595
    # Also on http://itsthetie.tumblr.com
596
    # Also on https://tapastic.com/series/itsthetie
597
    name = 'tie'
598
    long_name = "It's the tie"
599
    url = "http://itsthetie.com"
600
    _categories = ('TIE', )
601
    get_first_comic_link = get_div_navfirst_a
602
    get_navi_link = get_a_rel_next
603
604
    @classmethod
605
    def get_comic_info(cls, soup, link):
606
        """Get information about a particular comics."""
607
        title = soup.find('h1', class_='comic-title').find('a').string
608
        date_str = soup.find('header', class_='comic-meta entry-meta').find('a').string
609
        day = string_to_date(date_str, "%B %d, %Y")
610
        # Bonus images may or may not be in meta og:image.
611
        imgs = soup.find_all('meta', property='og:image')
612
        imgs_src = [i['content'] for i in imgs]
613
        bonus = soup.find_all('img', attrs={'data-oversrc': True})
614
        bonus_src = [b['data-oversrc'] for b in bonus]
615
        all_imgs_src = imgs_src + [s for s in bonus_src if s not in imgs_src]
616
        all_imgs_src = [s for s in all_imgs_src if not s.endswith("/2016/01/bonus-panel.png")]
617
        tag_meta = soup.find('meta', property='article:tag')
618
        tags = tag_meta['content'] if tag_meta else ""
619
        return {
620
            'title': title,
621
            'month': day.month,
622
            'year': day.year,
623
            'day': day.day,
624
            'img': all_imgs_src,
625
            'tags': tags,
626
        }
627
628
629
class PenelopeBagieu(GenericNavigableComic):
630
    """Class to retrieve comics from Penelope Bagieu's blog."""
631
    name = 'bagieu'
632
    long_name = 'Ma vie est tout a fait fascinante (Bagieu)'
633
    url = 'http://www.penelope-jolicoeur.com'
634
    _categories = ('FRANCAIS', )
635
    get_navi_link = get_link_rel_next
636
    get_first_comic_link = simulate_first_link
637
    first_url = 'http://www.penelope-jolicoeur.com/2007/02/ma-vie-mon-oeuv.html'
638
639
    @classmethod
640
    def get_comic_info(cls, soup, link):
641
        """Get information about a particular comics."""
642
        date_str = soup.find('h2', class_='date-header').string
643
        day = string_to_date(date_str, "%A %d %B %Y", "fr_FR.utf8")
644
        imgs = soup.find('div', class_='entry-body').find_all('img')
645 View Code Duplication
        title = soup.find('h3', class_='entry-header').string
0 ignored issues
show
This code seems to be duplicated in your project.
Loading history...
646
        return {
647
            'title': title,
648
            'img': [i['src'] for i in imgs],
649
            'month': day.month,
650
            'year': day.year,
651
            'day': day.day,
652
        }
653
654
655
class OneOneOneOneComic(GenericNavigableComic):
656
    """Class to retrieve 1111 Comics."""
657
    # Also on http://comics1111.tumblr.com
658
    # Also on https://tapastic.com/series/1111-Comics
659
    name = '1111'
660
    long_name = '1111 Comics'
661
    url = 'http://www.1111comics.me'
662
    _categories = ('ONEONEONEONE', )
663
    get_first_comic_link = get_div_navfirst_a
664
    get_navi_link = get_link_rel_next
665
666
    @classmethod
667
    def get_comic_info(cls, soup, link):
668
        """Get information about a particular comics."""
669
        title = soup.find('h1', class_='comic-title').find('a').string
670
        date_str = soup.find('header', class_='comic-meta entry-meta').find('a').string
671
        day = string_to_date(date_str, "%B %d, %Y")
672
        imgs = soup.find_all('meta', property='og:image')
673
        return {
674
            'title': title,
675
            'month': day.month,
676
            'year': day.year,
677
            'day': day.day,
678
            'img': [i['content'] for i in imgs],
679
        }
680
681
682
class AngryAtNothing(GenericNavigableComic):
683
    """Class to retrieve Angry at Nothing comics."""
684
    # Also on http://tapastic.com/series/Comics-yeah-definitely-comics-
685
    name = 'angry'
686
    long_name = 'Angry At Nothing'
687
    url = 'http://www.angryatnothing.net'
688
    get_first_comic_link = get_div_navfirst_a
689
    get_navi_link = get_a_rel_next
690
691
    @classmethod
692
    def get_comic_info(cls, soup, link):
693
        """Get information about a particular comics."""
694
        title = soup.find('h1', class_='comic-title').find('a').string
695
        date_str = soup.find('header', class_='comic-meta entry-meta').find('a').string
696
        day = string_to_date(date_str, "%B %d, %Y")
697
        imgs = soup.find_all('meta', property='og:image')
698
        return {
699
            'title': title,
700
            'month': day.month,
701
            'year': day.year,
702
            'day': day.day,
703
            'img': [i['content'] for i in imgs],
704
        }
705
706
707
class NeDroid(GenericNavigableComic):
708
    """Class to retrieve NeDroid comics."""
709
    name = 'nedroid'
710
    long_name = 'NeDroid'
711
    url = 'http://nedroid.com'
712
    get_first_comic_link = get_div_navfirst_a
713
    get_navi_link = get_link_rel_next
714
    get_url_from_link = join_cls_url_to_href
715
716
    @classmethod
717
    def get_comic_info(cls, soup, link):
718
        """Get information about a particular comics."""
719
        short_url_re = re.compile('^%s/\\?p=([0-9]*)' % cls.url)
720
        comic_url_re = re.compile('//nedroid.com/comics/([0-9]*)-([0-9]*)-([0-9]*).*')
721
        short_url = cls.get_url_from_link(soup.find('link', rel='shortlink'))
722
        num = int(short_url_re.match(short_url).groups()[0])
723
        imgs = soup.find('div', id='comic').find_all('img')
724
        year, month, day = [int(s) for s in comic_url_re.match(imgs[0]['src']).groups()]
725
        assert len(imgs) == 1
726
        title = imgs[0]['alt']
727
        title2 = imgs[0]['title']
728
        return {
729
            'short_url': short_url,
730
            'title': title,
731
            'title2': title2,
732
            'img': [urljoin_wrapper(cls.url, i['src']) for i in imgs],
733
            'day': day,
734
            'month': month,
735
            'year': year,
736
            'num': num,
737
        }
738
739
740
class Garfield(GenericNavigableComic):
741
    """Class to retrieve Garfield comics."""
742
    # Also on http://www.gocomics.com/garfield
743
    name = 'garfield'
744
    long_name = 'Garfield'
745
    url = 'https://garfield.com'
746
    _categories = ('GARFIELD', )
747
    get_first_comic_link = simulate_first_link
748
    first_url = 'https://garfield.com/comic/1978/06/19'
749
750
    @classmethod
751
    def get_navi_link(cls, last_soup, next_):
752
        """Get link to next or previous comic."""
753
        return last_soup.find('a', class_='comic-arrow-right' if next_ else 'comic-arrow-left')
754
755
    @classmethod
756
    def get_comic_info(cls, soup, link):
757
        """Get information about a particular comics."""
758 View Code Duplication
        url = cls.get_url_from_link(link)
0 ignored issues
show
This code seems to be duplicated in your project.
Loading history...
759
        date_re = re.compile('^%s/comic/([0-9]*)/([0-9]*)/([0-9]*)' % cls.url)
760
        year, month, day = [int(s) for s in date_re.match(url).groups()]
761
        imgs = soup.find('div', class_='comic-display').find_all('img', class_='img-responsive')
762
        return {
763
            'month': month,
764
            'year': year,
765
            'day': day,
766
            'img': [i['src'] for i in imgs],
767
        }
768
769
770
class Dilbert(GenericNavigableComic):
771
    """Class to retrieve Dilbert comics."""
772
    # Also on http://www.gocomics.com/dilbert-classics
773
    name = 'dilbert'
774
    long_name = 'Dilbert'
775
    url = 'http://dilbert.com'
776
    get_url_from_link = join_cls_url_to_href
777
    get_first_comic_link = simulate_first_link
778
    first_url = 'http://dilbert.com/strip/1989-04-16'
779
780
    @classmethod
781
    def get_navi_link(cls, last_soup, next_):
782
        """Get link to next or previous comic."""
783
        link = last_soup.find('div', class_='nav-comic nav-right' if next_ else 'nav-comic nav-left')
784
        return link.find('a') if link else None
785
786
    @classmethod
787
    def get_comic_info(cls, soup, link):
788
        """Get information about a particular comics."""
789
        title = soup.find('meta', property='og:title')['content']
790
        imgs = soup.find_all('meta', property='og:image')
791
        desc = soup.find('meta', property='og:description')['content']
792
        date_str = soup.find('meta', property='article:publish_date')['content']
793
        day = string_to_date(date_str, "%B %d, %Y")
794
        author = soup.find('meta', property='article:author')['content']
795
        tags = soup.find('meta', property='article:tag')['content']
796
        return {
797
            'title': title,
798
            'description': desc,
799
            'img': [i['content'] for i in imgs],
800
            'author': author,
801
            'tags': tags,
802
            'day': day.day,
803
            'month': day.month,
804
            'year': day.year
805
        }
806
807
808
class VictimsOfCircumsolar(GenericNavigableComic):
809
    """Class to retrieve VictimsOfCircumsolar comics."""
810
    name = 'circumsolar'
811
    long_name = 'Victims Of Circumsolar'
812
    url = 'http://www.victimsofcircumsolar.com'
813
    get_navi_link = get_a_navi_comicnavnext_navinext
814
    get_first_comic_link = simulate_first_link
815
    first_url = 'http://www.victimsofcircumsolar.com/comic/modern-addiction'
816
817
    @classmethod
818
    def get_comic_info(cls, soup, link):
819
        """Get information about a particular comics."""
820
        # Date is on the archive page
821
        title = soup.find_all('meta', property='og:title')[-1]['content']
822
        desc = soup.find_all('meta', property='og:description')[-1]['content']
823
        imgs = soup.find('div', id='comic').find_all('img')
824
        assert all(i['title'] == i['alt'] == title for i in imgs)
825
        return {
826
            'title': title,
827
            'description': desc,
828
            'img': [i['src'] for i in imgs],
829
        }
830
831
832
class ThreeWordPhrase(GenericNavigableComic):
833
    """Class to retrieve Three Word Phrase comics."""
834
    # Also on http://www.threewordphrase.tumblr.com
835
    name = 'threeword'
836
    long_name = 'Three Word Phrase'
837
    url = 'http://threewordphrase.com'
838
    get_url_from_link = join_cls_url_to_href
839
840
    @classmethod
841
    def get_first_comic_link(cls):
842
        """Get link to first comics."""
843
        return get_soup_at_url(cls.url).find('img', src='/firstlink.gif').parent
844
845
    @classmethod
846
    def get_navi_link(cls, last_soup, next_):
847
        """Get link to next or previous comic."""
848
        link = last_soup.find('img', src='/nextlink.gif' if next_ else '/prevlink.gif').parent
849
        return None if link.get('href') is None else link
850
851
    @classmethod
852
    def get_comic_info(cls, soup, link):
853
        """Get information about a particular comics."""
854
        title = soup.find('title')
855
        imgs = [img for img in soup.find_all('img')
856
                if not img['src'].endswith(
857
                    ('link.gif', '32.png', 'twpbookad.jpg',
858
                     'merchad.jpg', 'header.gif', 'tipjar.jpg'))]
859
        return {
860
            'title': title.string if title else None,
861
            'title2': '  '.join(img.get('alt') for img in imgs if img.get('alt')),
862
            'img': [urljoin_wrapper(cls.url, img['src']) for img in imgs],
863
        }
864
865
866
class DeadlyPanel(GenericEmptyComic, GenericNavigableComic):
867
    """Class to retrieve Deadly Panel comics."""
868
    # Also on https://tapastic.com/series/deadlypanel
869
    name = 'deadly'
870
    long_name = 'Deadly Panel'
871
    url = 'http://www.deadlypanel.com'
872
    get_first_comic_link = get_a_navi_navifirst
873
    get_navi_link = get_a_navi_comicnavnext_navinext
874
875
    @classmethod
876
    def get_comic_info(cls, soup, link):
877
        """Get information about a particular comics."""
878
        imgs = soup.find('div', id='comic').find_all('img')
879
        assert all(i['alt'] == i['title'] for i in imgs)
880
        return {
881
            'img': [i['src'] for i in imgs],
882
        }
883
884
885
class TheGentlemanArmchair(GenericNavigableComic):
886
    """Class to retrieve The Gentleman Armchair comics."""
887
    name = 'gentlemanarmchair'
888
    long_name = 'The Gentleman Armchair'
889
    url = 'http://thegentlemansarmchair.com'
890
    get_first_comic_link = get_a_navi_navifirst
891
    get_navi_link = get_link_rel_next
892
893
    @classmethod
894
    def get_comic_info(cls, soup, link):
895
        """Get information about a particular comics."""
896
        title = soup.find('h2', class_='post-title').string
897
        author = soup.find("span", class_="post-author").find("a").string
898
        date_str = soup.find('span', class_='post-date').string
899
        day = string_to_date(date_str, "%B %d, %Y")
900
        imgs = soup.find('div', id='comic').find_all('img')
901
        return {
902
            'img': [i['src'] for i in imgs],
903
            'title': title,
904
            'author': author,
905
            'month': day.month,
906
            'year': day.year,
907
            'day': day.day,
908
        }
909
910
911
class MyExtraLife(GenericNavigableComic):
912
    """Class to retrieve My Extra Life comics."""
913
    name = 'extralife'
914
    long_name = 'My Extra Life'
915
    url = 'http://www.myextralife.com'
916
    get_navi_link = get_link_rel_next
917
918
    @classmethod
919
    def get_first_comic_link(cls):
920
        """Get link to first comics."""
921
        return get_soup_at_url(cls.url).find('a', class_='comic_nav_link first_comic_link')
922
923
    @classmethod
924
    def get_comic_info(cls, soup, link):
925
        """Get information about a particular comics."""
926
        title = soup.find("h1", class_="comic_title").string
927
        date_str = soup.find("span", class_="comic_date").string
928
        day = string_to_date(date_str, "%B %d, %Y")
929
        imgs = soup.find_all("img", class_="comic")
930
        assert all(i['alt'] == i['title'] == title for i in imgs)
931
        return {
932
            'title': title,
933
            'img': [i['src'] for i in imgs if i["src"]],
934
            'day': day.day,
935
            'month': day.month,
936
            'year': day.year
937
        }
938
939
940
class SaturdayMorningBreakfastCereal(GenericNavigableComic):
941
    """Class to retrieve Saturday Morning Breakfast Cereal comics."""
942
    # Also on http://www.gocomics.com/saturday-morning-breakfast-cereal
943
    # Also on http://smbc-comics.tumblr.com
944
    name = 'smbc'
945
    long_name = 'Saturday Morning Breakfast Cereal'
946
    url = 'http://www.smbc-comics.com'
947
    _categories = ('SMBC', )
948
    get_navi_link = get_a_rel_next
949
950
    @classmethod
951
    def get_first_comic_link(cls):
952
        """Get link to first comics."""
953
        return get_soup_at_url(cls.url).find('a', rel='start')
954
955
    @classmethod
956
    def get_comic_info(cls, soup, link):
957
        """Get information about a particular comics."""
958
        image1 = soup.find('img', id='cc-comic')
959
        image_url1 = image1['src']
960
        aftercomic = soup.find('div', id='aftercomic')
961
        image_url2 = aftercomic.find('img')['src'] if aftercomic else ''
962
        imgs = [image_url1] + ([image_url2] if image_url2 else [])
963
        date_str = soup.find('div', class_='cc-publishtime').contents[0]
964
        day = string_to_date(date_str, "%B %d, %Y")
965
        return {
966
            'title': image1['title'],
967
            'img': [urljoin_wrapper(cls.url, i) for i in imgs],
968
            'day': day.day,
969
            'month': day.month,
970
            'year': day.year
971
        }
972
973
974
class PerryBibleFellowship(GenericListableComic):
975
    """Class to retrieve Perry Bible Fellowship comics."""
976
    name = 'pbf'
977
    long_name = 'Perry Bible Fellowship'
978
    url = 'http://pbfcomics.com'
979
    get_url_from_archive_element = join_cls_url_to_href
980
981
    @classmethod
982
    def get_archive_elements(cls):
983
        comic_link_re = re.compile('^/[0-9]*/$')
984
        return reversed(get_soup_at_url(cls.url).find_all('a', href=comic_link_re))
985
986
    @classmethod
987
    def get_comic_info(cls, soup, link):
988
        """Get information about a particular comics."""
989
        url = cls.get_url_from_archive_element(link)
990
        comic_img_re = re.compile('^/archive_b/PBF.*')
991
        name = link.string
992
        num = int(link['name'])
993
        href = link['href']
994
        assert href == '/%d/' % num
995
        imgs = soup.find_all('img', src=comic_img_re)
996
        assert len(imgs) == 1
997
        assert imgs[0]['alt'] == name
998
        return {
999
            'num': num,
1000
            'name': name,
1001
            'img': [urljoin_wrapper(url, i['src']) for i in imgs],
1002
            'prefix': '%d-' % num,
1003
        }
1004
1005
1006
class Mercworks(GenericNavigableComic):
1007
    """Class to retrieve Mercworks comics."""
1008
    # Also on http://mercworks.tumblr.com
1009
    name = 'mercworks'
1010
    long_name = 'Mercworks'
1011
    url = 'http://mercworks.net'
1012
    get_first_comic_link = get_a_comicnavbase_comicnavfirst
1013
    get_navi_link = get_a_rel_next
1014
1015
    @classmethod
1016
    def get_comic_info(cls, soup, link):
1017
        """Get information about a particular comics."""
1018
        title = soup.find('meta', property='og:title')['content']
1019
        metadesc = soup.find('meta', property='og:description')
1020
        desc = metadesc['content'] if metadesc else ""
1021
        author = soup.find('meta', attrs={'name': 'shareaholic:article_author_name'})['content']
1022
        date_str = soup.find('meta', attrs={'name': 'shareaholic:article_published_time'})['content']
1023
        date_str = date_str[:10]
1024
        day = string_to_date(date_str, "%Y-%m-%d")
1025
        imgs = soup.find_all('meta', property='og:image')
1026
        return {
1027
            'img': [i['content'] for i in imgs],
1028
            'title': title,
1029
            'author': author,
1030
            'desc': desc,
1031
            'day': day.day,
1032
            'month': day.month,
1033
            'year': day.year
1034
        }
1035
1036
1037
class BerkeleyMews(GenericListableComic):
1038
    """Class to retrieve Berkeley Mews comics."""
1039
    # Also on http://mews.tumblr.com
1040
    # Also on http://www.gocomics.com/berkeley-mews
1041
    name = 'berkeley'
1042
    long_name = 'Berkeley Mews'
1043
    url = 'http://www.berkeleymews.com'
1044
    _categories = ('BERKELEY', )
1045
    get_url_from_archive_element = get_href
1046
    comic_num_re = re.compile('%s/\\?p=([0-9]*)$' % url)
1047
1048
    @classmethod
1049
    def get_archive_elements(cls):
1050
        archive_url = urljoin_wrapper(cls.url, "?page_id=2")
1051
        return reversed(get_soup_at_url(archive_url).find_all('a', href=cls.comic_num_re))
1052
1053
    @classmethod
1054
    def get_comic_info(cls, soup, link):
1055
        """Get information about a particular comics."""
1056
        comic_date_re = re.compile('.*/([0-9]*)-([0-9]*)-([0-9]*)-.*')
1057
        url = cls.get_url_from_archive_element(link)
1058
        num = int(cls.comic_num_re.match(url).groups()[0])
1059
        img = soup.find('div', id='comic').find('img')
1060
        assert all(i['alt'] == i['title'] for i in [img])
1061
        title2 = img['title']
1062
        img_url = img['src']
1063
        year, month, day = [int(s) for s in comic_date_re.match(img_url).groups()]
1064
        return {
1065
            'num': num,
1066
            'title': link.string,
1067
            'title2': title2,
1068
            'img': [img_url],
1069
            'year': year,
1070
            'month': month,
1071
            'day': day,
1072
        }
1073
1074
1075
class GenericBouletCorp(GenericNavigableComic):
1076
    """Generic class to retrieve BouletCorp comics in different languages."""
1077
    # Also on http://bouletcorp.tumblr.com
1078
    _categories = ('BOULET', )
1079
    get_navi_link = get_link_rel_next
1080
1081
    @classmethod
1082
    def get_first_comic_link(cls):
1083
        """Get link to first comics."""
1084
        return get_soup_at_url(cls.url).find('div', id='centered_nav').find_all('a')[0]
1085
1086
    @classmethod
1087
    def get_comic_info(cls, soup, link):
1088
        """Get information about a particular comics."""
1089
        url = cls.get_url_from_link(link)
1090
        date_re = re.compile('^%s/([0-9]*)/([0-9]*)/([0-9]*)/' % cls.url)
1091
        year, month, day = [int(s) for s in date_re.match(url).groups()]
1092
        imgs = soup.find('div', id='notes').find('div', class_='storycontent').find_all('img')
1093
        texts = '  '.join(t for t in (i.get('title') for i in imgs) if t)
1094
        title = soup.find('title').string
1095
        return {
1096
            'img': [convert_iri_to_plain_ascii_uri(i['src']) for i in imgs if i.get('src') is not None],
1097
            'title': title,
1098
            'texts': texts,
1099
            'year': year,
1100
            'month': month,
1101
            'day': day,
1102
        }
1103
1104
1105
class BouletCorp(GenericBouletCorp):
1106
    """Class to retrieve BouletCorp comics."""
1107
    name = 'boulet'
1108
    long_name = 'Boulet Corp'
1109
    url = 'http://www.bouletcorp.com'
1110
    _categories = ('FRANCAIS', )
1111
1112
1113
class BouletCorpEn(GenericBouletCorp):
1114
    """Class to retrieve EnglishBouletCorp comics."""
1115
    name = 'boulet_en'
1116
    long_name = 'Boulet Corp English'
1117
    url = 'http://english.bouletcorp.com'
1118
1119
1120
class AmazingSuperPowers(GenericNavigableComic):
1121
    """Class to retrieve Amazing Super Powers comics."""
1122
    name = 'asp'
1123
    long_name = 'Amazing Super Powers'
1124
    url = 'http://www.amazingsuperpowers.com'
1125
    get_first_comic_link = get_a_navi_navifirst
1126
    get_navi_link = get_a_navi_navinext
1127
1128
    @classmethod
1129
    def get_comic_info(cls, soup, link):
1130
        """Get information about a particular comics."""
1131
        author = soup.find("span", class_="post-author").find("a").string
1132
        date_str = soup.find('span', class_='post-date').string
1133
        day = string_to_date(date_str, "%B %d, %Y")
1134
        imgs = soup.find('div', id='comic').find_all('img')
1135
        title = ' '.join(i['title'] for i in imgs)
1136
        assert all(i['alt'] == i['title'] for i in imgs)
1137
        return {
1138
            'title': title,
1139
            'author': author,
1140
            'img': [img['src'] for img in imgs],
1141
            'day': day.day,
1142
            'month': day.month,
1143
            'year': day.year
1144
        }
1145
1146
1147
class ToonHole(GenericNavigableComic):
1148
    """Class to retrieve Toon Holes comics."""
1149
    # Also on http://tapastic.com/series/TOONHOLE
1150
    name = 'toonhole'
1151
    long_name = 'Toon Hole'
1152
    url = 'http://www.toonhole.com'
1153
    get_first_comic_link = get_a_comicnavbase_comicnavfirst
1154
    get_navi_link = get_link_rel_next
1155
1156
    @classmethod
1157
    def get_comic_info(cls, soup, link):
1158
        """Get information about a particular comics."""
1159
        short_url = soup.find('link', rel='shortlink')['href']
1160
        date_str = soup.find('time', class_='entry-date published').string
1161
        day = string_to_date(date_str, "%B %d, %Y")
1162
        imgs = soup.find('div', id='comic').find_all('img')
1163
        if imgs:
1164
            i = imgs[0]
1165
            title = i['alt']
1166
            assert i['title'] == title
1167
        else:
1168
            title = ""
1169
        return {
1170
            'short_url': short_url,
1171
            'title': title,
1172
            'month': day.month,
1173
            'year': day.year,
1174
            'day': day.day,
1175
            'img': [convert_iri_to_plain_ascii_uri(i['src']) for i in imgs],
1176
        }
1177
1178
1179
class Channelate(GenericNavigableComic):
1180
    """Class to retrieve Channelate comics."""
1181
    name = 'channelate'
1182
    long_name = 'Channelate'
1183
    url = 'http://www.channelate.com'
1184
    get_first_comic_link = get_div_navfirst_a
1185
    get_navi_link = get_link_rel_next
1186
    get_url_from_link = join_cls_url_to_href
1187
1188
    @classmethod
1189
    def get_comic_info(cls, soup, link):
1190
        """Get information about a particular comics."""
1191
        author = soup.find("span", class_="post-author").find("a").string
1192
        date_str = soup.find('span', class_='post-date').string
1193
        day = string_to_date(date_str, '%Y/%m/%d')
1194
        title = soup.find('meta', property='og:title')['content']
1195
        post = soup.find('div', id='comic')
1196
        imgs = post.find_all('img') if post else []
1197
        extra_url = None
1198
        extra_div = soup.find('div', id='extrapanelbutton')
1199
        if extra_div:
1200
            extra_url = extra_div.find('a')['href']
1201
            extra_soup = get_soup_at_url(extra_url)
1202
            extra_imgs = extra_soup.find_all('img', class_='extrapanelimage')
1203
            imgs.extend(extra_imgs)
1204
        return {
1205
            'url_extra': extra_url,
1206
            'title': title,
1207
            'author': author,
1208
            'month': day.month,
1209
            'year': day.year,
1210
            'day': day.day,
1211
            'img': [urljoin_wrapper(cls.url, i['src']) for i in imgs],
1212
        }
1213
1214
1215
class CyanideAndHappiness(GenericNavigableComic):
1216
    """Class to retrieve Cyanide And Happiness comics."""
1217
    name = 'cyanide'
1218
    long_name = 'Cyanide and Happiness'
1219
    url = 'http://explosm.net'
1220
    _categories = ('NSFW', )
1221
    get_url_from_link = join_cls_url_to_href
1222
1223
    @classmethod
1224
    def get_first_comic_link(cls):
1225
        """Get link to first comics."""
1226
        return get_soup_at_url(cls.url).find('a', title='Oldest comic')
1227
1228
    @classmethod
1229
    def get_navi_link(cls, last_soup, next_):
1230
        """Get link to next or previous comic."""
1231
        link = last_soup.find('a', class_='next-comic' if next_ else 'previous-comic ')
1232
        return None if link.get('href') is None else link
1233
1234
    @classmethod
1235
    def get_comic_info(cls, soup, link):
1236
        """Get information about a particular comics."""
1237
        url2 = soup.find('meta', property='og:url')['content']
1238
        num = int(url2.split('/')[-2])
1239
        date_str = soup.find('h3').find('a').string
1240
        day = string_to_date(date_str, '%Y.%m.%d')
1241
        author = soup.find('small', class_="author-credit-name").string
1242
        assert author.startswith('by ')
1243
        author = author[3:]
1244
        imgs = soup.find_all('img', id='main-comic')
1245
        return {
1246
            'num': num,
1247
            'author': author,
1248
            'month': day.month,
1249
            'year': day.year,
1250
            'day': day.day,
1251
            'prefix': '%d-' % num,
1252
            'img': [convert_iri_to_plain_ascii_uri(urljoin_wrapper(cls.url, i['src'])) for i in imgs]
1253
        }
1254
1255
1256
class MrLovenstein(GenericComic):
1257
    """Class to retrieve Mr Lovenstein comics."""
1258
    # Also on https://tapastic.com/series/MrLovenstein
1259
    name = 'mrlovenstein'
1260
    long_name = 'Mr. Lovenstein'
1261
    url = 'http://www.mrlovenstein.com'
1262
1263
    @classmethod
1264
    def get_next_comic(cls, last_comic):
1265
        """Generator to get the next comic. Implementation of GenericComic's abstract method."""
1266
        # TODO: more info from http://www.mrlovenstein.com/archive
1267
        comic_num_re = re.compile('^/comic/([0-9]*)$')
1268
        nums = [int(comic_num_re.match(link['href']).groups()[0])
1269
                for link in get_soup_at_url(cls.url).find_all('a', href=comic_num_re)]
1270
        first, last = min(nums), max(nums)
1271
        if last_comic:
1272
            first = last_comic['num'] + 1
1273
        for num in range(first, last + 1):
1274
            url = urljoin_wrapper(cls.url, '/comic/%d' % num)
1275
            soup = get_soup_at_url(url)
1276
            imgs = list(
1277
                reversed(soup.find_all('img', src=re.compile('^/images/comics/'))))
1278
            description = soup.find('meta', attrs={'name': 'description'})['content']
1279
            yield {
1280
                'url': url,
1281
                'num': num,
1282
                'texts': '  '.join(t for t in (i.get('title') for i in imgs) if t),
1283
                'img': [urljoin_wrapper(url, i['src']) for i in imgs],
1284
                'description': description,
1285
            }
1286
1287
1288
class DinosaurComics(GenericListableComic):
1289
    """Class to retrieve Dinosaur Comics comics."""
1290
    name = 'dinosaur'
1291
    long_name = 'Dinosaur Comics'
1292
    url = 'http://www.qwantz.com'
1293
    get_url_from_archive_element = get_href
1294
    comic_link_re = re.compile('^%s/index.php\\?comic=([0-9]*)$' % url)
1295
1296
    @classmethod
1297
    def get_archive_elements(cls):
1298
        archive_url = urljoin_wrapper(cls.url, 'archive.php')
1299
        # first link is random -> skip it
1300
        return reversed(get_soup_at_url(archive_url).find_all('a', href=cls.comic_link_re)[1:])
1301
1302
    @classmethod
1303
    def get_comic_info(cls, soup, link):
1304
        """Get information about a particular comics."""
1305
        url = cls.get_url_from_archive_element(link)
1306
        num = int(cls.comic_link_re.match(url).groups()[0])
1307
        date_str = link.string
1308
        text = link.next_sibling.string
1309
        day = string_to_date(remove_st_nd_rd_th_from_date(date_str), "%B %d, %Y")
1310
        comic_img_re = re.compile('^%s/comics/' % cls.url)
1311
        img = soup.find('img', src=comic_img_re)
1312
        return {
1313
            'month': day.month,
1314
            'year': day.year,
1315
            'day': day.day,
1316
            'img': [img.get('src')],
1317
            'title': img.get('title'),
1318
            'text': text,
1319
            'num': num,
1320
        }
1321
1322
1323
class ButterSafe(GenericListableComic):
1324
    """Class to retrieve Butter Safe comics."""
1325
    name = 'butter'
1326
    long_name = 'ButterSafe'
1327 View Code Duplication
    url = 'http://buttersafe.com'
0 ignored issues
show
This code seems to be duplicated in your project.
Loading history...
1328
    get_url_from_archive_element = get_href
1329
    comic_link_re = re.compile('^%s/([0-9]*)/([0-9]*)/([0-9]*)/.*' % url)
1330
1331
    @classmethod
1332
    def get_archive_elements(cls):
1333
        archive_url = urljoin_wrapper(cls.url, 'archive/')
1334
        return reversed(get_soup_at_url(archive_url).find_all('a', href=cls.comic_link_re))
1335
1336
    @classmethod
1337
    def get_comic_info(cls, soup, link):
1338
        """Get information about a particular comics."""
1339
        url = cls.get_url_from_archive_element(link)
1340
        title = link.string
1341
        year, month, day = [int(s) for s in cls.comic_link_re.match(url).groups()]
1342
        img = soup.find('div', id='comic').find('img')
1343
        assert img['alt'] == title
1344
        return {
1345
            'title': title,
1346
            'day': day,
1347
            'month': month,
1348
            'year': year,
1349
            'img': [img['src']],
1350
        }
1351
1352
1353
class CalvinAndHobbes(GenericComic):
1354
    """Class to retrieve Calvin and Hobbes comics."""
1355
    # Also on http://www.gocomics.com/calvinandhobbes/
1356
    name = 'calvin'
1357
    long_name = 'Calvin and Hobbes'
1358
    # This is not through any official webpage but eh...
1359
    url = 'http://marcel-oehler.marcellosendos.ch/comics/ch/'
1360
1361
    @classmethod
1362
    def get_next_comic(cls, last_comic):
1363
        """Generator to get the next comic. Implementation of GenericComic's abstract method."""
1364
        last_date = get_date_for_comic(
1365
            last_comic) if last_comic else date(1985, 11, 1)
1366
        link_re = re.compile('^([0-9]*)/([0-9]*)/')
1367
        img_re = re.compile('')
1368
        for link in get_soup_at_url(cls.url).find_all('a', href=link_re):
1369
            url = link['href']
1370
            year, month = link_re.match(url).groups()
1371
            if date(int(year), int(month), 1) + timedelta(days=31) >= last_date:
1372
                img_re = re.compile('^%s%s([0-9]*)' % (year, month))
1373
                month_url = urljoin_wrapper(cls.url, url)
1374
                for img in get_soup_at_url(month_url).find_all('img', src=img_re):
1375
                    img_src = img['src']
1376
                    day = int(img_re.match(img_src).groups()[0])
1377
                    comic_date = date(int(year), int(month), day)
1378
                    if comic_date > last_date:
1379
                        yield {
1380
                            'url': month_url,
1381
                            'year': int(year),
1382
                            'month': int(month),
1383
                            'day': int(day),
1384
                            'img': ['%s%s/%s/%s' % (cls.url, year, month, img_src)],
1385
                        }
1386
                        last_date = comic_date
1387
1388
1389
class AbstruseGoose(GenericListableComic):
1390
    """Class to retrieve AbstruseGoose Comics."""
1391
    name = 'abstruse'
1392
    long_name = 'Abstruse Goose'
1393 View Code Duplication
    url = 'http://abstrusegoose.com'
0 ignored issues
show
This code seems to be duplicated in your project.
Loading history...
1394
    get_url_from_archive_element = get_href
1395
    comic_url_re = re.compile('^%s/([0-9]*)$' % url)
1396
    comic_img_re = re.compile('^%s/strips/.*' % url)
1397
1398
    @classmethod
1399
    def get_archive_elements(cls):
1400
        archive_url = urljoin_wrapper(cls.url, 'archive')
1401
        return get_soup_at_url(archive_url).find_all('a', href=cls.comic_url_re)
1402
1403
    @classmethod
1404
    def get_comic_info(cls, soup, archive_elt):
1405
        comic_url = cls.get_url_from_archive_element(archive_elt)
1406
        num = int(cls.comic_url_re.match(comic_url).groups()[0])
1407
        return {
1408
            'num': num,
1409
            'title': archive_elt.string,
1410
            'img': [soup.find('img', src=cls.comic_img_re)['src']]
1411
        }
1412
1413
1414
class PhDComics(GenericNavigableComic):
1415
    """Class to retrieve PHD Comics."""
1416
    name = 'phd'
1417
    long_name = 'PhD Comics'
1418
    url = 'http://phdcomics.com/comics/archive.php'
1419
    get_url_from_link = join_cls_url_to_href
1420
1421
    @classmethod
1422
    def get_first_comic_link(cls):
1423
        """Get link to first comics."""
1424
        return get_soup_at_url(cls.url).find('img', src='images/first_button.gif').parent
1425
1426
    @classmethod
1427
    def get_navi_link(cls, last_soup, next_):
1428
        """Get link to next or previous comic."""
1429
        img = last_soup.find('img', src='images/next_button.gif' if next_ else 'images/prev_button.gif')
1430
        return None if img is None else img.parent
1431
1432
    @classmethod
1433 View Code Duplication
    def get_comic_info(cls, soup, link):
0 ignored issues
show
This code seems to be duplicated in your project.
Loading history...
1434
        """Get information about a particular comics."""
1435
        date_str = soup.find('font', face='Arial,Helvetica,Geneva,Swiss,SunSans-Regular', color='white').string.strip()
1436
        try:
1437
            day = string_to_date(date_str, '%m/%d/%Y')
1438
        except ValueError:
1439
            print("Invalid date %s" % date_str)
1440
            day = date.today()
1441
        title = soup.find('meta', attrs={'name': 'twitter:title'})['content']
1442
        return {
1443
            'year': day.year,
1444
            'month': day.month,
1445
            'day': day.day,
1446
            'img': [soup.find('img', id='comic')['src']],
1447
            'title': title,
1448
        }
1449
1450
1451
class Octopuns(GenericNavigableComic):
1452
    """Class to retrieve Octopuns comics."""
1453
    # Also on http://octopuns.tumblr.com
1454
    name = 'octopuns'
1455
    long_name = 'Octopuns'
1456
    url = 'http://www.octopuns.net'
1457
1458
    @classmethod
1459
    def get_first_comic_link(cls):
1460
        """Get link to first comics."""
1461
        return get_soup_at_url(cls.url).find('img', src=re.compile('.*/First.png')).parent
1462
1463
    @classmethod
1464
    def get_navi_link(cls, last_soup, next_):
1465
        """Get link to next or previous comic."""
1466
        link = last_soup.find('img', src=re.compile('.*/Next.png' if next_ else '.*/Back.png')).parent
1467
        return None if link.get('href') is None else link
1468
1469
    @classmethod
1470
    def get_comic_info(cls, soup, link):
1471
        """Get information about a particular comics."""
1472
        title = soup.find('h3', class_='post-title entry-title').string
1473
        date_str = soup.find('h2', class_='date-header').string
1474
        day = string_to_date(date_str, "%A, %B %d, %Y")
1475
        imgs = soup.find_all('link', rel='image_src')
1476
        return {
1477
            'img': [i['href'] for i in imgs],
1478
            'title': title,
1479
            'day': day.day,
1480
            'month': day.month,
1481
            'year': day.year,
1482
        }
1483
1484
1485
class Quarktees(GenericNavigableComic):
1486
    """Class to retrieve the Quarktees comics."""
1487
    name = 'quarktees'
1488
    long_name = 'Quarktees'
1489
    url = 'http://www.quarktees.com/blogs/news'
1490
    get_url_from_link = join_cls_url_to_href
1491
    get_first_comic_link = simulate_first_link
1492
    first_url = 'http://www.quarktees.com/blogs/news/12486621-coming-soon'
1493
1494
    @classmethod
1495
    def get_navi_link(cls, last_soup, next_):
1496
        """Get link to next or previous comic."""
1497
        return last_soup.find('a', id='article-next' if next_ else 'article-prev')
1498
1499
    @classmethod
1500
    def get_comic_info(cls, soup, link):
1501
        """Get information about a particular comics."""
1502
        title = soup.find('meta', property='og:title')['content']
1503
        article = soup.find('div', class_='single-article')
1504
        imgs = article.find_all('img')
1505
        return {
1506
            'title': title,
1507
            'img': [urljoin_wrapper(cls.url, i['src']) for i in imgs],
1508
        }
1509
1510
1511
class OverCompensating(GenericNavigableComic):
1512
    """Class to retrieve the Over Compensating comics."""
1513
    name = 'compensating'
1514
    long_name = 'Over Compensating'
1515
    url = 'http://www.overcompensating.com'
1516
    get_url_from_link = join_cls_url_to_href
1517
1518
    @classmethod
1519
    def get_first_comic_link(cls):
1520
        """Get link to first comics."""
1521
        return get_soup_at_url(cls.url).find('a', href=re.compile('comic=1$'))
1522
1523
    @classmethod
1524
    def get_navi_link(cls, last_soup, next_):
1525
        """Get link to next or previous comic."""
1526
        return last_soup.find('a', title='next comic' if next_ else 'go back already')
1527
1528
    @classmethod
1529
    def get_comic_info(cls, soup, link):
1530
        """Get information about a particular comics."""
1531
        img_src_re = re.compile('^/oc/comics/.*')
1532
        comic_num_re = re.compile('.*comic=([0-9]*)$')
1533
        comic_url = cls.get_url_from_link(link)
1534
        num = int(comic_num_re.match(comic_url).groups()[0])
1535
        img = soup.find('img', src=img_src_re)
1536
        return {
1537
            'num': num,
1538
            'img': [urljoin_wrapper(comic_url, img['src'])],
1539
            'title': img.get('title')
1540
        }
1541
1542
1543
class Oglaf(GenericNavigableComic):
1544
    """Class to retrieve Oglaf comics."""
1545
    name = 'oglaf'
1546
    long_name = 'Oglaf [NSFW]'
1547
    url = 'http://oglaf.com'
1548
    _categories = ('NSFW', )
1549
    get_url_from_link = join_cls_url_to_href
1550
1551
    @classmethod
1552
    def get_first_comic_link(cls):
1553
        """Get link to first comics."""
1554
        return get_soup_at_url(cls.url).find("div", id="st").parent
1555
1556
    @classmethod
1557
    def get_navi_link(cls, last_soup, next_):
1558
        """Get link to next or previous comic."""
1559
        div = last_soup.find("div", id="nx" if next_ else "pvs")
1560
        return div.parent if div else None
1561
1562
    @classmethod
1563
    def get_comic_info(cls, soup, link):
1564
        """Get information about a particular comics."""
1565
        title = soup.find('title').string
1566
        title_imgs = soup.find('div', id='tt').find_all('img')
1567
        assert len(title_imgs) == 1
1568
        strip_imgs = soup.find_all('img', id='strip')
1569
        assert len(strip_imgs) == 1
1570
        imgs = title_imgs + strip_imgs
1571
        desc = ' '.join(i['title'] for i in imgs)
1572
        return {
1573
            'title': title,
1574
            'img': [i['src'] for i in imgs],
1575
            'description': desc,
1576
        }
1577
1578
1579
class ScandinaviaAndTheWorld(GenericNavigableComic):
1580
    """Class to retrieve Scandinavia And The World comics."""
1581
    name = 'satw'
1582
    long_name = 'Scandinavia And The World'
1583
    url = 'http://satwcomic.com'
1584
    get_first_comic_link = simulate_first_link
1585
    first_url = 'http://satwcomic.com/sweden-denmark-and-norway'
1586
1587
    @classmethod
1588
    def get_navi_link(cls, last_soup, next_):
1589
        """Get link to next or previous comic."""
1590
        return last_soup.find('a', accesskey='n' if next_ else 'p')
1591
1592
    @classmethod
1593
    def get_comic_info(cls, soup, link):
1594
        """Get information about a particular comics."""
1595
        title = soup.find('meta', attrs={'name': 'twitter:label1'})['content']
1596
        desc = soup.find('meta', property='og:description')['content']
1597
        imgs = soup.find_all('img', itemprop="image")
1598
        return {
1599
            'title': title,
1600
            'description': desc,
1601
            'img': [i['src'] for i in imgs],
1602
        }
1603
1604
1605
class SomethingOfThatIlk(GenericEmptyComic):  # Does not exist anymore
1606
    """Class to retrieve the Something Of That Ilk comics."""
1607
    name = 'somethingofthatilk'
1608
    long_name = 'Something Of That Ilk'
1609
    url = 'http://www.somethingofthatilk.com'
1610
1611
1612
class InfiniteMonkeyBusiness(GenericNavigableComic):
1613
    """Generic class to retrieve InfiniteMonkeyBusiness comics."""
1614
    name = 'monkey'
1615
    long_name = 'Infinite Monkey Business'
1616
    url = 'http://infinitemonkeybusiness.net'
1617
    get_navi_link = get_a_navi_comicnavnext_navinext
1618
    get_first_comic_link = simulate_first_link
1619
    first_url = 'http://infinitemonkeybusiness.net/comic/pillory/'
1620
1621
    @classmethod
1622
    def get_comic_info(cls, soup, link):
1623
        """Get information about a particular comics."""
1624
        title = soup.find('meta', property='og:title')['content']
1625
        imgs = soup.find('div', id='comic').find_all('img')
1626
        return {
1627
            'title': title,
1628
            'img': [i['src'] for i in imgs],
1629
        }
1630
1631
1632
class Wondermark(GenericListableComic):
1633
    """Class to retrieve the Wondermark comics."""
1634
    name = 'wondermark'
1635
    long_name = 'Wondermark'
1636
    url = 'http://wondermark.com'
1637
    get_url_from_archive_element = get_href
1638
1639
    @classmethod
1640
    def get_archive_elements(cls):
1641
        archive_url = urljoin_wrapper(cls.url, 'archive/')
1642
        return reversed(get_soup_at_url(archive_url).find_all('a', rel='bookmark'))
1643
1644
    @classmethod
1645
    def get_comic_info(cls, soup, link):
1646
        """Get information about a particular comics."""
1647
        date_str = soup.find('div', class_='postdate').find('em').string
1648
        day = string_to_date(remove_st_nd_rd_th_from_date(date_str), "%B %d, %Y")
1649
        div = soup.find('div', id='comic')
1650 View Code Duplication
        if div:
0 ignored issues
show
This code seems to be duplicated in your project.
Loading history...
1651
            img = div.find('img')
1652
            img_src = [img['src']]
1653
            alt = img['alt']
1654
            assert alt == img['title']
1655
            title = soup.find('meta', property='og:title')['content']
1656
        else:
1657
            img_src = []
1658
            alt = ''
1659
            title = ''
1660
        return {
1661
            'month': day.month,
1662
            'year': day.year,
1663
            'day': day.day,
1664
            'img': img_src,
1665
            'title': title,
1666
            'alt': alt,
1667
            'tags': ' '.join(t.string for t in soup.find('div', class_='postmeta').find_all('a', rel='tag')),
1668
        }
1669
1670
1671
class WarehouseComic(GenericNavigableComic):
1672
    """Class to retrieve Warehouse Comic comics."""
1673
    name = 'warehouse'
1674
    long_name = 'Warehouse Comic'
1675
    url = 'http://warehousecomic.com'
1676
    get_first_comic_link = get_a_navi_navifirst
1677
    get_navi_link = get_link_rel_next
1678
1679
    @classmethod
1680
    def get_comic_info(cls, soup, link):
1681
        """Get information about a particular comics."""
1682
        title = soup.find('h2', class_='post-title').string
1683
        date_str = soup.find('span', class_='post-date').string
1684
        day = string_to_date(date_str, "%B %d, %Y")
1685
        imgs = soup.find('div', id='comic').find_all('img')
1686
        return {
1687
            'img': [i['src'] for i in imgs],
1688
            'title': title,
1689
            'day': day.day,
1690
            'month': day.month,
1691
            'year': day.year,
1692
        }
1693
1694
1695
class JustSayEh(GenericNavigableComic):
1696
    """Class to retrieve Just Say Eh comics."""
1697
    # Also on http//tapastic.com/series/Just-Say-Eh
1698
    name = 'justsayeh'
1699
    long_name = 'Just Say Eh'
1700
    url = 'http://www.justsayeh.com'
1701
    get_first_comic_link = get_a_navi_navifirst
1702
    get_navi_link = get_a_navi_comicnavnext_navinext
1703
1704
    @classmethod
1705
    def get_comic_info(cls, soup, link):
1706
        """Get information about a particular comics."""
1707
        title = soup.find('h2', class_='post-title').string
1708
        imgs = soup.find("div", id="comic").find_all("img")
1709
        assert all(i['alt'] == i['title'] for i in imgs)
1710
        alt = imgs[0]['alt']
1711
        return {
1712
            'img': [i['src'] for i in imgs],
1713
            'title': title,
1714
            'alt': alt,
1715
        }
1716
1717
1718
class MouseBearComedy(GenericNavigableComic):
1719
    """Class to retrieve Mouse Bear Comedy comics."""
1720
    # Also on http://mousebearcomedy.tumblr.com
1721
    name = 'mousebear'
1722
    long_name = 'Mouse Bear Comedy'
1723
    url = 'http://www.mousebearcomedy.com'
1724
    get_first_comic_link = get_a_navi_navifirst
1725
    get_navi_link = get_a_navi_comicnavnext_navinext
1726
1727
    @classmethod
1728
    def get_comic_info(cls, soup, link):
1729
        """Get information about a particular comics."""
1730
        title = soup.find('h2', class_='post-title').string
1731
        author = soup.find("span", class_="post-author").find("a").string
1732
        date_str = soup.find("span", class_="post-date").string
1733
        day = string_to_date(date_str, '%B %d, %Y')
1734
        imgs = soup.find("div", id="comic").find_all("img")
1735
        assert all(i['alt'] == i['title'] == title for i in imgs)
1736
        return {
1737
            'day': day.day,
1738
            'month': day.month,
1739
            'year': day.year,
1740
            'img': [i['src'] for i in imgs],
1741
            'title': title,
1742
            'author': author,
1743
        }
1744 View Code Duplication
0 ignored issues
show
This code seems to be duplicated in your project.
Loading history...
1745
1746
class BigFootJustice(GenericNavigableComic):
1747
    """Class to retrieve Big Foot Justice comics."""
1748
    # Also on http://tapastic.com/series/bigfoot-justice
1749
    name = 'bigfoot'
1750
    long_name = 'Big Foot Justice'
1751
    url = 'http://bigfootjustice.com'
1752
    get_first_comic_link = get_a_navi_navifirst
1753
    get_navi_link = get_a_navi_comicnavnext_navinext
1754
1755
    @classmethod
1756
    def get_comic_info(cls, soup, link):
1757
        """Get information about a particular comics."""
1758
        imgs = soup.find('div', id='comic').find_all('img')
1759
        assert all(i['title'] == i['alt'] for i in imgs)
1760
        title = ' '.join(i['title'] for i in imgs)
1761
        return {
1762
            'img': [i['src'] for i in imgs],
1763
            'title': title,
1764
        }
1765
1766
1767
class RespawnComic(GenericNavigableComic):
1768
    """Class to retrieve Respawn Comic."""
1769
    # Also on http://respawncomic.tumblr.com
1770
    name = 'respawn'
1771
    long_name = 'Respawn Comic'
1772
    url = 'http://respawncomic.com '
1773
    _categories = ('RESPAWN', )
1774
    get_navi_link = get_a_rel_next
1775
    get_first_comic_link = simulate_first_link
1776
    first_url = 'http://respawncomic.com/comic/c0001/'
1777
1778
    @classmethod
1779
    def get_comic_info(cls, soup, link):
1780
        """Get information about a particular comics."""
1781 View Code Duplication
        title = soup.find('meta', property='og:title')['content']
0 ignored issues
show
This code seems to be duplicated in your project.
Loading history...
1782
        author = soup.find('meta', attrs={'name': 'shareaholic:article_author_name'})['content']
1783
        date_str = soup.find('meta', attrs={'name': 'shareaholic:article_published_time'})['content']
1784
        date_str = date_str[:10]
1785
        day = string_to_date(date_str, "%Y-%m-%d")
1786
        imgs = soup.find_all('meta', property='og:image')
1787
        skip_imgs = {
1788
            'http://respawncomic.com/wp-content/uploads/2016/03/site/HAROLD2.png',
1789
            'http://respawncomic.com/wp-content/uploads/2016/03/site/DEVA.png'
1790
        }
1791
        return {
1792
            'title': title,
1793
            'author': author,
1794
            'day': day.day,
1795
            'month': day.month,
1796
            'year': day.year,
1797
            'img': [i['content'] for i in imgs if i['content'] not in skip_imgs],
1798
        }
1799
1800
1801
class SafelyEndangered(GenericNavigableComic):
1802
    """Class to retrieve Safely Endangered comics."""
1803
    # Also on http://tumblr.safelyendangered.com
1804
    name = 'endangered'
1805
    long_name = 'Safely Endangered'
1806
    url = 'http://www.safelyendangered.com'
1807
    get_navi_link = get_link_rel_next
1808
    get_first_comic_link = simulate_first_link
1809
    first_url = 'http://www.safelyendangered.com/comic/ignored/'
1810 View Code Duplication
0 ignored issues
show
This code seems to be duplicated in your project.
Loading history...
1811
    @classmethod
1812
    def get_comic_info(cls, soup, link):
1813
        """Get information about a particular comics."""
1814
        title = soup.find('h2', class_='post-title').string
1815
        date_str = soup.find('span', class_='post-date').string
1816
        day = string_to_date(date_str, '%B %d, %Y')
1817
        imgs = soup.find('div', id='comic').find_all('img')
1818
        alt = imgs[0]['alt']
1819
        assert all(i['alt'] == i['title'] for i in imgs)
1820
        return {
1821
            'day': day.day,
1822
            'month': day.month,
1823
            'year': day.year,
1824
            'img': [i['src'] for i in imgs],
1825
            'title': title,
1826
            'alt': alt,
1827
        }
1828
1829
1830
class PicturesInBoxes(GenericNavigableComic):
1831
    """Class to retrieve Pictures In Boxes comics."""
1832
    # Also on http://picturesinboxescomic.tumblr.com
1833
    name = 'picturesinboxes'
1834
    long_name = 'Pictures in Boxes'
1835
    url = 'http://www.picturesinboxes.com'
1836
    get_navi_link = get_a_navi_navinext
1837
    get_first_comic_link = simulate_first_link
1838
    first_url = 'http://www.picturesinboxes.com/2013/10/26/tetris/'
1839
1840
    @classmethod
1841
    def get_comic_info(cls, soup, link):
1842
        """Get information about a particular comics."""
1843
        title = soup.find('h2', class_='post-title').string
1844
        author = soup.find("span", class_="post-author").find("a").string
1845
        date_str = soup.find('span', class_='post-date').string
1846
        day = string_to_date(date_str, '%B %d, %Y')
1847
        imgs = soup.find('div', class_='comicpane').find_all('img')
1848
        assert imgs
1849
        assert all(i['title'] == i['alt'] == title for i in imgs)
1850
        return {
1851
            'day': day.day,
1852
            'month': day.month,
1853
            'year': day.year,
1854
            'img': [i['src'] for i in imgs],
1855
            'title': title,
1856
            'author': author,
1857
        }
1858
1859
1860
class Penmen(GenericEmptyComic):
1861
    """Class to retrieve Penmen comics."""
1862
    name = 'penmen'
1863
    long_name = 'Penmen'
1864
    url = 'http://penmen.com'
1865
1866
1867
class TheDoghouseDiaries(GenericNavigableComic):
1868
    """Class to retrieve The Dog House Diaries comics."""
1869
    name = 'doghouse'
1870
    long_name = 'The Dog House Diaries'
1871
    url = 'http://thedoghousediaries.com'
1872
1873
    @classmethod
1874
    def get_first_comic_link(cls):
1875
        """Get link to first comics."""
1876
        return get_soup_at_url(cls.url).find('a', id='firstlink')
1877
1878
    @classmethod
1879
    def get_navi_link(cls, last_soup, next_):
1880
        """Get link to next or previous comic."""
1881
        return last_soup.find('a', id='nextlink' if next_ else 'previouslink')
1882
1883
    @classmethod
1884
    def get_comic_info(cls, soup, link):
1885
        """Get information about a particular comics."""
1886
        comic_img_re = re.compile('^dhdcomics/.*')
1887
        img = soup.find('img', src=comic_img_re)
1888
        comic_url = cls.get_url_from_link(link)
1889
        return {
1890
            'title': soup.find('h2', id='titleheader').string,
1891
            'title2': soup.find('div', id='subtext').string,
1892
            'alt': img.get('title'),
1893
            'img': [urljoin_wrapper(comic_url, img['src'].strip())],
1894
            'num': int(comic_url.split('/')[-1]),
1895
        }
1896
1897
1898
class InvisibleBread(GenericListableComic):
1899
    """Class to retrieve Invisible Bread comics."""
1900
    # Also on http://www.gocomics.com/invisible-bread
1901
    name = 'invisiblebread'
1902
    long_name = 'Invisible Bread'
1903
    url = 'http://invisiblebread.com'
1904
1905
    @classmethod
1906
    def get_archive_elements(cls):
1907
        archive_url = urljoin_wrapper(cls.url, 'archives/')
1908
        return reversed(get_soup_at_url(archive_url).find_all('td', class_='archive-title'))
1909
1910
    @classmethod
1911
    def get_url_from_archive_element(cls, td):
1912
        return td.find('a')['href']
1913
1914
    @classmethod
1915
    def get_comic_info(cls, soup, td):
1916
        """Get information about a particular comics."""
1917
        url = cls.get_url_from_archive_element(td)
1918
        title = td.find('a').string
1919
        month_and_day = td.previous_sibling.string
1920
        link_re = re.compile('^%s/([0-9]+)/' % cls.url)
1921
        year = link_re.match(url).groups()[0]
1922
        date_str = month_and_day + ' ' + year
1923
        day = string_to_date(date_str, '%b %d %Y')
1924
        imgs = [soup.find('div', id='comic').find('img')]
1925
        assert len(imgs) == 1
1926
        assert all(i['title'] == i['alt'] == title for i in imgs)
1927
        return {
1928
            'month': day.month,
1929
            'year': day.year,
1930
            'day': day.day,
1931
            'img': [urljoin_wrapper(cls.url, i['src']) for i in imgs],
1932 View Code Duplication
            'title': title,
0 ignored issues
show
This code seems to be duplicated in your project.
Loading history...
1933
        }
1934
1935
1936
class DiscoBleach(GenericEmptyComic):  # Does not work anymore
1937
    """Class to retrieve Disco Bleach Comics."""
1938
    name = 'discobleach'
1939
    long_name = 'Disco Bleach'
1940
    url = 'http://discobleach.com'
1941
1942
1943
class TubeyToons(GenericEmptyComic):  # Does not work anymore
1944
    """Class to retrieve TubeyToons comics."""
1945
    # Also on http://tapastic.com/series/Tubey-Toons
1946
    # Also on http://tubeytoons.tumblr.com
1947
    name = 'tubeytoons'
1948
    long_name = 'Tubey Toons'
1949
    url = 'http://tubeytoons.com'
1950
    _categories = ('TUNEYTOONS', )
1951
1952
1953
class CompletelySeriousComics(GenericNavigableComic):
1954
    """Class to retrieve Completely Serious comics."""
1955
    name = 'completelyserious'
1956
    long_name = 'Completely Serious Comics'
1957
    url = 'http://completelyseriouscomics.com'
1958
    get_first_comic_link = get_a_navi_navifirst
1959
    get_navi_link = get_a_navi_navinext
1960
1961
    @classmethod
1962
    def get_comic_info(cls, soup, link):
1963
        """Get information about a particular comics."""
1964
        title = soup.find('h2', class_='post-title').string
1965
        author = soup.find('span', class_='post-author').contents[1].string
1966
        date_str = soup.find('span', class_='post-date').string
1967
        day = string_to_date(date_str, '%B %d, %Y')
1968
        imgs = soup.find('div', class_='comicpane').find_all('img')
1969
        assert imgs
1970
        alt = imgs[0]['title']
1971
        assert all(i['title'] == i['alt'] == alt for i in imgs)
1972
        return {
1973
            'month': day.month,
1974
            'year': day.year,
1975
            'day': day.day,
1976
            'img': [i['src'] for i in imgs],
1977
            'title': title,
1978
            'alt': alt,
1979
            'author': author,
1980
        }
1981
1982
1983
class PoorlyDrawnLines(GenericListableComic):
1984
    """Class to retrieve Poorly Drawn Lines comics."""
1985
    # Also on http://pdlcomics.tumblr.com
1986
    name = 'poorlydrawn'
1987 View Code Duplication
    long_name = 'Poorly Drawn Lines'
0 ignored issues
show
This code seems to be duplicated in your project.
Loading history...
1988
    url = 'http://poorlydrawnlines.com'
1989
    _categories = ('POORLYDRAWN', )
1990
    get_url_from_archive_element = get_href
1991
1992
    @classmethod
1993
    def get_comic_info(cls, soup, link):
1994
        """Get information about a particular comics."""
1995
        imgs = soup.find('div', class_='post').find_all('img')
1996
        assert len(imgs) <= 1
1997
        return {
1998
            'img': [i['src'] for i in imgs],
1999
            'title': imgs[0].get('title', "") if imgs else "",
2000
        }
2001
2002
    @classmethod
2003
    def get_archive_elements(cls):
2004
        archive_url = urljoin_wrapper(cls.url, 'archive')
2005
        url_re = re.compile('^%s/comic/.' % cls.url)
2006
        return reversed(get_soup_at_url(archive_url).find_all('a', href=url_re))
2007
2008
2009
class LoadingComics(GenericNavigableComic):
2010
    """Class to retrieve Loading Artist comics."""
2011
    name = 'loadingartist'
2012
    long_name = 'Loading Artist'
2013
    url = 'http://www.loadingartist.com/latest'
2014
2015
    @classmethod
2016
    def get_first_comic_link(cls):
2017
        """Get link to first comics."""
2018
        return get_soup_at_url(cls.url).find('a', title="First")
2019 View Code Duplication
0 ignored issues
show
This code seems to be duplicated in your project.
Loading history...
2020
    @classmethod
2021
    def get_navi_link(cls, last_soup, next_):
2022
        """Get link to next or previous comic."""
2023
        return last_soup.find('a', title='Next' if next_ else 'Previous')
2024
2025
    @classmethod
2026
    def get_comic_info(cls, soup, link):
2027
        """Get information about a particular comics."""
2028
        title = soup.find('h1').string
2029
        date_str = soup.find('span', class_='date').string.strip()
2030
        day = string_to_date(date_str, "%B %d, %Y")
2031
        imgs = soup.find('div', class_='comic').find_all('img', alt='', title='')
2032
        return {
2033
            'title': title,
2034
            'img': [i['src'] for i in imgs],
2035
            'month': day.month,
2036
            'year': day.year,
2037
            'day': day.day,
2038
        }
2039
2040
2041
class ChuckleADuck(GenericNavigableComic):
2042
    """Class to retrieve Chuckle-A-Duck comics."""
2043
    name = 'chuckleaduck'
2044
    long_name = 'Chuckle-A-duck'
2045
    url = 'http://chuckleaduck.com'
2046
    get_first_comic_link = get_div_navfirst_a
2047
    get_navi_link = get_link_rel_next
2048
2049
    @classmethod
2050
    def get_comic_info(cls, soup, link):
2051
        """Get information about a particular comics."""
2052
        date_str = soup.find('span', class_='post-date').string
2053
        day = string_to_date(remove_st_nd_rd_th_from_date(date_str), "%B %d, %Y")
2054
        author = soup.find('span', class_='post-author').string
2055
        div = soup.find('div', id='comic')
2056
        imgs = div.find_all('img') if div else []
2057
        title = imgs[0]['title'] if imgs else ""
2058
        assert all(i['title'] == i['alt'] == title for i in imgs)
2059
        return {
2060
            'month': day.month,
2061
            'year': day.year,
2062
            'day': day.day,
2063
            'img': [i['src'] for i in imgs],
2064
            'title': title,
2065
            'author': author,
2066
        }
2067
2068
2069
class DepressedAlien(GenericNavigableComic):
2070
    """Class to retrieve Depressed Alien Comics."""
2071
    name = 'depressedalien'
2072
    long_name = 'Depressed Alien'
2073
    url = 'http://depressedalien.com'
2074
    get_url_from_link = join_cls_url_to_href
2075
2076
    @classmethod
2077
    def get_first_comic_link(cls):
2078
        """Get link to first comics."""
2079
        return get_soup_at_url(cls.url).find('img', attrs={'name': 'beginArrow'}).parent
2080
2081
    @classmethod
2082
    def get_navi_link(cls, last_soup, next_):
2083
        """Get link to next or previous comic."""
2084
        return last_soup.find('img', attrs={'name': 'rightArrow' if next_ else 'leftArrow'}).parent
2085
2086
    @classmethod
2087
    def get_comic_info(cls, soup, link):
2088
        """Get information about a particular comics."""
2089
        title = soup.find('meta', attrs={'name': 'twitter:title'})['content']
2090
        imgs = soup.find_all('meta', property='og:image')
2091
        return {
2092
            'title': title,
2093
            'img': [i['content'] for i in imgs],
2094
        }
2095
2096
2097
class ThingsInSquares(GenericListableComic):
2098
    """Class to retrieve Things In Squares comics."""
2099
    # This can be retrieved in other languages
2100
    # Also on https://tapastic.com/series/Things-in-Squares
2101
    name = 'squares'
2102
    long_name = 'Things in squares'
2103
    url = 'http://www.thingsinsquares.com'
2104
2105
    @classmethod
2106
    def get_comic_info(cls, soup, tr):
2107
        """Get information about a particular comics."""
2108
        _, td2, td3 = tr.find_all('td')
2109
        a = td2.find('a')
2110
        date_str = td3.string
2111
        day = string_to_date(date_str, "%m.%d.%y")
2112
        title = a.string
2113
        title2 = soup.find('meta', property='og:title')['content']
2114
        desc = soup.find('meta', property='og:description')
2115
        description = desc['content'] if desc else ''
2116
        tags = ' '.join(t['content'] for t in soup.find_all('meta', property='article:tag'))
2117
        imgs = soup.find('div', class_='entry-content').find_all('img')
2118
        return {
2119 View Code Duplication
            'day': day.day,
0 ignored issues
show
This code seems to be duplicated in your project.
Loading history...
2120
            'month': day.month,
2121
            'year': day.year,
2122
            'title': title,
2123
            'title2': title2,
2124
            'description': description,
2125
            'tags': tags,
2126
            'img': [i['src'] for i in imgs],
2127
            'alt': ' '.join(i['alt'] for i in imgs),
2128
        }
2129
2130
    @classmethod
2131
    def get_url_from_archive_element(cls, tr):
2132
        _, td2, td3 = tr.find_all('td')
2133
        return td2.find('a')['href']
2134
2135
    @classmethod
2136
    def get_archive_elements(cls):
2137
        archive_url = urljoin_wrapper(cls.url, 'archive-2')
2138
        return reversed(get_soup_at_url(archive_url).find('tbody').find_all('tr'))
2139
2140
2141
class HappleTea(GenericNavigableComic):
2142
    """Class to retrieve Happle Tea Comics."""
2143
    name = 'happletea'
2144
    long_name = 'Happle Tea'
2145
    url = 'http://www.happletea.com'
2146
    get_first_comic_link = get_a_navi_navifirst
2147
    get_navi_link = get_link_rel_next
2148
2149
    @classmethod
2150
    def get_comic_info(cls, soup, link):
2151
        """Get information about a particular comics."""
2152
        imgs = soup.find('div', id='comic').find_all('img')
2153
        post = soup.find('div', class_='post-content')
2154
        title = post.find('h2', class_='post-title').string
2155
        author = post.find('a', rel='author').string
2156
        date_str = post.find('span', class_='post-date').string
2157
        day = string_to_date(date_str, "%B %d, %Y")
2158
        assert all(i['alt'] == i['title'] for i in imgs)
2159
        return {
2160
            'title': title,
2161
            'img': [i['src'] for i in imgs],
2162
            'alt': ''.join(i['alt'] for i in imgs),
2163
            'month': day.month,
2164
            'year': day.year,
2165
            'day': day.day,
2166
            'author': author,
2167
        }
2168
2169
2170
class FatAwesomeComics(GenericNavigableComic):
2171
    """Class to retrieve Fat Awesome Comics."""
2172
    # Also on http://fatawesomecomedy.tumblr.com
2173
    name = 'fatawesome'
2174
    long_name = 'Fat Awesome'
2175
    url = 'http://fatawesome.com/comics'
2176
    get_navi_link = get_a_rel_next
2177
    get_first_comic_link = simulate_first_link
2178
    first_url = 'http://fatawesome.com/shortbus/'
2179
2180
    @classmethod
2181
    def get_comic_info(cls, soup, link):
2182
        """Get information about a particular comics."""
2183
        title = soup.find('meta', attrs={'name': 'twitter:title'})['content']
2184
        description = soup.find('meta', attrs={'name': 'description'})['content']
2185
        tags_prop = soup.find('meta', property='article:tag')
2186
        tags = tags_prop['content'] if tags_prop else ""
2187
        date_str = soup.find('meta', property='article:published_time')['content'][:10]
2188
        day = string_to_date(date_str, "%Y-%m-%d")
2189
        imgs = soup.find_all('img', attrs={'data-recalc-dims': "1"})
2190
        assert len(imgs) == 1
2191
        return {
2192
            'title': title,
2193
            'description': description,
2194
            'tags': tags,
2195
            'alt': "".join(i['alt'] for i in imgs),
2196
            'img': [i['src'].rsplit('?', 1)[0] for i in imgs],
2197
            'month': day.month,
2198
            'year': day.year,
2199
            'day': day.day,
2200
        }
2201
2202
2203
class AnythingComic(GenericListableComic):
2204
    """Class to retrieve Anything Comics."""
2205
    # Also on http://tapastic.com/series/anything
2206
    name = 'anythingcomic'
2207
    long_name = 'Anything Comic'
2208
    url = 'http://www.anythingcomic.com'
2209
2210
    @classmethod
2211
    def get_archive_elements(cls):
2212
        archive_url = urljoin_wrapper(cls.url, 'archive/')
2213
        # The first 2 <tr>'s do not correspond to comics
2214
        return get_soup_at_url(archive_url).find('table', id='chapter_table').find_all('tr')[2:]
2215
2216
    @classmethod
2217
    def get_url_from_archive_element(cls, tr):
2218
        """Get url corresponding to an archive element."""
2219
        td_num, td_comic, td_date, _ = tr.find_all('td')
2220
        link = td_comic.find('a')
2221
        return urljoin_wrapper(cls.url, link['href'])
2222
2223
    @classmethod
2224
    def get_comic_info(cls, soup, tr):
2225
        """Get information about a particular comics."""
2226
        td_num, td_comic, td_date, _ = tr.find_all('td')
2227
        num = int(td_num.string)
2228
        link = td_comic.find('a')
2229
        title = link.string
2230
        imgs = soup.find_all('img', id='comic_image')
2231
        day = string_to_date(td_date.string, '%d %b %Y %I:%M %p')
2232
        assert len(imgs) == 1
2233
        assert all(i.get('alt') == i.get('title') for i in imgs)
2234
        return {
2235
            'num': num,
2236
            'title': title,
2237
            'alt': imgs[0].get('alt', ''),
2238
            'img': [i['src'] for i in imgs],
2239
            'month': day.month,
2240
            'year': day.year,
2241
            'day': day.day,
2242
        }
2243
2244
2245
class LonnieMillsap(GenericNavigableComic):
2246
    """Class to retrieve Lonnie Millsap's comics."""
2247
    name = 'millsap'
2248
    long_name = 'Lonnie Millsap'
2249
    url = 'http://www.lonniemillsap.com'
2250
    get_navi_link = get_link_rel_next
2251
    get_first_comic_link = simulate_first_link
2252
    first_url = 'http://www.lonniemillsap.com/?p=42'
2253
2254
    @classmethod
2255
    def get_comic_info(cls, soup, link):
2256
        """Get information about a particular comics."""
2257
        title = soup.find('h2', class_='post-title').string
2258
        post = soup.find('div', class_='post-content')
2259
        author = post.find("span", class_="post-author").find("a").string
2260
        date_str = post.find("span", class_="post-date").string
2261
        day = string_to_date(date_str, "%B %d, %Y")
2262
        imgs = post.find("div", class_="entry").find_all("img")
2263
        return {
2264
            'title': title,
2265
            'author': author,
2266
            'img': [i['src'] for i in imgs],
2267
            'month': day.month,
2268
            'year': day.year,
2269
            'day': day.day,
2270
        }
2271
2272
2273
class LinsEditions(GenericNavigableComic):
2274
    """Class to retrieve L.I.N.S. Editions comics."""
2275
    # Also on http://linscomics.tumblr.com
2276
    name = 'lins'
2277
    long_name = 'L.I.N.S. Editions'
2278
    url = 'https://linsedition.com'
2279
    _categories = ('LINS', )
2280
    get_navi_link = get_link_rel_next
2281
    get_first_comic_link = simulate_first_link
2282
    first_url = 'https://linsedition.com/2011/09/07/l-i-n-s/'
2283
2284
    @classmethod
2285
    def get_comic_info(cls, soup, link):
2286
        """Get information about a particular comics."""
2287
        title = soup.find('meta', property='og:title')['content']
2288
        imgs = soup.find_all('meta', property='og:image')
2289
        date_str = soup.find('meta', property='article:published_time')['content'][:10]
2290
        day = string_to_date(date_str, "%Y-%m-%d")
2291
        return {
2292
            'title': title,
2293
            'img': [i['content'] for i in imgs],
2294
            'month': day.month,
2295
            'year': day.year,
2296
            'day': day.day,
2297
        }
2298
2299
2300
class ThorsThundershack(GenericNavigableComic):
2301
    """Class to retrieve Thor's Thundershack comics."""
2302
    # Also on http://tapastic.com/series/Thors-Thundershac
2303
    name = 'thor'
2304
    long_name = 'Thor\'s Thundershack'
2305
    url = 'http://www.thorsthundershack.com'
2306
    _categories = ('THOR', )
2307
    get_url_from_link = join_cls_url_to_href
2308
2309
    @classmethod
2310
    def get_first_comic_link(cls):
2311
        """Get link to first comics."""
2312
        return get_soup_at_url(cls.url).find('a', class_='first navlink')
2313
2314
    @classmethod
2315
    def get_navi_link(cls, last_soup, next_):
2316
        """Get link to next or previous comic."""
2317
        for link in last_soup.find_all('a', rel='next' if next_ else 'prev'):
2318
            if link['href'] != '/comic':
2319
                return link
2320
        return None
2321 View Code Duplication
0 ignored issues
show
This code seems to be duplicated in your project.
Loading history...
2322
    @classmethod
2323
    def get_comic_info(cls, soup, link):
2324
        """Get information about a particular comics."""
2325
        title = soup.find('meta', attrs={'name': 'description'})["content"]
2326
        description = soup.find('div', itemprop='articleBody').text
2327
        author = soup.find('span', itemprop='author copyrightHolder').string
2328
        imgs = soup.find_all('img', itemprop='image')
2329
        assert all(i['title'] == i['alt'] for i in imgs)
2330
        alt = imgs[0]['alt'] if imgs else ""
2331
        date_str = soup.find('time', itemprop='datePublished')["datetime"]
2332
        day = string_to_date(date_str, "%Y-%m-%d %H:%M:%S")
2333
        return {
2334
            'img': [urljoin_wrapper(cls.url, i['src']) for i in imgs],
2335
            'month': day.month,
2336
            'year': day.year,
2337
            'day': day.day,
2338
            'author': author,
2339
            'title': title,
2340
            'alt': alt,
2341
            'description': description,
2342
        }
2343
2344
2345
class GerbilWithAJetpack(GenericNavigableComic):
2346
    """Class to retrieve GerbilWithAJetpack comics."""
2347
    name = 'gerbil'
2348
    long_name = 'Gerbil With A Jetpack'
2349
    url = 'http://gerbilwithajetpack.com'
2350
    get_first_comic_link = get_a_navi_navifirst
2351
    get_navi_link = get_a_rel_next
2352
2353
    @classmethod
2354
    def get_comic_info(cls, soup, link):
2355
        """Get information about a particular comics."""
2356
        title = soup.find('h2', class_='post-title').string
2357
        author = soup.find("span", class_="post-author").find("a").string
2358
        date_str = soup.find("span", class_="post-date").string
2359
        day = string_to_date(date_str, "%B %d, %Y")
2360
        imgs = soup.find("div", id="comic").find_all("img")
2361
        alt = imgs[0]['alt']
2362
        assert all(i['alt'] == i['title'] == alt for i in imgs)
2363
        return {
2364
            'img': [i['src'] for i in imgs],
2365
            'title': title,
2366
            'alt': alt,
2367
            'author': author,
2368
            'day': day.day,
2369
            'month': day.month,
2370
            'year': day.year
2371
        }
2372
2373
2374
class EveryDayBlues(GenericNavigableComic):
2375
    """Class to retrieve EveryDayBlues Comics."""
2376
    name = "blues"
2377
    long_name = "Every Day Blues"
2378 View Code Duplication
    url = "http://everydayblues.net"
0 ignored issues
show
This code seems to be duplicated in your project.
Loading history...
2379
    get_first_comic_link = get_a_navi_navifirst
2380
    get_navi_link = get_link_rel_next
2381
2382
    @classmethod
2383
    def get_comic_info(cls, soup, link):
2384
        """Get information about a particular comics."""
2385
        title = soup.find("h2", class_="post-title").string
2386
        author = soup.find("span", class_="post-author").find("a").string
2387
        date_str = soup.find("span", class_="post-date").string
2388
        day = string_to_date(date_str, "%d. %B %Y", "de_DE.utf8")
2389
        imgs = soup.find("div", id="comic").find_all("img")
2390
        assert all(i['alt'] == i['title'] == title for i in imgs)
2391
        assert len(imgs) <= 1
2392
        return {
2393
            'img': [i['src'] for i in imgs],
2394
            'title': title,
2395
            'author': author,
2396
            'day': day.day,
2397
            'month': day.month,
2398
            'year': day.year
2399
        }
2400
2401
2402
class BiterComics(GenericNavigableComic):
2403
    """Class to retrieve Biter Comics."""
2404
    name = "biter"
2405
    long_name = "Biter Comics"
2406
    url = "http://www.bitercomics.com"
2407
    get_first_comic_link = get_a_navi_navifirst
2408
    get_navi_link = get_link_rel_next
2409
2410
    @classmethod
2411
    def get_comic_info(cls, soup, link):
2412
        """Get information about a particular comics."""
2413
        title = soup.find("h1", class_="entry-title").string
2414
        author = soup.find("span", class_="author vcard").find("a").string
2415
        date_str = soup.find("span", class_="entry-date").string
2416
        day = string_to_date(date_str, "%B %d, %Y")
2417
        imgs = soup.find("div", id="comic").find_all("img")
2418
        assert all(i['alt'] == i['title'] for i in imgs)
2419
        assert len(imgs) == 1
2420
        alt = imgs[0]['alt']
2421
        return {
2422
            'img': [i['src'] for i in imgs],
2423
            'title': title,
2424
            'alt': alt,
2425
            'author': author,
2426
            'day': day.day,
2427
            'month': day.month,
2428
            'year': day.year
2429
        }
2430
2431
2432
class TheAwkwardYeti(GenericNavigableComic):
2433
    """Class to retrieve The Awkward Yeti comics."""
2434
    # Also on http://www.gocomics.com/the-awkward-yeti
2435
    # Also on http://larstheyeti.tumblr.com
2436
    # Also on https://tapastic.com/series/TheAwkwardYeti
2437
    name = 'yeti'
2438
    long_name = 'The Awkward Yeti'
2439
    url = 'http://theawkwardyeti.com'
2440
    _categories = ('YETI', )
2441
    get_first_comic_link = get_a_navi_navifirst
2442
    get_navi_link = get_link_rel_next
2443
2444
    @classmethod
2445
    def get_comic_info(cls, soup, link):
2446
        """Get information about a particular comics."""
2447
        title = soup.find('h2', class_='post-title').string
2448
        date_str = soup.find("span", class_="post-date").string
2449
        day = string_to_date(date_str, "%B %d, %Y")
2450
        imgs = soup.find("div", id="comic").find_all("img")
2451
        assert all(idx > 0 or i['alt'] == i['title'] for idx, i in enumerate(imgs))
2452
        return {
2453
            'img': [i['src'] for i in imgs],
2454
            'title': title,
2455
            'day': day.day,
2456
            'month': day.month,
2457
            'year': day.year
2458
        }
2459
2460
2461
class PleasantThoughts(GenericNavigableComic):
2462
    """Class to retrieve Pleasant Thoughts comics."""
2463
    name = 'pleasant'
2464
    long_name = 'Pleasant Thoughts'
2465
    url = 'http://pleasant-thoughts.com'
2466
    get_first_comic_link = get_a_comicnavbase_comicnavfirst
2467
    get_navi_link = get_link_rel_next
2468
2469
    @classmethod
2470
    def get_comic_info(cls, soup, link):
2471
        """Get information about a particular comics."""
2472
        post = soup.find('div', class_='post-content')
2473
        title = post.find('h2', class_='post-title').string
2474
        imgs = post.find("div", class_="entry").find_all("img")
2475
        return {
2476
            'title': title,
2477
            'img': [i['src'] for i in imgs],
2478
        }
2479
2480
2481
class MisterAndMe(GenericNavigableComic):
2482
    """Class to retrieve Mister & Me Comics."""
2483
    # Also on http://www.gocomics.com/mister-and-me
2484
    # Also on https://tapastic.com/series/Mister-and-Me
2485
    name = 'mister'
2486
    long_name = 'Mister & Me'
2487
    url = 'http://www.mister-and-me.com'
2488 View Code Duplication
    get_first_comic_link = get_a_comicnavbase_comicnavfirst
0 ignored issues
show
This code seems to be duplicated in your project.
Loading history...
2489
    get_navi_link = get_link_rel_next
2490
2491
    @classmethod
2492
    def get_comic_info(cls, soup, link):
2493
        """Get information about a particular comics."""
2494
        title = soup.find('h2', class_='post-title').string
2495
        author = soup.find("span", class_="post-author").find("a").string
2496
        date_str = soup.find("span", class_="post-date").string
2497
        day = string_to_date(date_str, "%B %d, %Y")
2498
        imgs = soup.find("div", id="comic").find_all("img")
2499
        assert all(i['alt'] == i['title'] for i in imgs)
2500
        assert len(imgs) <= 1
2501
        alt = imgs[0]['alt'] if imgs else ""
2502
        return {
2503
            'img': [i['src'] for i in imgs],
2504
            'title': title,
2505
            'alt': alt,
2506
            'author': author,
2507
            'day': day.day,
2508
            'month': day.month,
2509
            'year': day.year
2510
        }
2511
2512
2513
class LastPlaceComics(GenericNavigableComic):
2514
    """Class to retrieve Last Place Comics."""
2515
    name = 'lastplace'
2516
    long_name = 'Last Place Comics'
2517
    url = "http://lastplacecomics.com"
2518 View Code Duplication
    get_first_comic_link = get_a_comicnavbase_comicnavfirst
0 ignored issues
show
This code seems to be duplicated in your project.
Loading history...
2519
    get_navi_link = get_link_rel_next
2520
2521
    @classmethod
2522
    def get_comic_info(cls, soup, link):
2523
        """Get information about a particular comics."""
2524
        title = soup.find('h2', class_='post-title').string
2525
        author = soup.find("span", class_="post-author").find("a").string
2526
        date_str = soup.find("span", class_="post-date").string
2527
        day = string_to_date(date_str, "%B %d, %Y")
2528
        imgs = soup.find("div", id="comic").find_all("img")
2529
        assert all(i['alt'] == i['title'] for i in imgs)
2530
        assert len(imgs) <= 1
2531
        alt = imgs[0]['alt'] if imgs else ""
2532
        return {
2533
            'img': [i['src'] for i in imgs],
2534
            'title': title,
2535
            'alt': alt,
2536
            'author': author,
2537
            'day': day.day,
2538
            'month': day.month,
2539
            'year': day.year
2540
        }
2541
2542
2543
class TalesOfAbsurdity(GenericNavigableComic):
2544
    """Class to retrieve Tales Of Absurdity comics."""
2545
    # Also on http://tapastic.com/series/Tales-Of-Absurdity
2546
    # Also on http://talesofabsurdity.tumblr.com
2547
    name = 'absurdity'
2548
    long_name = 'Tales of Absurdity'
2549
    url = 'http://talesofabsurdity.com'
2550
    _categories = ('ABSURDITY', )
2551
    get_first_comic_link = get_a_navi_navifirst
2552
    get_navi_link = get_a_navi_comicnavnext_navinext
2553
2554
    @classmethod
2555
    def get_comic_info(cls, soup, link):
2556
        """Get information about a particular comics."""
2557
        title = soup.find('h2', class_='post-title').string
2558
        author = soup.find("span", class_="post-author").find("a").string
2559
        date_str = soup.find("span", class_="post-date").string
2560
        day = string_to_date(date_str, "%B %d, %Y")
2561
        imgs = soup.find("div", id="comic").find_all("img")
2562
        assert all(i['alt'] == i['title'] for i in imgs)
2563
        alt = imgs[0]['alt'] if imgs else ""
2564
        return {
2565
            'img': [i['src'] for i in imgs],
2566
            'title': title,
2567
            'alt': alt,
2568
            'author': author,
2569
            'day': day.day,
2570
            'month': day.month,
2571
            'year': day.year
2572
        }
2573
2574
2575
class EndlessOrigami(GenericNavigableComic):
2576
    """Class to retrieve Endless Origami Comics."""
2577
    name = "origami"
2578
    long_name = "Endless Origami"
2579
    url = "http://endlessorigami.com"
2580
    get_first_comic_link = get_a_navi_navifirst
2581
    get_navi_link = get_link_rel_next
2582
2583
    @classmethod
2584
    def get_comic_info(cls, soup, link):
2585
        """Get information about a particular comics."""
2586
        title = soup.find('h2', class_='post-title').string
2587
        author = soup.find("span", class_="post-author").find("a").string
2588
        date_str = soup.find("span", class_="post-date").string
2589
        day = string_to_date(date_str, "%B %d, %Y")
2590
        imgs = soup.find("div", id="comic").find_all("img")
2591
        assert all(i['alt'] == i['title'] for i in imgs)
2592
        alt = imgs[0]['alt'] if imgs else ""
2593
        return {
2594
            'img': [i['src'] for i in imgs],
2595
            'title': title,
2596
            'alt': alt,
2597
            'author': author,
2598
            'day': day.day,
2599
            'month': day.month,
2600
            'year': day.year
2601
        }
2602
2603
2604
class PlanC(GenericNavigableComic):
2605
    """Class to retrieve Plan C comics."""
2606
    name = 'planc'
2607
    long_name = 'Plan C'
2608
    url = 'http://www.plancomic.com'
2609
    get_first_comic_link = get_a_navi_navifirst
2610
    get_navi_link = get_a_navi_comicnavnext_navinext
2611
2612
    @classmethod
2613
    def get_comic_info(cls, soup, link):
2614
        """Get information about a particular comics."""
2615
        title = soup.find('h2', class_='post-title').string
2616
        date_str = soup.find("span", class_="post-date").string
2617
        day = string_to_date(date_str, "%B %d, %Y")
2618
        imgs = soup.find('div', id='comic').find_all('img')
2619
        return {
2620
            'title': title,
2621
            'img': [i['src'] for i in imgs],
2622
            'month': day.month,
2623
            'year': day.year,
2624
            'day': day.day,
2625
        }
2626 View Code Duplication
0 ignored issues
show
This code seems to be duplicated in your project.
Loading history...
2627
2628
class BuniComic(GenericNavigableComic):
2629
    """Class to retrieve Buni Comics."""
2630
    name = 'buni'
2631
    long_name = 'BuniComics'
2632
    url = 'http://www.bunicomic.com'
2633
    get_first_comic_link = get_a_comicnavbase_comicnavfirst
2634
    get_navi_link = get_link_rel_next
2635
2636
    @classmethod
2637
    def get_comic_info(cls, soup, link):
2638
        """Get information about a particular comics."""
2639
        imgs = soup.find('div', id='comic').find_all('img')
2640
        assert all(i['alt'] == i['title'] for i in imgs)
2641
        assert len(imgs) == 1
2642
        return {
2643
            'img': [i['src'] for i in imgs],
2644
            'title': imgs[0]['title'],
2645
        }
2646
2647
2648
class GenericCommitStrip(GenericNavigableComic):
2649
    """Generic class to retrieve Commit Strips in different languages."""
2650
    get_navi_link = get_a_rel_next
2651
    get_first_comic_link = simulate_first_link
2652
    first_url = NotImplemented
2653
2654
    @classmethod
2655
    def get_comic_info(cls, soup, link):
2656
        """Get information about a particular comics."""
2657
        desc = soup.find('meta', property='og:description')['content']
2658
        title = soup.find('meta', property='og:title')['content']
2659 View Code Duplication
        imgs = soup.find('div', class_='entry-content').find_all('img')
0 ignored issues
show
This code seems to be duplicated in your project.
Loading history...
2660
        title2 = ' '.join(i.get('title', '') for i in imgs)
2661
        return {
2662
            'title': title,
2663
            'title2': title2,
2664
            'description': desc,
2665
            'img': [urljoin_wrapper(cls.url, convert_iri_to_plain_ascii_uri(i['src'])) for i in imgs],
2666
        }
2667
2668
2669
class CommitStripFr(GenericCommitStrip):
2670
    """Class to retrieve Commit Strips in French."""
2671
    name = 'commit_fr'
2672
    long_name = 'Commit Strip (Fr)'
2673
    url = 'http://www.commitstrip.com/fr'
2674
    _categories = ('FRANCAIS', )
2675
    first_url = 'http://www.commitstrip.com/fr/2012/02/22/interview/'
2676
2677
2678
class CommitStripEn(GenericCommitStrip):
2679
    """Class to retrieve Commit Strips in English."""
2680
    name = 'commit_en'
2681
    long_name = 'Commit Strip (En)'
2682
    url = 'http://www.commitstrip.com/en'
2683
    first_url = 'http://www.commitstrip.com/en/2012/02/22/interview/'
2684
2685
2686
class GenericBoumerie(GenericNavigableComic):
2687
    """Generic class to retrieve Boumeries comics in different languages."""
2688
    get_first_comic_link = get_a_navi_navifirst
2689
    get_navi_link = get_link_rel_next
2690
    date_format = NotImplemented
2691
    lang = NotImplemented
2692
2693
    @classmethod
2694
    def get_comic_info(cls, soup, link):
2695
        """Get information about a particular comics."""
2696
        title = soup.find('h2', class_='post-title').string
2697
        short_url = soup.find('link', rel='shortlink')['href']
2698
        author = soup.find("span", class_="post-author").find("a").string
2699
        date_str = soup.find('span', class_='post-date').string
2700
        day = string_to_date(date_str, cls.date_format, cls.lang)
2701
        imgs = soup.find('div', id='comic').find_all('img')
2702
        assert all(i['alt'] == i['title'] for i in imgs)
2703
        return {
2704
            'short_url': short_url,
2705
            'img': [i['src'] for i in imgs],
2706
            'title': title,
2707
            'author': author,
2708
            'month': day.month,
2709
            'year': day.year,
2710
            'day': day.day,
2711
        }
2712
2713
2714
class BoumerieEn(GenericBoumerie):
2715
    """Class to retrieve Boumeries comics in English."""
2716
    name = 'boumeries_en'
2717
    long_name = 'Boumeries (En)'
2718
    url = 'http://comics.boumerie.com'
2719
    date_format = "%B %d, %Y"
2720
    lang = 'en_GB.UTF-8'
2721
2722
2723
class BoumerieFr(GenericBoumerie):
2724
    """Class to retrieve Boumeries comics in French."""
2725
    name = 'boumeries_fr'
2726
    long_name = 'Boumeries (Fr)'
2727
    url = 'http://bd.boumerie.com'
2728
    _categories = ('FRANCAIS', )
2729
    date_format = "%A, %d %B %Y"
2730
    lang = "fr_FR.utf8"
2731
2732
2733
class UnearthedComics(GenericNavigableComic):
2734
    """Class to retrieve Unearthed comics."""
2735
    # Also on http://tapastic.com/series/UnearthedComics
2736
    # Also on http://unearthedcomics.tumblr.com
2737
    name = 'unearthed'
2738 View Code Duplication
    long_name = 'Unearthed Comics'
0 ignored issues
show
This code seems to be duplicated in your project.
Loading history...
2739
    url = 'http://unearthedcomics.com'
2740
    _categories = ('UNEARTHED', )
2741
    get_navi_link = get_link_rel_next
2742
    get_first_comic_link = simulate_first_link
2743
    first_url = 'http://unearthedcomics.com/comics/world-with-turn-signals/'
2744
2745
    @classmethod
2746
    def get_comic_info(cls, soup, link):
2747
        """Get information about a particular comics."""
2748
        short_url = soup.find('link', rel='shortlink')['href']
2749
        title_elt = soup.find('h1') or soup.find('h2')
2750
        title = title_elt.string if title_elt else ""
2751
        desc = soup.find('meta', property='og:description')
2752
        date_str = soup.find('time', class_='published updated hidden')['datetime']
2753
        day = string_to_date(date_str, "%Y-%m-%d")
2754
        post = soup.find('div', class_="entry content entry-content type-portfolio")
2755
        imgs = post.find_all('img')
2756
        return {
2757
            'title': title,
2758
            'description': desc,
2759
            'url2': short_url,
2760
            'img': [i['src'] for i in imgs],
2761
            'month': day.month,
2762
            'year': day.year,
2763
            'day': day.day,
2764
        }
2765
2766
2767
class Optipess(GenericNavigableComic):
2768
    """Class to retrieve Optipess comics."""
2769
    name = 'optipess'
2770
    long_name = 'Optipess'
2771
    url = 'http://www.optipess.com'
2772
    get_first_comic_link = get_a_navi_navifirst
2773
    get_navi_link = get_link_rel_next
2774
2775
    @classmethod
2776
    def get_comic_info(cls, soup, link):
2777
        """Get information about a particular comics."""
2778
        title = soup.find('h2', class_='post-title').string
2779
        author = soup.find("span", class_="post-author").find("a").string
2780
        comic = soup.find('div', id='comic')
2781
        imgs = comic.find_all('img') if comic else []
2782
        alt = imgs[0]['title'] if imgs else ""
2783
        assert all(i['alt'] == i['title'] == alt for i in imgs)
2784
        date_str = soup.find('span', class_='post-date').string
2785
        day = string_to_date(date_str, "%B %d, %Y")
2786
        return {
2787
            'title': title,
2788
            'alt': alt,
2789
            'author': author,
2790
            'img': [i['src'] for i in imgs],
2791
            'month': day.month,
2792
            'year': day.year,
2793
            'day': day.day,
2794
        }
2795
2796
2797
class PainTrainComic(GenericNavigableComic):
2798
    """Class to retrieve Pain Train Comics."""
2799
    name = 'paintrain'
2800
    long_name = 'Pain Train Comics'
2801
    url = 'http://paintraincomic.com'
2802
    get_first_comic_link = get_a_navi_navifirst
2803
    get_navi_link = get_link_rel_next
2804
2805
    @classmethod
2806
    def get_comic_info(cls, soup, link):
2807
        """Get information about a particular comics."""
2808
        title = soup.find('h2', class_='post-title').string
2809
        short_url = soup.find('link', rel='shortlink')['href']
2810
        short_url_re = re.compile('^%s/\\?p=([0-9]*)' % cls.url)
2811
        num = int(short_url_re.match(short_url).groups()[0])
2812
        imgs = soup.find('div', id='comic').find_all('img')
2813
        alt = imgs[0]['title']
2814
        assert all(i['alt'] == i['title'] == alt for i in imgs)
2815
        date_str = soup.find('span', class_='post-date').string
2816
        day = string_to_date(date_str, "%d/%m/%Y")
2817
        return {
2818
            'short_url': short_url,
2819
            'num': num,
2820
            'img': [i['src'] for i in imgs],
2821
            'month': day.month,
2822
            'year': day.year,
2823
            'day': day.day,
2824
            'alt': alt,
2825
            'title': title,
2826
        }
2827
2828
2829
class MoonBeard(GenericNavigableComic):
2830
    """Class to retrieve MoonBeard comics."""
2831
    # Also on http://blog.squiresjam.es/moonbeard
2832
    # Also on http://www.webtoons.com/en/comedy/moon-beard/list?title_no=471
2833
    name = 'moonbeard'
2834
    long_name = 'Moon Beard'
2835
    url = 'http://moonbeard.com'
2836
    get_first_comic_link = get_a_navi_navifirst
2837
    get_navi_link = get_a_navi_navinext
2838
2839
    @classmethod
2840
    def get_comic_info(cls, soup, link):
2841
        """Get information about a particular comics."""
2842
        title = soup.find('h2', class_='post-title').string
2843
        short_url = soup.find('link', rel='shortlink')['href']
2844
        short_url_re = re.compile('^%s/\\?p=([0-9]*)' % cls.url)
2845
        num = int(short_url_re.match(short_url).groups()[0])
2846
        imgs = soup.find('div', id='comic').find_all('img')
2847
        alt = imgs[0]['title']
2848
        assert all(i['alt'] == i['title'] == alt for i in imgs)
2849
        date_str = soup.find('span', class_='post-date').string
2850
        day = string_to_date(date_str, "%B %d, %Y")
2851
        tags = ' '.join(t['content'] for t in soup.find_all('meta', property='article:tag'))
2852
        author = soup.find('span', class_='post-author').string
2853
        return {
2854
            'short_url': short_url,
2855
            'num': num,
2856
            'img': [i['src'] for i in imgs],
2857
            'month': day.month,
2858
            'year': day.year,
2859
            'day': day.day,
2860
            'title': title,
2861
            'tags': tags,
2862
            'alt': alt,
2863
            'author': author,
2864
        }
2865
2866
2867
class AHamADay(GenericNavigableComic):
2868
    """Class to retrieve class A Ham A Day comics."""
2869 View Code Duplication
    name = 'ham'
0 ignored issues
show
This code seems to be duplicated in your project.
Loading history...
2870
    long_name = 'A Ham A Day'
2871
    url = 'http://www.ahammaday.com'
2872
    get_url_from_link = join_cls_url_to_href
2873
    get_first_comic_link = simulate_first_link
2874
    first_url = 'http://www.ahammaday.com/today/3/6/french'
2875
2876
    @classmethod
2877
    def get_navi_link(cls, last_soup, next_):
2878
        """Get link to next or previous comic."""
2879
        # prev is next / next is prev
2880
        return last_soup.find('li', class_='previous' if next_ else 'next').find('a')
2881
2882
    @classmethod
2883
    def get_comic_info(cls, soup, link):
2884
        """Get information about a particular comics."""
2885
        date_str = soup.find('time', class_='published')['datetime']
2886
        day = string_to_date(date_str, "%Y-%m-%d")
2887
        author = soup.find('span', class_='blog-author').find('a').string
2888
        title = soup.find('meta', property='og:title')['content']
2889
        imgs = soup.find_all('meta', itemprop='image')
2890
        return {
2891
            'img': [i['content'] for i in imgs],
2892
            'title': title,
2893
            'author': author,
2894
            'day': day.day,
2895
            'month': day.month,
2896
            'year': day.year,
2897
        }
2898
2899
2900
class LittleLifeLines(GenericNavigableComic):
2901
    """Class to retrieve Little Life Lines comics."""
2902
    # Also on https://little-life-lines.tumblr.com
2903
    name = 'life'
2904
    long_name = 'Little Life Lines'
2905
    url = 'http://www.littlelifelines.com'
2906
    get_url_from_link = join_cls_url_to_href
2907
    get_first_comic_link = simulate_first_link
2908
    first_url = 'http://www.littlelifelines.com/comics/well-done'
2909
2910
    @classmethod
2911
    def get_navi_link(cls, last_soup, next_):
2912
        """Get link to next or previous comic."""
2913
        # prev is next / next is prev
2914
        li = last_soup.find('li', class_='prev' if next_ else 'next')
2915
        return li.find('a') if li else None
2916
2917
    @classmethod
2918
    def get_comic_info(cls, soup, link):
2919
        """Get information about a particular comics."""
2920
        title = soup.find('meta', property='og:title')['content']
2921
        desc = soup.find('meta', property='og:description')['content']
2922
        date_str = soup.find('time', class_='published')['datetime']
2923
        day = string_to_date(date_str, "%Y-%m-%d")
2924
        author = soup.find('a', rel='author').string
2925
        div_content = soup.find('div', class_="body entry-content")
2926
        imgs = div_content.find_all('img')
2927
        imgs = [i for i in imgs if i.get('src') is not None]
2928
        alt = imgs[0]['alt']
2929
        return {
2930
            'title': title,
2931
            'alt': alt,
2932
            'description': desc,
2933
            'author': author,
2934
            'day': day.day,
2935
            'month': day.month,
2936
            'year': day.year,
2937
            'img': [i['src'] for i in imgs],
2938
        }
2939
2940
2941
class GenericWordPressInkblot(GenericNavigableComic):
2942
    """Generic class to retrieve comics using WordPress with Inkblot."""
2943
    get_navi_link = get_link_rel_next
2944
2945
    @classmethod
2946
    def get_first_comic_link(cls):
2947
        """Get link to first comics."""
2948
        return get_soup_at_url(cls.url).find('a', class_='webcomic-link webcomic1-link first-webcomic-link first-webcomic1-link')
2949
2950
    @classmethod
2951
    def get_comic_info(cls, soup, link):
2952
        """Get information about a particular comics."""
2953
        title = soup.find('meta', property='og:title')['content']
2954
        imgs = soup.find('div', class_='webcomic-image').find_all('img')
2955
        date_str = soup.find('meta', property='article:published_time')['content'][:10]
2956
        day = string_to_date(date_str, "%Y-%m-%d")
2957
        return {
2958
            'title': title,
2959
            'day': day.day,
2960
            'month': day.month,
2961
            'year': day.year,
2962
            'img': [i['src'] for i in imgs],
2963
        }
2964
2965
2966
class EverythingsStupid(GenericWordPressInkblot):
2967
    """Class to retrieve Everything's stupid Comics."""
2968
    # Also on http://tapastic.com/series/EverythingsStupid
2969
    # Also on http://www.webtoons.com/en/challenge/everythings-stupid/list?title_no=14591
2970
    # Also on http://everythingsstupidcomics.tumblr.com
2971
    name = 'stupid'
2972
    long_name = "Everything's Stupid"
2973
    url = 'http://everythingsstupid.net'
2974
2975
2976
class TheIsmComics(GenericWordPressInkblot):
2977
    """Class to retrieve The Ism Comics."""
2978
    # Also on https://tapastic.com/series/TheIsm (?)
2979
    name = 'theism'
2980
    long_name = "The Ism"
2981
    url = 'http://www.theism-comics.com'
2982
2983
2984
class WoodenPlankStudios(GenericWordPressInkblot):
2985
    """Class to retrieve Wooden Plank Studios comics."""
2986
    name = 'woodenplank'
2987
    long_name = 'Wooden Plank Studios'
2988
    url = 'http://woodenplankstudios.com'
2989
2990
2991
class ElectricBunnyComic(GenericNavigableComic):
2992
    """Class to retrieve Electric Bunny Comics."""
2993
    # Also on http://electricbunnycomics.tumblr.com
2994
    name = 'bunny'
2995
    long_name = 'Electric Bunny Comic'
2996
    url = 'http://www.electricbunnycomics.com/View/Comic/153/Welcome+to+Hell'
2997
    get_url_from_link = join_cls_url_to_href
2998
2999
    @classmethod
3000
    def get_first_comic_link(cls):
3001
        """Get link to first comics."""
3002
        return get_soup_at_url(cls.url).find('img', alt='First').parent
3003
3004
    @classmethod
3005
    def get_navi_link(cls, last_soup, next_):
3006
        """Get link to next or previous comic."""
3007
        img = last_soup.find('img', alt='Next' if next_ else 'Back')
3008
        return img.parent if img else None
3009
3010
    @classmethod
3011
    def get_comic_info(cls, soup, link):
3012
        """Get information about a particular comics."""
3013
        title = soup.find('meta', property='og:title')['content']
3014
        imgs = soup.find_all('meta', property='og:image')
3015
        return {
3016
            'title': title,
3017
            'img': [i['content'] for i in imgs],
3018
        }
3019
3020
3021
class SheldonComics(GenericNavigableComic):
3022
    """Class to retrieve Sheldon comics."""
3023
    # Also on http://www.gocomics.com/sheldon
3024
    name = 'sheldon'
3025
    long_name = 'Sheldon Comics'
3026
    url = 'http://www.sheldoncomics.com'
3027
3028
    @classmethod
3029
    def get_first_comic_link(cls):
3030
        """Get link to first comics."""
3031
        return get_soup_at_url(cls.url).find("a", id="nav-first")
3032
3033
    @classmethod
3034
    def get_navi_link(cls, last_soup, next_):
3035
        """Get link to next or previous comic."""
3036
        for link in last_soup.find_all("a", id="nav-next" if next_ else "nav-prev"):
3037
            if link['href'] != 'http://www.sheldoncomics.com':
3038
                return link
3039
        return None
3040
3041
    @classmethod
3042
    def get_comic_info(cls, soup, link):
3043
        """Get information about a particular comics."""
3044
        imgs = soup.find("div", id="comic-foot").find_all("img")
3045
        assert all(i['alt'] == i['title'] for i in imgs)
3046
        assert len(imgs) == 1
3047
        title = imgs[0]['title']
3048
        return {
3049
            'title': title,
3050
            'img': [i['src'] for i in imgs],
3051
        }
3052
3053
3054
class Ubertool(GenericNavigableComic):
3055
    """Class to retrieve Ubertool comics."""
3056
    # Also on http://ubertool.tumblr.com
3057
    # Also on https://tapastic.com/series/ubertool
3058
    name = 'ubertool'
3059
    long_name = 'Ubertool'
3060
    url = 'http://ubertoolcomic.com'
3061
    _categories = ('UBERTOOL', )
3062
    get_first_comic_link = get_a_comicnavbase_comicnavfirst
3063
    get_navi_link = get_a_comicnavbase_comicnavnext
3064
3065
    @classmethod
3066
    def get_comic_info(cls, soup, link):
3067
        """Get information about a particular comics."""
3068
        title = soup.find('h2', class_='post-title').string
3069
        date_str = soup.find('span', class_='post-date').string
3070
        day = string_to_date(date_str, "%B %d, %Y")
3071
        imgs = soup.find('div', id='comic').find_all('img')
3072
        return {
3073
            'img': [i['src'] for i in imgs],
3074
            'title': title,
3075
            'month': day.month,
3076
            'year': day.year,
3077
            'day': day.day,
3078
        }
3079
3080
3081
class CubeDrone(GenericNavigableComic):
3082
    """Class to retrieve Cube Drone comics."""
3083
    name = 'cubedrone'
3084
    long_name = 'Cube Drone'
3085
    url = 'http://cube-drone.com/comics'
3086
    get_url_from_link = join_cls_url_to_href
3087
3088
    @classmethod
3089
    def get_first_comic_link(cls):
3090
        """Get link to first comics."""
3091
        return get_soup_at_url(cls.url).find('span', class_='glyphicon glyphicon-backward').parent
3092
3093
    @classmethod
3094
    def get_navi_link(cls, last_soup, next_):
3095
        """Get link to next or previous comic."""
3096
        class_ = 'glyphicon glyphicon-chevron-' + ('right' if next_ else 'left')
3097
        return last_soup.find('span', class_=class_).parent
3098
3099
    @classmethod
3100
    def get_comic_info(cls, soup, link):
3101
        """Get information about a particular comics."""
3102
        title = soup.find('meta', attrs={'name': 'twitter:title'})['content']
3103
        url2 = soup.find('meta', attrs={'name': 'twitter:url'})['content']
3104
        # date_str = soup.find('h2', class_='comic_title').find('small').string
3105
        # day = string_to_date(date_str, "%B %d, %Y, %I:%M %p")
3106
        imgs = soup.find_all('img', class_='comic img-responsive')
3107
        title2 = imgs[0]['title']
3108
        alt = imgs[0]['alt']
3109
        return {
3110
            'url2': url2,
3111
            'title': title,
3112
            'title2': title2,
3113
            'alt': alt,
3114
            'img': [i['src'] for i in imgs],
3115
        }
3116
3117
3118
class MakeItStoopid(GenericNavigableComic):
3119
    """Class to retrieve Make It Stoopid Comics."""
3120
    name = 'stoopid'
3121
    long_name = 'Make it stoopid'
3122
    url = 'http://makeitstoopid.com/comic.php'
3123
3124 View Code Duplication
    @classmethod
0 ignored issues
show
This code seems to be duplicated in your project.
Loading history...
3125
    def get_nav(cls, soup):
3126
        """Get the navigation elements from soup object."""
3127
        cnav = soup.find_all(class_='cnav')
3128
        nav1, nav2 = cnav[:5], cnav[5:]
3129
        assert nav1 == nav2
3130
        # begin, prev, archive, next_, end = nav1
3131
        return [None if i.get('href') is None else i for i in nav1]
3132
3133
    @classmethod
3134
    def get_first_comic_link(cls):
3135
        """Get link to first comics."""
3136
        return cls.get_nav(get_soup_at_url(cls.url))[0]
3137
3138
    @classmethod
3139
    def get_navi_link(cls, last_soup, next_):
3140
        """Get link to next or previous comic."""
3141
        return cls.get_nav(last_soup)[3 if next_ else 1]
3142
3143
    @classmethod
3144
    def get_comic_info(cls, soup, link):
3145
        """Get information about a particular comics."""
3146
        title = link['title']
3147
        imgs = soup.find_all('img', id='comicimg')
3148
        return {
3149
            'title': title,
3150
            'img': [i['src'] for i in imgs],
3151
        }
3152
3153
3154
class TuMourrasMoinsBete(GenericNavigableComic):
3155
    """Class to retrieve Tu Mourras Moins Bete comics."""
3156
    name = 'mourrasmoinsbete'
3157
    long_name = 'Tu Mourras Moins Bete'
3158
    url = 'http://tumourrasmoinsbete.blogspot.fr'
3159
    _categories = ('FRANCAIS', )
3160
    get_first_comic_link = simulate_first_link
3161
    first_url = 'http://tumourrasmoinsbete.blogspot.fr/2008/06/essai.html'
3162
3163
    @classmethod
3164
    def get_navi_link(cls, last_soup, next_):
3165
        """Get link to next or previous comic."""
3166
        return last_soup.find('a', id='Blog1_blog-pager-newer-link' if next_ else 'Blog1_blog-pager-older-link')
3167
3168
    @classmethod
3169
    def get_comic_info(cls, soup, link):
3170
        """Get information about a particular comics."""
3171
        title = soup.find('title').string
3172
        imgs = soup.find('div', itemprop='description articleBody').find_all('img')
3173
        author = soup.find('span', itemprop='author').string
3174
        return {
3175
            'img': [i['src'] for i in imgs],
3176
            'author': author,
3177
            'title': title,
3178
        }
3179
3180
3181
class GeekAndPoke(GenericNavigableComic):
3182
    """Class to retrieve Geek And Poke comics."""
3183
    name = 'geek'
3184
    long_name = 'Geek And Poke'
3185
    url = 'http://geek-and-poke.com'
3186
    get_url_from_link = join_cls_url_to_href
3187
    get_first_comic_link = simulate_first_link
3188
    first_url = 'http://geek-and-poke.com/geekandpoke/2006/8/27/a-new-place-for-a-not-so-old-blog.html'
3189
3190
    @classmethod
3191 View Code Duplication
    def get_navi_link(cls, last_soup, next_):
0 ignored issues
show
This code seems to be duplicated in your project.
Loading history...
3192
        """Get link to next or previous comic."""
3193
        return last_soup.find('a', class_='prev-item' if next_ else 'next-item')
3194
3195
    @classmethod
3196
    def get_comic_info(cls, soup, link):
3197
        """Get information about a particular comics."""
3198
        title = soup.find('meta', property='og:title')['content']
3199
        desc = soup.find('meta', property='og:description')['content']
3200
        date_str = soup.find('time', class_='published')['datetime']
3201
        day = string_to_date(date_str, "%Y-%m-%d")
3202
        author = soup.find('a', rel='author').string
3203
        div_content = (soup.find('div', class_="body entry-content") or
3204
                       soup.find('div', class_="special-content"))
3205
        imgs = div_content.find_all('img')
3206
        imgs = [i for i in imgs if i.get('src') is not None]
3207
        assert all('title' not in i or i['alt'] == i['title'] for i in imgs)
3208
        alt = imgs[0].get('alt', "") if imgs else []
3209
        return {
3210
            'title': title,
3211
            'alt': alt,
3212
            'description': desc,
3213
            'author': author,
3214
            'day': day.day,
3215
            'month': day.month,
3216
            'year': day.year,
3217
            'img': [urljoin_wrapper(cls.url, i['src']) for i in imgs],
3218
        }
3219
3220
3221
class GloryOwlComix(GenericNavigableComic):
3222
    """Class to retrieve Glory Owl comics."""
3223
    name = 'gloryowl'
3224
    long_name = 'Glory Owl'
3225
    url = 'http://gloryowlcomix.blogspot.fr'
3226
    _categories = ('NSFW', 'FRANCAIS')
3227
    get_first_comic_link = simulate_first_link
3228
    first_url = 'http://gloryowlcomix.blogspot.fr/2013/02/1_7.html'
3229
3230
    @classmethod
3231
    def get_navi_link(cls, last_soup, next_):
3232
        """Get link to next or previous comic."""
3233
        return last_soup.find('a', id='Blog1_blog-pager-newer-link' if next_ else 'Blog1_blog-pager-older-link')
3234
3235
    @classmethod
3236
    def get_comic_info(cls, soup, link):
3237
        """Get information about a particular comics."""
3238
        title = soup.find('title').string
3239
        imgs = soup.find_all('link', rel='image_src')
3240
        author = soup.find('a', rel='author').string
3241
        return {
3242
            'img': [i['href'] for i in imgs],
3243
            'author': author,
3244
            'title': title,
3245
        }
3246
3247
3248
class GenericTumblrV1(GenericComic):
3249
    """Generic class to retrieve comics from Tumblr using the V1 API."""
3250
    _categories = ('TUMBLR', )
3251
3252
    @classmethod
3253
    def get_next_comic(cls, last_comic):
3254
        """Generic implementation of get_next_comic for Tumblr comics."""
3255
        for p in cls.get_posts(last_comic):
3256
            comic = cls.get_comic_info(p)
3257
            if comic is not None:
3258
                yield comic
3259
3260
    @classmethod
3261
    def get_url_from_post(cls, post):
3262
        return post['url']
3263
3264
    @classmethod
3265
    def get_api_url(cls):
3266
        return urljoin_wrapper(cls.url, '/api/read/')
3267
3268
    @classmethod
3269
    def get_comic_info(cls, post):
3270
        """Get information about a particular comics."""
3271
        type_ = post['type']
3272
        if type_ != 'photo':
3273
            return None
3274
        tumblr_id = int(post['id'])
3275
        api_url = cls.get_api_url() + '?id=%d' % (tumblr_id)
3276
        day = datetime.datetime.fromtimestamp(int(post['unix-timestamp'])).date()
3277
        caption = post.find('photo-caption')
3278
        title = caption.string if caption else ""
3279
        tags = ' '.join(t.string for t in post.find_all('tag'))
3280
        # Photos may appear in 'photo' tags and/or straight in the post
3281
        photo_tags = post.find_all('photo')
3282
        if not photo_tags:
3283
            photo_tags = [post]
3284
        # Images are in multiple resolutions - taking the first one
3285
        imgs = [photo.find('photo-url') for photo in photo_tags]
3286
        return {
3287
            'url': cls.get_url_from_post(post),
3288
            'url2': post['url-with-slug'],
3289
            'day': day.day,
3290
            'month': day.month,
3291
            'year': day.year,
3292
            'title': title,
3293
            'tags': tags,
3294
            'img': [i.string for i in imgs],
3295
            'tumblr-id': tumblr_id,
3296
            'api_url': api_url,
3297
        }
3298
3299
    @classmethod
3300
    def get_posts(cls, last_comic, nb_post_per_call=10):
3301
        """Get posts using API. nb_post_per_call is max 50.
3302
3303
        Posts are retrieved from newer to older as per the tumblr v1 api
3304
        but are returned in chronological order."""
3305
        waiting_for_url = last_comic['url'] if last_comic else None
3306
        posts_acc = []
3307
        if last_comic is not None:
3308
            # Sometimes, tumblr posts are deleted. When previous post is deleted, we
3309
            # might end up spending a lot of time looking for something that
3310
            # doesn't exist. Failing early and clearly might be a better option.
3311
            last_api_url = last_comic['api_url']
3312
            try:
3313
                get_soup_at_url(last_api_url)
3314
            except urllib.error.HTTPError:
3315
                try:
3316
                    get_soup_at_url(cls.url)
3317
                except urllib.error.HTTPError:
3318
                    print("Did not find previous post nor main url %s" % cls.url)
3319
                else:
3320
                    print("Did not find previous post %s : it might have been deleted" % last_api_url)
3321
                return reversed(posts_acc)
3322
        api_url = cls.get_api_url()
3323
        posts = get_soup_at_url(api_url).find('posts')
3324
        start, total = int(posts['start']), int(posts['total'])
3325
        assert start == 0
3326
        for starting_num in range(0, total, nb_post_per_call):
3327
            api_url2 = api_url + '?start=%d&num=%d' % (starting_num, nb_post_per_call)
3328
            posts2 = get_soup_at_url(api_url2).find('posts')
3329
            start2, total2 = int(posts2['start']), int(posts2['total'])
3330
            assert starting_num == start2, "%d != %d" % (starting_num, start2)
3331
            # This may happen and should be handled in the future
3332
            assert total == total2, "%d != %d" % (total, total2)
3333
            for p in posts2.find_all('post'):
3334
                if waiting_for_url and waiting_for_url == cls.get_url_from_post(p):
3335
                    return reversed(posts_acc)
3336
                posts_acc.append(p)
3337
        if waiting_for_url is None:
3338
            return reversed(posts_acc)
3339
        print("Did not find %s : there might be a problem" % waiting_for_url)
3340
        return []
3341
3342
3343
class GenericTumblrV1Empty(GenericEmptyComic, GenericTumblrV1):
3344
    """Generic class for Tumblr comics with a problem."""
3345
    pass
3346
3347
3348
class SaturdayMorningBreakfastCerealTumblr(GenericTumblrV1Empty):
3349
    """Class to retrieve Saturday Morning Breakfast Cereal comics."""
3350
    # Also on http://www.gocomics.com/saturday-morning-breakfast-cereal
3351
    # Also on http://www.smbc-comics.com
3352
    name = 'smbc-tumblr'
3353
    long_name = 'Saturday Morning Breakfast Cereal (from Tumblr)'
3354
    url = 'http://smbc-comics.tumblr.com'
3355
    _categories = ('SMBC', )
3356
3357
3358
class IrwinCardozo(GenericTumblrV1):
3359
    """Class to retrieve Irwin Cardozo Comics."""
3360
    name = 'irwinc'
3361
    long_name = 'Irwin Cardozo'
3362
    url = 'http://irwincardozocomics.tumblr.com'
3363
3364
3365
class AccordingToDevin(GenericTumblrV1):
3366
    """Class to retrieve According To Devin comics."""
3367
    name = 'devin'
3368
    long_name = 'According To Devin'
3369
    url = 'http://accordingtodevin.tumblr.com'
3370
3371
3372
class ItsTheTieTumblr(GenericTumblrV1):
3373
    """Class to retrieve It's the tie comics."""
3374
    # Also on http://itsthetie.com
3375
    # Also on https://tapastic.com/series/itsthetie
3376
    name = 'tie-tumblr'
3377
    long_name = "It's the tie (from Tumblr)"
3378
    url = "http://itsthetie.tumblr.com"
3379
    _categories = ('TIE', )
3380
3381
3382
class OctopunsTumblr(GenericTumblrV1):
3383
    """Class to retrieve Octopuns comics."""
3384
    # Also on http://www.octopuns.net
3385
    name = 'octopuns-tumblr'
3386
    long_name = 'Octopuns (from Tumblr)'
3387
    url = 'http://octopuns.tumblr.com'
3388
3389
3390
class PicturesInBoxesTumblr(GenericTumblrV1):
3391
    """Class to retrieve Pictures In Boxes comics."""
3392
    # Also on http://www.picturesinboxes.com
3393
    name = 'picturesinboxes-tumblr'
3394
    long_name = 'Pictures in Boxes (from Tumblr)'
3395
    url = 'http://picturesinboxescomic.tumblr.com'
3396
3397
3398
class TubeyToonsTumblr(GenericTumblrV1):
3399
    """Class to retrieve TubeyToons comics."""
3400
    # Also on http://tapastic.com/series/Tubey-Toons
3401
    # Also on http://tubeytoons.com
3402
    name = 'tubeytoons-tumblr'
3403
    long_name = 'Tubey Toons (from Tumblr)'
3404
    url = 'http://tubeytoons.tumblr.com'
3405
    _categories = ('TUNEYTOONS', )
3406
3407
3408
class UnearthedComicsTumblr(GenericTumblrV1):
3409
    """Class to retrieve Unearthed comics."""
3410
    # Also on http://tapastic.com/series/UnearthedComics
3411
    # Also on http://unearthedcomics.com
3412
    name = 'unearthed-tumblr'
3413
    long_name = 'Unearthed Comics (from Tumblr)'
3414
    url = 'http://unearthedcomics.tumblr.com'
3415
    _categories = ('UNEARTHED', )
3416
3417
3418
class PieComic(GenericTumblrV1):
3419
    """Class to retrieve Pie Comic comics."""
3420
    name = 'pie'
3421
    long_name = 'Pie Comic'
3422
    url = "http://piecomic.tumblr.com"
3423
3424
3425
class MrEthanDiamond(GenericTumblrV1):
3426
    """Class to retrieve Mr Ethan Diamond comics."""
3427
    name = 'diamond'
3428
    long_name = 'Mr Ethan Diamond'
3429
    url = 'http://mrethandiamond.tumblr.com'
3430
3431
3432
class Flocci(GenericTumblrV1):
3433
    """Class to retrieve floccinaucinihilipilification comics."""
3434
    name = 'flocci'
3435
    long_name = 'floccinaucinihilipilification'
3436
    url = "http://floccinaucinihilipilificationa.tumblr.com"
3437
3438
3439
class UpAndOut(GenericTumblrV1):
3440
    """Class to retrieve Up & Out comics."""
3441
    # Also on http://tapastic.com/series/UP-and-OUT
3442
    name = 'upandout'
3443
    long_name = 'Up And Out (from Tumblr)'
3444
    url = 'http://upandoutcomic.tumblr.com'
3445
3446
3447
class Pundemonium(GenericTumblrV1):
3448
    """Class to retrieve Pundemonium comics."""
3449
    name = 'pundemonium'
3450
    long_name = 'Pundemonium'
3451
    url = 'http://monstika.tumblr.com'
3452
3453
3454
class PoorlyDrawnLinesTumblr(GenericTumblrV1Empty):
3455
    """Class to retrieve Poorly Drawn Lines comics."""
3456
    # Also on http://poorlydrawnlines.com
3457
    name = 'poorlydrawn-tumblr'
3458
    long_name = 'Poorly Drawn Lines (from Tumblr)'
3459
    url = 'http://pdlcomics.tumblr.com'
3460
    _categories = ('POORLYDRAWN', )
3461
3462
3463
class PearShapedComics(GenericTumblrV1):
3464
    """Class to retrieve Pear Shaped Comics."""
3465
    name = 'pearshaped'
3466
    long_name = 'Pear-Shaped Comics'
3467
    url = 'http://pearshapedcomics.com'
3468
3469
3470
class PondScumComics(GenericTumblrV1):
3471
    """Class to retrieve Pond Scum Comics."""
3472
    name = 'pond'
3473
    long_name = 'Pond Scum'
3474
    url = 'http://pondscumcomic.tumblr.com'
3475
3476
3477
class MercworksTumblr(GenericTumblrV1):
3478
    """Class to retrieve Mercworks comics."""
3479
    # Also on http://mercworks.net
3480
    name = 'mercworks-tumblr'
3481
    long_name = 'Mercworks (from Tumblr)'
3482
    url = 'http://mercworks.tumblr.com'
3483
3484
3485
class OwlTurdTumblr(GenericTumblrV1Empty):
3486
    """Class to retrieve Owl Turd comics."""
3487
    # Also on http://tapastic.com/series/Owl-Turd-Comix
3488
    name = 'owlturd-tumblr'
3489
    long_name = 'Owl Turd (from Tumblr)'
3490
    url = 'http://owlturd.com'
3491
    _categories = ('OWLTURD', )
3492
3493
3494
class VectorBelly(GenericTumblrV1):
3495
    """Class to retrieve Vector Belly comics."""
3496
    # Also on http://vectorbelly.com
3497
    name = 'vector'
3498
    long_name = 'Vector Belly'
3499
    url = 'http://vectorbelly.tumblr.com'
3500
3501
3502
class GoneIntoRapture(GenericTumblrV1):
3503
    """Class to retrieve Gone Into Rapture comics."""
3504
    # Also on http://goneintorapture.tumblr.com
3505
    # Also on http://tapastic.com/series/Goneintorapture
3506
    name = 'rapture'
3507
    long_name = 'Gone Into Rapture'
3508
    url = 'http://www.goneintorapture.com'
3509
3510
3511
class TheOatmealTumblr(GenericTumblrV1):
3512
    """Class to retrieve The Oatmeal comics."""
3513
    # Also on http://theoatmeal.com
3514
    name = 'oatmeal-tumblr'
3515
    long_name = 'The Oatmeal (from Tumblr)'
3516
    url = 'http://oatmeal.tumblr.com'
3517
3518
3519
class HeckIfIKnowComicsTumblr(GenericTumblrV1):
3520
    """Class to retrieve Heck If I Know Comics."""
3521
    # Also on http://tapastic.com/series/Regular
3522
    name = 'heck-tumblr'
3523
    long_name = 'Heck if I Know comics (from Tumblr)'
3524
    url = 'http://heckifiknowcomics.com'
3525
3526
3527
class MyJetPack(GenericTumblrV1):
3528
    """Class to retrieve My Jet Pack comics."""
3529
    name = 'jetpack'
3530
    long_name = 'My Jet Pack'
3531
    url = 'http://myjetpack.tumblr.com'
3532
3533
3534
class CheerUpEmoKidTumblr(GenericTumblrV1):
3535
    """Class to retrieve CheerUpEmoKid comics."""
3536
    # Also on http://www.cheerupemokid.com
3537
    # Also on http://tapastic.com/series/CUEK
3538
    name = 'cuek-tumblr'
3539
    long_name = 'Cheer Up Emo Kid (from Tumblr)'
3540
    url = 'http://enzocomics.tumblr.com'
3541
3542
3543
class ForLackOfABetterComic(GenericTumblrV1Empty):
3544
    """Class to retrieve For Lack Of A Better Comics."""
3545
    # Also on http://forlackofabettercomic.com
3546
    name = 'lack'
3547
    long_name = 'For Lack Of A Better Comic'
3548
    url = 'http://forlackofabettercomic.tumblr.com'
3549
3550
3551
class ZenPencilsTumblr(GenericTumblrV1):
3552
    """Class to retrieve ZenPencils comics."""
3553
    # Also on http://zenpencils.com
3554
    # Also on http://www.gocomics.com/zen-pencils
3555
    name = 'zenpencils-tumblr'
3556
    long_name = 'Zen Pencils (from Tumblr)'
3557
    url = 'http://zenpencils.tumblr.com'
3558
    _categories = ('ZENPENCILS', )
3559
3560
3561
class ThreeWordPhraseTumblr(GenericTumblrV1):
3562
    """Class to retrieve Three Word Phrase comics."""
3563
    # Also on http://threewordphrase.com
3564
    name = 'threeword-tumblr'
3565
    long_name = 'Three Word Phrase (from Tumblr)'
3566
    url = 'http://www.threewordphrase.tumblr.com'
3567
3568
3569
class TimeTrabbleTumblr(GenericTumblrV1):
3570
    """Class to retrieve Time Trabble comics."""
3571
    # Also on http://timetrabble.com
3572
    name = 'timetrabble-tumblr'
3573
    long_name = 'Time Trabble (from Tumblr)'
3574
    url = 'http://timetrabble.tumblr.com'
3575
3576
3577
class SafelyEndangeredTumblr(GenericTumblrV1):
3578
    """Class to retrieve Safely Endangered comics."""
3579
    # Also on http://www.safelyendangered.com
3580
    name = 'endangered-tumblr'
3581
    long_name = 'Safely Endangered (from Tumblr)'
3582
    url = 'http://tumblr.safelyendangered.com'
3583
3584
3585
class MouseBearComedyTumblr(GenericTumblrV1):
3586
    """Class to retrieve Mouse Bear Comedy comics."""
3587
    # Also on http://www.mousebearcomedy.com
3588
    name = 'mousebear-tumblr'
3589
    long_name = 'Mouse Bear Comedy (from Tumblr)'
3590
    url = 'http://mousebearcomedy.tumblr.com'
3591
3592
3593
class BouletCorpTumblr(GenericTumblrV1):
3594
    """Class to retrieve BouletCorp comics."""
3595
    # Also on http://www.bouletcorp.com
3596
    name = 'boulet-tumblr'
3597
    long_name = 'Boulet Corp (from Tumblr)'
3598
    url = 'http://bouletcorp.tumblr.com'
3599
    _categories = ('BOULET', )
3600
3601
3602
class TheAwkwardYetiTumblr(GenericTumblrV1Empty):
3603
    """Class to retrieve The Awkward Yeti comics."""
3604
    # Also on http://www.gocomics.com/the-awkward-yeti
3605
    # Also on http://theawkwardyeti.com
3606
    # Also on https://tapastic.com/series/TheAwkwardYeti
3607
    name = 'yeti-tumblr'
3608
    long_name = 'The Awkward Yeti (from Tumblr)'
3609
    url = 'http://larstheyeti.tumblr.com'
3610
    _categories = ('YETI', )
3611
3612
3613
class NellucNhoj(GenericTumblrV1):
3614
    """Class to retrieve NellucNhoj comics."""
3615
    name = 'nhoj'
3616
    long_name = 'Nelluc Nhoj'
3617
    url = 'http://nellucnhoj.com'
3618
3619
3620
class DownTheUpwardSpiralTumblr(GenericTumblrV1):
3621
    """Class to retrieve Down The Upward Spiral comics."""
3622
    # Also on http://www.downtheupwardspiral.com
3623
    name = 'spiral-tumblr'
3624
    long_name = 'Down the Upward Spiral (from Tumblr)'
3625
    url = 'http://downtheupwardspiral.tumblr.com'
3626
3627
3628
class AsPerUsualTumblr(GenericTumblrV1Empty):
3629
    """Class to retrieve As Per Usual comics."""
3630
    # Also on https://tapastic.com/series/AsPerUsual
3631
    name = 'usual-tumblr'
3632
    long_name = 'As Per Usual (from Tumblr)'
3633
    url = 'http://as-per-usual.tumblr.com'
3634
    categories = ('DAMILEE', )
3635
3636
3637
class HotComicsForCoolPeopleTumblr(GenericTumblrV1):
3638
    """Class to retrieve Hot Comics For Cool People."""
3639
    # Also on https://tapastic.com/series/Hot-Comics-For-Cool-People
3640
    # Also on http://hotcomics.biz (links to tumblr)
3641
    # Also on http://hcfcp.com (links to tumblr)
3642
    name = 'hotcomics-tumblr'
3643
    long_name = 'Hot Comics For Cool People (from Tumblr)'
3644
    url = 'http://hotcomicsforcoolpeople.tumblr.com'
3645
    categories = ('DAMILEE', )
3646
3647
3648
class OneOneOneOneComicTumblr(GenericTumblrV1):
3649
    """Class to retrieve 1111 Comics."""
3650
    # Also on http://www.1111comics.me
3651
    # Also on https://tapastic.com/series/1111-Comics
3652
    name = '1111-tumblr'
3653
    long_name = '1111 Comics (from Tumblr)'
3654
    url = 'http://comics1111.tumblr.com'
3655
    _categories = ('ONEONEONEONE', )
3656
3657
3658
class JhallComicsTumblr(GenericTumblrV1):
3659
    """Class to retrieve Jhall Comics."""
3660
    # Also on http://jhallcomics.com
3661
    name = 'jhall-tumblr'
3662
    long_name = 'Jhall Comics (from Tumblr)'
3663
    url = 'http://jhallcomics.tumblr.com'
3664
3665
3666
class BerkeleyMewsTumblr(GenericTumblrV1):
3667
    """Class to retrieve Berkeley Mews comics."""
3668
    # Also on http://www.gocomics.com/berkeley-mews
3669
    # Also on http://www.berkeleymews.com
3670
    name = 'berkeley-tumblr'
3671
    long_name = 'Berkeley Mews (from Tumblr)'
3672
    url = 'http://mews.tumblr.com'
3673
    _categories = ('BERKELEY', )
3674
3675
3676
class JoanCornellaTumblr(GenericTumblrV1):
3677
    """Class to retrieve Joan Cornella comics."""
3678
    # Also on http://joancornella.net
3679
    name = 'cornella-tumblr'
3680
    long_name = 'Joan Cornella (from Tumblr)'
3681
    url = 'http://cornellajoan.tumblr.com'
3682
3683
3684
class RespawnComicTumblr(GenericTumblrV1):
3685
    """Class to retrieve Respawn Comic."""
3686
    # Also on http://respawncomic.com
3687
    name = 'respawn-tumblr'
3688
    long_name = 'Respawn Comic (from Tumblr)'
3689
    url = 'http://respawncomic.tumblr.com'
3690
3691
3692
class ChrisHallbeckTumblr(GenericTumblrV1Empty):
3693
    """Class to retrieve Chris Hallbeck comics."""
3694
    # Also on https://tapastic.com/ChrisHallbeck
3695
    # Also on http://maximumble.com
3696
    # Also on http://minimumble.com
3697
    # Also on http://thebookofbiff.com
3698
    name = 'hallbeck-tumblr'
3699
    long_name = 'Chris Hallback (from Tumblr)'
3700
    url = 'http://chrishallbeck.tumblr.com'
3701
    _categories = ('HALLBACK', )
3702
3703
3704
class ComicNuggets(GenericTumblrV1):
3705
    """Class to retrieve Comic Nuggets."""
3706
    name = 'nuggets'
3707
    long_name = 'Comic Nuggets'
3708
    url = 'http://comicnuggets.com'
3709
3710
3711
class PigeonGazetteTumblr(GenericTumblrV1):
3712
    """Class to retrieve The Pigeon Gazette comics."""
3713
    # Also on https://tapastic.com/series/The-Pigeon-Gazette
3714
    name = 'pigeon-tumblr'
3715
    long_name = 'The Pigeon Gazette (from Tumblr)'
3716
    url = 'http://thepigeongazette.tumblr.com'
3717
3718
3719
class CancerOwl(GenericTumblrV1):
3720
    """Class to retrieve Cancer Owl comics."""
3721
    # Also on http://cancerowl.com
3722
    name = 'cancerowl-tumblr'
3723
    long_name = 'Cancer Owl (from Tumblr)'
3724
    url = 'http://cancerowl.tumblr.com'
3725
3726
3727
class FowlLanguageTumblr(GenericTumblrV1):
3728
    """Class to retrieve Fowl Language comics."""
3729
    # Also on http://www.fowllanguagecomics.com
3730
    # Also on http://tapastic.com/series/Fowl-Language-Comics
3731
    # Also on http://www.gocomics.com/fowl-language
3732
    name = 'fowllanguage-tumblr'
3733
    long_name = 'Fowl Language Comics (from Tumblr)'
3734
    url = 'http://fowllanguagecomics.tumblr.com'
3735
    _categories = ('FOWLLANGUAGE', )
3736
3737
3738
class TheOdd1sOutTumblr(GenericTumblrV1):
3739
    """Class to retrieve The Odd 1s Out comics."""
3740
    # Also on http://theodd1sout.com
3741
    # Also on https://tapastic.com/series/Theodd1sout
3742
    name = 'theodd-tumblr'
3743
    long_name = 'The Odd 1s Out (from Tumblr)'
3744
    url = 'http://theodd1sout.tumblr.com'
3745
3746
3747
class TheUnderfoldTumblr(GenericTumblrV1):
3748
    """Class to retrieve The Underfold comics."""
3749
    # Also on http://theunderfold.com
3750
    name = 'underfold-tumblr'
3751
    long_name = 'The Underfold (from Tumblr)'
3752
    url = 'http://theunderfold.tumblr.com'
3753
3754
3755
class LolNeinTumblr(GenericTumblrV1Empty):
3756
    """Class to retrieve Lol Nein comics."""
3757
    # Also on http://lolnein.com
3758
    name = 'lolnein-tumblr'
3759
    long_name = 'Lol Nein (from Tumblr)'
3760
    url = 'http://lolneincom.tumblr.com'
3761
3762
3763
class FatAwesomeComicsTumblr(GenericTumblrV1):
3764
    """Class to retrieve Fat Awesome Comics."""
3765
    # Also on http://fatawesome.com/comics
3766
    name = 'fatawesome-tumblr'
3767
    long_name = 'Fat Awesome (from Tumblr)'
3768
    url = 'http://fatawesomecomedy.tumblr.com'
3769
3770
3771
class TheWorldIsFlatTumblr(GenericTumblrV1):
3772
    """Class to retrieve The World Is Flat Comics."""
3773
    # Also on https://tapastic.com/series/The-World-is-Flat
3774
    name = 'flatworld-tumblr'
3775
    long_name = 'The World Is Flat (from Tumblr)'
3776
    url = 'http://theworldisflatcomics.tumblr.com'
3777
3778
3779
class DorrisMc(GenericTumblrV1Empty):
3780
    """Class to retrieve Dorris Mc Comics"""
3781
    # Also on http://www.gocomics.com/dorris-mccomics
3782
    name = 'dorrismc'
3783
    long_name = 'Dorris Mc'
3784
    url = 'http://dorrismccomics.com'
3785
3786
3787
class LeleozTumblr(GenericTumblrV1Empty):
3788
    """Class to retrieve Leleoz comics."""
3789
    # Also on https://tapastic.com/series/Leleoz
3790
    name = 'leleoz-tumblr'
3791
    long_name = 'Leleoz (from Tumblr)'
3792
    url = 'http://leleozcomics.tumblr.com'
3793
3794
3795
class MoonBeardTumblr(GenericTumblrV1):
3796
    """Class to retrieve MoonBeard comics."""
3797
    # Also on http://moonbeard.com
3798
    # Also on http://www.webtoons.com/en/comedy/moon-beard/list?title_no=471
3799
    name = 'moonbeard-tumblr'
3800
    long_name = 'Moon Beard (from Tumblr)'
3801
    url = 'http://blog.squiresjam.es/moonbeard'
3802
3803
3804
class AComik(GenericTumblrV1):
3805
    """Class to retrieve A Comik"""
3806
    name = 'comik'
3807
    long_name = 'A Comik'
3808
    url = 'http://acomik.com'
3809
3810
3811
class ClassicRandy(GenericTumblrV1):
3812
    """Class to retrieve Classic Randy comics."""
3813
    name = 'randy'
3814
    long_name = 'Classic Randy'
3815
    url = 'http://classicrandy.tumblr.com'
3816
3817
3818
class DagssonTumblr(GenericTumblrV1):
3819
    """Class to retrieve Dagsson comics."""
3820
    # Also on http://www.dagsson.com
3821
    name = 'dagsson-tumblr'
3822
    long_name = 'Dagsson Hugleikur (from Tumblr)'
3823
    url = 'http://hugleikurdagsson.tumblr.com'
3824
3825
3826
class LinsEditionsTumblr(GenericTumblrV1):
3827
    """Class to retrieve L.I.N.S. Editions comics."""
3828
    # Also on https://linsedition.com
3829
    name = 'lins-tumblr'
3830
    long_name = 'L.I.N.S. Editions (from Tumblr)'
3831
    url = 'http://linscomics.tumblr.com'
3832
    _categories = ('LINS', )
3833
3834
3835
class OrigamiHotDish(GenericTumblrV1):
3836
    """Class to retrieve Origami Hot Dish comics."""
3837
    name = 'origamihotdish'
3838
    long_name = 'Origami Hot Dish'
3839
    url = 'http://origamihotdish.com'
3840
3841
3842
class HitAndMissComicsTumblr(GenericTumblrV1):
3843
    """Class to retrieve Hit and Miss Comics."""
3844
    name = 'hitandmiss'
3845
    long_name = 'Hit and Miss Comics'
3846
    url = 'http://hitandmisscomics.tumblr.com'
3847
3848
3849
class HMBlanc(GenericTumblrV1):
3850
    """Class to retrieve HM Blanc comics."""
3851
    name = 'hmblanc'
3852
    long_name = 'HM Blanc'
3853
    url = 'http://hmblanc.tumblr.com'
3854
3855
3856
class TalesOfAbsurdityTumblr(GenericTumblrV1):
3857
    """Class to retrieve Tales Of Absurdity comics."""
3858
    # Also on http://talesofabsurdity.com
3859
    # Also on http://tapastic.com/series/Tales-Of-Absurdity
3860
    name = 'absurdity-tumblr'
3861
    long_name = 'Tales of Absurdity (from Tumblr)'
3862
    url = 'http://talesofabsurdity.tumblr.com'
3863
    _categories = ('ABSURDITY', )
3864
3865
3866
class RobbieAndBobby(GenericTumblrV1):
3867
    """Class to retrieve Robbie And Bobby comics."""
3868
    # Also on http://robbieandbobby.com
3869
    name = 'robbie-tumblr'
3870
    long_name = 'Robbie And Bobby (from Tumblr)'
3871
    url = 'http://robbieandbobby.tumblr.com'
3872
3873
3874
class ElectricBunnyComicTumblr(GenericTumblrV1):
3875
    """Class to retrieve Electric Bunny Comics."""
3876
    # Also on http://www.electricbunnycomics.com/View/Comic/153/Welcome+to+Hell
3877
    name = 'bunny-tumblr'
3878
    long_name = 'Electric Bunny Comic (from Tumblr)'
3879
    url = 'http://electricbunnycomics.tumblr.com'
3880
3881
3882
class Hoomph(GenericTumblrV1):
3883
    """Class to retrieve Hoomph comics."""
3884
    name = 'hoomph'
3885
    long_name = 'Hoomph'
3886
    url = 'http://hoom.ph'
3887
3888
3889
class BFGFSTumblr(GenericTumblrV1):
3890
    """Class to retrieve BFGFS comics."""
3891
    # Also on https://tapastic.com/series/BFGFS
3892
    # Also on http://bfgfs.com
3893
    name = 'bfgfs-tumblr'
3894
    long_name = 'BFGFS (from Tumblr)'
3895
    url = 'http://bfgfs.tumblr.com'
3896
3897
3898
class DoodleForFood(GenericTumblrV1Empty):
3899
    """Class to retrieve Doodle For Food comics."""
3900
    # Also on http://doodleforfood.com
3901
    name = 'doodle'
3902
    long_name = 'Doodle For Food'
3903
    url = 'http://doodleforfood.com'
3904
3905
3906
class CassandraCalinTumblr(GenericTumblrV1Empty):
3907
    """Class to retrieve C. Cassandra comics."""
3908
    # Also on http://cassandracalin.com
3909
    # Also on https://tapastic.com/series/C-Cassandra-comics
3910
    name = 'cassandra-tumblr'
3911
    long_name = 'Cassandra Calin (from Tumblr)'
3912
    url = 'http://c-cassandra.tumblr.com'
3913
3914
3915
class DougWasTaken(GenericTumblrV1Empty):
3916
    """Class to retrieve Doug Was Taken comics."""
3917
    name = 'doug'
3918
    long_name = 'Doug Was Taken'
3919
    url = 'http://dougwastaken.tumblr.com'
3920
3921
3922
class MandatoryRollerCoaster(GenericTumblrV1Empty):
3923
    """Class to retrieve Mandatory Roller Coaster comics."""
3924
    name = 'rollercoaster'
3925
    long_name = 'Mandatory Roller Coaster'
3926
    url = 'http://mandatoryrollercoaster.com'
3927
3928
3929
class CEstPasEnRegardantSesPompes(GenericTumblrV1Empty):
3930
    """Class to retrieve C'Est Pas En Regardant Ses Pompes (...)  comics."""
3931
    name = 'cperspqccltt'
3932
    long_name = 'C Est Pas En Regardant Ses Pompes (...)'
3933
    url = 'http://cperspqccltt.tumblr.com'
3934
3935
3936
class TheGrohlTroll(GenericTumblrV1Empty):
3937
    """Class to retrieve The Grohl Troll comics."""
3938
    name = 'grohltroll'
3939
    long_name = 'The Grohl Troll'
3940
    url = 'http://thegrohltroll.com'
3941
3942
3943
class WebcomicName(GenericTumblrV1Empty):
3944
    """Class to retrieve Webcomic Name comics."""
3945
    name = 'webcomicname'
3946
    long_name = 'Webcomic Name'
3947
    url = 'http://webcomicname.com'
3948
3949
3950
class BooksOfAdam(GenericTumblrV1Empty):
3951
    """Class to retrieve Books of Adam comics."""
3952
    # Also on http://www.booksofadam.com
3953
    name = 'booksofadam'
3954
    long_name = 'Books of Adam'
3955
    url = 'http://booksofadam.tumblr.com'
3956
3957
3958
class HarkAVagrant(GenericTumblrV1Empty):
3959
    """Class to retrieve Hark A Vagrant comics."""
3960
    # Also on http://www.harkavagrant.com
3961
    name = 'hark-tumblr'
3962
    long_name = 'Hark A Vagrant (from Tumblr)'
3963
    url = 'http://beatonna.tumblr.com'
3964
3965
3966
class OurSuperAdventureTumblr(GenericTumblrV1Empty):
3967
    """Class to retrieve Our Super Adventure comics."""
3968
    # Also on https://tapastic.com/series/Our-Super-Adventure
3969
    # Also on http://www.oursuperadventure.com
3970
    # http://sarahgraley.com
3971
    name = 'superadventure-tumblr'
3972
    long_name = 'Our Super Adventure (from Tumblr)'
3973
    url = 'http://sarahssketchbook.tumblr.com'
3974
3975
3976
class JakeLikesOnions(GenericTumblrV1):
3977
    """Class to retrieve Jake Likes Onions comics."""
3978
    name = 'jake'
3979
    long_name = 'Jake Likes Onions'
3980
    url = 'http://jakelikesonions.com'
3981
3982
3983
class InYourFaceCake(GenericTumblrV1Empty):
3984
    """Class to retrieve In Your Face Cake comics."""
3985
    name = 'inyourfacecake-tumblr'
3986
    long_name = 'In Your Face Cake (from Tumblr)'
3987
    url = 'http://in-your-face-cake.tumblr.com'
3988
3989
3990
class Robospunk(GenericTumblrV1):
3991
    """Class to retrieve Robospunk comics."""
3992
    name = 'robospunk'
3993
    long_name = 'Robospunk'
3994
    url = 'http://robospunk.com'
3995
3996
3997
class BananaTwinky(GenericTumblrV1):
3998
    """Class to retrieve Banana Twinky comics."""
3999
    name = 'banana'
4000
    long_name = 'Banana Twinky'
4001
    url = 'http://bananatwinky.tumblr.com'
4002
4003
4004
class YesterdaysPopcornTumblr(GenericTumblrV1):
4005
    """Class to retrieve Yesterday's Popcorn comics."""
4006
    # Also on http://www.yesterdayspopcorn.com
4007
    # Also on https://tapastic.com/series/Yesterdays-Popcorn
4008
    name = 'popcorn-tumblr'
4009
    long_name = 'Yesterday\'s Popcorn (from Tumblr)'
4010
    url = 'http://yesterdayspopcorn.tumblr.com'
4011
4012
4013
class TwistedDoodles(GenericTumblrV1Empty):
4014
    """Class to retrieve Twisted Doodles comics."""
4015
    name = 'twisted'
4016
    long_name = 'Twisted Doodles'
4017
    url = 'http://www.twisteddoodles.com'
4018
4019
4020
class UbertoolTumblr(GenericTumblrV1Empty):
4021
    """Class to retrieve Ubertool comics."""
4022
    # Also on http://ubertoolcomic.com
4023
    # Also on https://tapastic.com/series/ubertool
4024
    name = 'ubertool-tumblr'
4025
    long_name = 'Ubertool (from Tumblr)'
4026
    url = 'http://ubertool.tumblr.com'
4027
    _categories = ('UBERTOOL', )
4028
4029
4030
class LittleLifeLinesTumblr(GenericTumblrV1):
4031
    """Class to retrieve Little Life Lines comics."""
4032
    # Also on http://www.littlelifelines.com
4033
    name = 'life-tumblr'
4034
    long_name = 'Little Life Lines (from Tumblr)'
4035
    url = 'https://little-life-lines.tumblr.com'
4036
4037
4038
class TheyCanTalk(GenericTumblrV1Empty):
4039
    """Class to retrieve They Can Talk comics."""
4040
    name = 'theycantalk'
4041
    long_name = 'They Can Talk'
4042
    url = 'http://theycantalk.com'
4043
4044
4045
class Will5NeverCome(GenericTumblrV1Empty):
4046
    """Class to retrieve Will 5:00 Never Come comics."""
4047
    name = 'will5'
4048
    long_name = 'Will 5:00 Never Come ?'
4049
    url = 'http://will5nevercome.com'
4050
4051
4052
class Sephko(GenericTumblrV1):
4053
    """Class to retrieve Sephko Comics."""
4054
    # Also on http://www.sephko.com
4055
    name = 'sephko'
4056
    long_name = 'Sephko'
4057
    url = 'http://sephko.tumblr.com'
4058
4059
4060
class BlazersAtDawn(GenericTumblrV1):
4061
    """Class to retrieve Blazers At Dawn Comics."""
4062
    name = 'blazers'
4063
    long_name = 'Blazers At Dawn'
4064
    url = 'http://blazersatdawn.tumblr.com'
4065
4066
4067
class ArtByMoga(GenericTumblrV1Empty):
4068
    """Class to retrieve Art By Moga Comics."""
4069
    name = 'moga'
4070
    long_name = 'Art By Moga'
4071
    url = 'http://artbymoga.tumblr.com'
4072
4073
4074
class HorovitzComics(GenericListableComic):
4075
    """Generic class to handle the logic common to the different comics from Horovitz."""
4076
    url = 'http://www.horovitzcomics.com'
4077
    _categories = ('HOROVITZ', )
4078
    img_re = re.compile('.*comics/([0-9]*)/([0-9]*)/([0-9]*)/.*$')
4079
    link_re = NotImplemented
4080
    get_url_from_archive_element = join_cls_url_to_href
4081
4082
    @classmethod
4083
    def get_comic_info(cls, soup, link):
4084
        """Get information about a particular comics."""
4085
        href = link['href']
4086
        num = int(cls.link_re.match(href).groups()[0])
4087
        title = link.string
4088
        imgs = soup.find_all('img', id='comic')
4089
        assert len(imgs) == 1
4090
        year, month, day = [int(s)
4091
                            for s in cls.img_re.match(imgs[0]['src']).groups()]
4092
        return {
4093
            'title': title,
4094
            'day': day,
4095
            'month': month,
4096
            'year': year,
4097
            'img': [i['src'] for i in imgs],
4098
            'num': num,
4099
        }
4100
4101
    @classmethod
4102
    def get_archive_elements(cls):
4103
        archive_url = 'http://www.horovitzcomics.com/comics/archive/'
4104
        return reversed(get_soup_at_url(archive_url).find_all('a', href=cls.link_re))
4105
4106
4107
class HorovitzNew(HorovitzComics):
4108
    """Class to retrieve Horovitz new comics."""
4109
    name = 'horovitznew'
4110
    long_name = 'Horovitz New'
4111
    link_re = re.compile('^/comics/new/([0-9]+)$')
4112
4113
4114
class HorovitzClassic(HorovitzComics):
4115
    """Class to retrieve Horovitz classic comics."""
4116
    name = 'horovitzclassic'
4117
    long_name = 'Horovitz Classic'
4118
    link_re = re.compile('^/comics/classic/([0-9]+)$')
4119
4120
4121
class GenericGoComic(GenericNavigableComic):
4122
    """Generic class to handle the logic common to comics from gocomics.com."""
4123
    _categories = ('GOCOMIC', )
4124
    url_date_re = re.compile('.*/([0-9]*)/([0-9]*)/([0-9]*)$')
4125
4126
    @classmethod
4127
    def get_first_comic_link(cls):
4128
        """Get link to first comics."""
4129
        return get_soup_at_url(cls.url).find('a', class_='beginning')
4130
4131
    @classmethod
4132
    def get_navi_link(cls, last_soup, next_):
4133
        """Get link to next or previous comic."""
4134
        return last_soup.find('a', class_='next' if next_ else 'prev', href=cls.url_date_re)
4135
4136
    @classmethod
4137
    def get_url_from_link(cls, link):
4138
        gocomics = 'http://www.gocomics.com'
4139
        return urljoin_wrapper(gocomics, link['href'])
4140
4141
    @classmethod
4142
    def get_comic_info(cls, soup, link):
4143
        """Get information about a particular comics."""
4144
        url = cls.get_url_from_link(link)
4145
        year, month, day = [int(s)
4146
                            for s in cls.url_date_re.match(url).groups()]
4147
        return {
4148
            'day': day,
4149
            'month': month,
4150
            'year': year,
4151
            'img': [soup.find_all('img', class_='strip')[-1]['src']],
4152
            'author': soup.find('meta', attrs={'name': 'author'})['content']
4153
        }
4154
4155
4156
class PearlsBeforeSwine(GenericGoComic):
4157
    """Class to retrieve Pearls Before Swine comics."""
4158
    name = 'pearls'
4159
    long_name = 'Pearls Before Swine'
4160
    url = 'http://www.gocomics.com/pearlsbeforeswine'
4161
4162
4163
class Peanuts(GenericGoComic):
4164
    """Class to retrieve Peanuts comics."""
4165
    name = 'peanuts'
4166
    long_name = 'Peanuts'
4167
    url = 'http://www.gocomics.com/peanuts'
4168
4169
4170
class MattWuerker(GenericGoComic):
4171
    """Class to retrieve Matt Wuerker comics."""
4172
    name = 'wuerker'
4173
    long_name = 'Matt Wuerker'
4174
    url = 'http://www.gocomics.com/mattwuerker'
4175
4176
4177
class TomToles(GenericGoComic):
4178
    """Class to retrieve Tom Toles comics."""
4179
    name = 'toles'
4180
    long_name = 'Tom Toles'
4181
    url = 'http://www.gocomics.com/tomtoles'
4182
4183
4184
class BreakOfDay(GenericGoComic):
4185
    """Class to retrieve Break Of Day comics."""
4186
    name = 'breakofday'
4187
    long_name = 'Break Of Day'
4188
    url = 'http://www.gocomics.com/break-of-day'
4189
4190
4191
class Brevity(GenericGoComic):
4192
    """Class to retrieve Brevity comics."""
4193
    name = 'brevity'
4194
    long_name = 'Brevity'
4195
    url = 'http://www.gocomics.com/brevity'
4196
4197
4198
class MichaelRamirez(GenericGoComic):
4199
    """Class to retrieve Michael Ramirez comics."""
4200
    name = 'ramirez'
4201
    long_name = 'Michael Ramirez'
4202
    url = 'http://www.gocomics.com/michaelramirez'
4203
4204
4205
class MikeLuckovich(GenericGoComic):
4206
    """Class to retrieve Mike Luckovich comics."""
4207
    name = 'luckovich'
4208
    long_name = 'Mike Luckovich'
4209
    url = 'http://www.gocomics.com/mikeluckovich'
4210
4211
4212
class JimBenton(GenericGoComic):
4213
    """Class to retrieve Jim Benton comics."""
4214
    # Also on http://jimbenton.tumblr.com
4215
    name = 'benton'
4216
    long_name = 'Jim Benton'
4217
    url = 'http://www.gocomics.com/jim-benton-cartoons'
4218
4219
4220
class TheArgyleSweater(GenericGoComic):
4221
    """Class to retrieve the Argyle Sweater comics."""
4222
    name = 'argyle'
4223
    long_name = 'Argyle Sweater'
4224
    url = 'http://www.gocomics.com/theargylesweater'
4225
4226
4227
class SunnyStreet(GenericGoComic):
4228
    """Class to retrieve Sunny Street comics."""
4229
    # Also on http://www.sunnystreetcomics.com
4230
    name = 'sunny'
4231
    long_name = 'Sunny Street'
4232
    url = 'http://www.gocomics.com/sunny-street'
4233
4234
4235
class OffTheMark(GenericGoComic):
4236
    """Class to retrieve Off The Mark comics."""
4237
    # Also on https://www.offthemark.com
4238
    name = 'offthemark'
4239
    long_name = 'Off The Mark'
4240
    url = 'http://www.gocomics.com/offthemark'
4241
4242
4243
class WuMo(GenericGoComic):
4244
    """Class to retrieve WuMo comics."""
4245
    # Also on http://wumo.com
4246
    name = 'wumo'
4247
    long_name = 'WuMo'
4248
    url = 'http://www.gocomics.com/wumo'
4249
4250
4251
class LunarBaboon(GenericGoComic):
4252
    """Class to retrieve Lunar Baboon comics."""
4253
    # Also on http://www.lunarbaboon.com
4254
    # Also on https://tapastic.com/series/Lunarbaboon
4255
    name = 'lunarbaboon'
4256
    long_name = 'Lunar Baboon'
4257
    url = 'http://www.gocomics.com/lunarbaboon'
4258
4259
4260
class SandersenGocomic(GenericGoComic):
4261
    """Class to retrieve Sarah Andersen comics."""
4262
    # Also on http://sarahcandersen.com
4263
    # Also on http://tapastic.com/series/Doodle-Time
4264
    name = 'sandersen-goc'
4265
    long_name = 'Sarah Andersen (from GoComics)'
4266
    url = 'http://www.gocomics.com/sarahs-scribbles'
4267
4268
4269
class SaturdayMorningBreakfastCerealGoComic(GenericGoComic):
4270
    """Class to retrieve Saturday Morning Breakfast Cereal comics."""
4271
    # Also on http://smbc-comics.tumblr.com
4272
    # Also on http://www.smbc-comics.com
4273
    name = 'smbc-goc'
4274
    long_name = 'Saturday Morning Breakfast Cereal (from GoComics)'
4275
    url = 'http://www.gocomics.com/saturday-morning-breakfast-cereal'
4276
    _categories = ('SMBC', )
4277
4278
4279
class CalvinAndHobbesGoComic(GenericGoComic):
4280
    """Class to retrieve Calvin and Hobbes comics."""
4281
    # From gocomics, not http://marcel-oehler.marcellosendos.ch/comics/ch/
4282
    name = 'calvin-goc'
4283
    long_name = 'Calvin and Hobbes (from GoComics)'
4284
    url = 'http://www.gocomics.com/calvinandhobbes'
4285
4286
4287
class RallGoComic(GenericGoComic):
4288
    """Class to retrieve Ted Rall comics."""
4289
    # Also on http://rall.com/comic
4290
    name = 'rall-goc'
4291
    long_name = "Ted Rall (from GoComics)"
4292
    url = "http://www.gocomics.com/tedrall"
4293
    _categories = ('RALL', )
4294
4295
4296
class TheAwkwardYetiGoComic(GenericGoComic):
4297
    """Class to retrieve The Awkward Yeti comics."""
4298
    # Also on http://larstheyeti.tumblr.com
4299
    # Also on http://theawkwardyeti.com
4300
    # Also on https://tapastic.com/series/TheAwkwardYeti
4301
    name = 'yeti-goc'
4302
    long_name = 'The Awkward Yeti (from GoComics)'
4303
    url = 'http://www.gocomics.com/the-awkward-yeti'
4304
    _categories = ('YETI', )
4305
4306
4307
class BerkeleyMewsGoComics(GenericGoComic):
4308
    """Class to retrieve Berkeley Mews comics."""
4309
    # Also on http://mews.tumblr.com
4310
    # Also on http://www.berkeleymews.com
4311
    name = 'berkeley-goc'
4312
    long_name = 'Berkeley Mews (from GoComics)'
4313
    url = 'http://www.gocomics.com/berkeley-mews'
4314
    _categories = ('BERKELEY', )
4315
4316
4317
class SheldonGoComics(GenericGoComic):
4318
    """Class to retrieve Sheldon comics."""
4319
    # Also on http://www.sheldoncomics.com
4320
    name = 'sheldon-goc'
4321
    long_name = 'Sheldon Comics (from GoComics)'
4322
    url = 'http://www.gocomics.com/sheldon'
4323
4324
4325
class FowlLanguageGoComics(GenericGoComic):
4326
    """Class to retrieve Fowl Language comics."""
4327
    # Also on http://www.fowllanguagecomics.com
4328
    # Also on http://tapastic.com/series/Fowl-Language-Comics
4329
    # Also on http://fowllanguagecomics.tumblr.com
4330
    name = 'fowllanguage-goc'
4331
    long_name = 'Fowl Language Comics (from GoComics)'
4332
    url = 'http://www.gocomics.com/fowl-language'
4333
    _categories = ('FOWLLANGUAGE', )
4334
4335
4336
class NickAnderson(GenericGoComic):
4337
    """Class to retrieve Nick Anderson comics."""
4338
    name = 'nickanderson'
4339
    long_name = 'Nick Anderson'
4340
    url = 'http://www.gocomics.com/nickanderson'
4341
4342
4343
class GarfieldGoComics(GenericGoComic):
4344
    """Class to retrieve Garfield comics."""
4345
    # Also on http://garfield.com
4346
    name = 'garfield-goc'
4347
    long_name = 'Garfield (from GoComics)'
4348
    url = 'http://www.gocomics.com/garfield'
4349
    _categories = ('GARFIELD', )
4350
4351
4352
class DorrisMcGoComics(GenericGoComic):
4353
    """Class to retrieve Dorris Mc Comics"""
4354
    # Also on http://dorrismccomics.com
4355
    name = 'dorrismc-goc'
4356
    long_name = 'Dorris Mc (from GoComics)'
4357
    url = 'http://www.gocomics.com/dorris-mccomics'
4358
4359
4360
class FoxTrot(GenericGoComic):
4361
    """Class to retrieve FoxTrot comics."""
4362
    name = 'foxtrot'
4363
    long_name = 'FoxTrot'
4364
    url = 'http://www.gocomics.com/foxtrot'
4365
4366
4367
class FoxTrotClassics(GenericGoComic):
4368
    """Class to retrieve FoxTrot Classics comics."""
4369
    name = 'foxtrot-classics'
4370
    long_name = 'FoxTrot Classics'
4371
    url = 'http://www.gocomics.com/foxtrotclassics'
4372
4373
4374
class MisterAndMeGoComics(GenericGoComic):
4375
    """Class to retrieve Mister & Me Comics."""
4376
    # Also on http://www.mister-and-me.com
4377
    # Also on https://tapastic.com/series/Mister-and-Me
4378
    name = 'mister-goc'
4379
    long_name = 'Mister & Me (from GoComics)'
4380
    url = 'http://www.gocomics.com/mister-and-me'
4381
4382
4383
class NonSequitur(GenericGoComic):
4384
    """Class to retrieve Non Sequitur (Wiley Miller) comics."""
4385
    name = 'nonsequitur'
4386
    long_name = 'Non Sequitur'
4387
    url = 'http://www.gocomics.com/nonsequitur'
4388
4389
4390
class GenericTapasticComic(GenericListableComic):
4391
    """Generic class to handle the logic common to comics from tapastic.com."""
4392
    _categories = ('TAPASTIC', )
4393
4394
    @classmethod
4395
    def get_comic_info(cls, soup, archive_elt):
4396
        """Get information about a particular comics."""
4397
        timestamp = int(archive_elt['publishDate']) / 1000.0
4398
        day = datetime.datetime.fromtimestamp(timestamp).date()
4399
        imgs = soup.find_all('img', class_='art-image')
4400
        if not imgs:
4401
            print("Comic %s is being uploaded, retry later" % cls.get_url_from_archive_element(archive_elt))
4402
            return None
4403
        assert len(imgs) > 0
4404
        return {
4405
            'day': day.day,
4406
            'year': day.year,
4407
            'month': day.month,
4408
            'img': [i['src'] for i in imgs],
4409
            'title': archive_elt['title'],
4410
        }
4411
4412
    @classmethod
4413
    def get_url_from_archive_element(cls, archive_elt):
4414
        return 'http://tapastic.com/episode/' + str(archive_elt['id'])
4415
4416
    @classmethod
4417
    def get_archive_elements(cls):
4418
        pref, suff = 'episodeList : ', ','
4419
        # Information is stored in the javascript part
4420
        # I don't know the clean way to get it so this is the ugly way.
4421
        string = [s[len(pref):-len(suff)] for s in (s.decode('utf-8').strip() for s in urlopen_wrapper(cls.url).readlines()) if s.startswith(pref) and s.endswith(suff)][0]
4422
        return json.loads(string)
4423
4424
4425
class VegetablesForDessert(GenericTapasticComic):
4426
    """Class to retrieve Vegetables For Dessert comics."""
4427
    # Also on http://vegetablesfordessert.tumblr.com
4428
    name = 'vegetables'
4429
    long_name = 'Vegetables For Dessert'
4430
    url = 'http://tapastic.com/series/vegetablesfordessert'
4431
4432
4433
class FowlLanguageTapa(GenericTapasticComic):
4434
    """Class to retrieve Fowl Language comics."""
4435
    # Also on http://www.fowllanguagecomics.com
4436
    # Also on http://fowllanguagecomics.tumblr.com
4437
    # Also on http://www.gocomics.com/fowl-language
4438
    name = 'fowllanguage-tapa'
4439
    long_name = 'Fowl Language Comics (from Tapastic)'
4440
    url = 'http://tapastic.com/series/Fowl-Language-Comics'
4441
    _categories = ('FOWLLANGUAGE', )
4442
4443
4444
class OscillatingProfundities(GenericTapasticComic):
4445
    """Class to retrieve Oscillating Profundities comics."""
4446
    name = 'oscillating'
4447
    long_name = 'Oscillating Profundities'
4448
    url = 'http://tapastic.com/series/oscillatingprofundities'
4449
4450
4451
class ZnoflatsComics(GenericTapasticComic):
4452
    """Class to retrieve Znoflats comics."""
4453
    name = 'znoflats'
4454
    long_name = 'Znoflats Comics'
4455
    url = 'http://tapastic.com/series/Znoflats-Comics'
4456
4457
4458
class SandersenTapastic(GenericTapasticComic):
4459
    """Class to retrieve Sarah Andersen comics."""
4460
    # Also on http://sarahcandersen.com
4461
    # Also on http://www.gocomics.com/sarahs-scribbles
4462
    name = 'sandersen-tapa'
4463
    long_name = 'Sarah Andersen (from Tapastic)'
4464
    url = 'http://tapastic.com/series/Doodle-Time'
4465
4466
4467
class TubeyToonsTapastic(GenericTapasticComic):
4468
    """Class to retrieve TubeyToons comics."""
4469
    # Also on http://tubeytoons.com
4470
    # Also on http://tubeytoons.tumblr.com
4471
    name = 'tubeytoons-tapa'
4472
    long_name = 'Tubey Toons (from Tapastic)'
4473
    url = 'http://tapastic.com/series/Tubey-Toons'
4474
    _categories = ('TUNEYTOONS', )
4475
4476
4477
class AnythingComicTapastic(GenericTapasticComic):
4478
    """Class to retrieve Anything Comics."""
4479
    # Also on http://www.anythingcomic.com
4480
    name = 'anythingcomic-tapa'
4481
    long_name = 'Anything Comic (from Tapastic)'
4482
    url = 'http://tapastic.com/series/anything'
4483
4484
4485
class UnearthedComicsTapastic(GenericTapasticComic):
4486
    """Class to retrieve Unearthed comics."""
4487
    # Also on http://unearthedcomics.com
4488
    # Also on http://unearthedcomics.tumblr.com
4489
    name = 'unearthed-tapa'
4490
    long_name = 'Unearthed Comics (from Tapastic)'
4491
    url = 'http://tapastic.com/series/UnearthedComics'
4492
    _categories = ('UNEARTHED', )
4493
4494
4495
class EverythingsStupidTapastic(GenericTapasticComic):
4496
    """Class to retrieve Everything's stupid Comics."""
4497
    # Also on http://www.webtoons.com/en/challenge/everythings-stupid/list?title_no=14591
4498
    # Also on http://everythingsstupid.net
4499
    name = 'stupid-tapa'
4500
    long_name = "Everything's Stupid (from Tapastic)"
4501
    url = 'http://tapastic.com/series/EverythingsStupid'
4502
4503
4504
class JustSayEhTapastic(GenericTapasticComic):
4505
    """Class to retrieve Just Say Eh comics."""
4506
    # Also on http://www.justsayeh.com
4507
    name = 'justsayeh-tapa'
4508
    long_name = 'Just Say Eh (from Tapastic)'
4509
    url = 'http://tapastic.com/series/Just-Say-Eh'
4510
4511
4512
class ThorsThundershackTapastic(GenericTapasticComic):
4513
    """Class to retrieve Thor's Thundershack comics."""
4514
    # Also on http://www.thorsthundershack.com
4515
    name = 'thor-tapa'
4516
    long_name = 'Thor\'s Thundershack (from Tapastic)'
4517
    url = 'http://tapastic.com/series/Thors-Thundershac'
4518
    _categories = ('THOR', )
4519
4520
4521
class OwlTurdTapastic(GenericTapasticComic):
4522
    """Class to retrieve Owl Turd comics."""
4523
    # Also on http://owlturd.com
4524
    name = 'owlturd-tapa'
4525
    long_name = 'Owl Turd (from Tapastic)'
4526
    url = 'http://tapastic.com/series/Owl-Turd-Comix'
4527
    _categories = ('OWLTURD', )
4528
4529
4530
class GoneIntoRaptureTapastic(GenericTapasticComic):
4531
    """Class to retrieve Gone Into Rapture comics."""
4532
    # Also on http://goneintorapture.tumblr.com
4533
    # Also on http://www.goneintorapture.com
4534
    name = 'rapture-tapa'
4535
    long_name = 'Gone Into Rapture (from Tapastic)'
4536
    url = 'http://tapastic.com/series/Goneintorapture'
4537
4538
4539
class HeckIfIKnowComicsTapa(GenericTapasticComic):
4540
    """Class to retrieve Heck If I Know Comics."""
4541
    # Also on http://heckifiknowcomics.com
4542
    name = 'heck-tapa'
4543
    long_name = 'Heck if I Know comics (from Tapastic)'
4544
    url = 'http://tapastic.com/series/Regular'
4545
4546
4547
class CheerUpEmoKidTapa(GenericTapasticComic):
4548
    """Class to retrieve CheerUpEmoKid comics."""
4549
    # Also on http://www.cheerupemokid.com
4550
    # Also on http://enzocomics.tumblr.com
4551
    name = 'cuek-tapa'
4552
    long_name = 'Cheer Up Emo Kid (from Tapastic)'
4553
    url = 'http://tapastic.com/series/CUEK'
4554
4555
4556
class BigFootJusticeTapa(GenericTapasticComic):
4557
    """Class to retrieve Big Foot Justice comics."""
4558
    # Also on http://bigfootjustice.com
4559
    name = 'bigfoot-tapa'
4560
    long_name = 'Big Foot Justice (from Tapastic)'
4561
    url = 'http://tapastic.com/series/bigfoot-justice'
4562
4563
4564
class UpAndOutTapa(GenericTapasticComic):
4565
    """Class to retrieve Up & Out comics."""
4566
    # Also on http://upandoutcomic.tumblr.com
4567
    name = 'upandout-tapa'
4568
    long_name = 'Up And Out (from Tapastic)'
4569
    url = 'http://tapastic.com/series/UP-and-OUT'
4570
4571
4572
class ToonHoleTapa(GenericTapasticComic):
4573
    """Class to retrieve Toon Holes comics."""
4574
    # Also on http://www.toonhole.com
4575
    name = 'toonhole-tapa'
4576
    long_name = 'Toon Hole (from Tapastic)'
4577
    url = 'http://tapastic.com/series/TOONHOLE'
4578
4579
4580
class AngryAtNothingTapa(GenericTapasticComic):
4581
    """Class to retrieve Angry at Nothing comics."""
4582
    # Also on http://www.angryatnothing.net
4583
    name = 'angry-tapa'
4584
    long_name = 'Angry At Nothing (from Tapastic)'
4585
    url = 'http://tapastic.com/series/Comics-yeah-definitely-comics-'
4586
4587
4588
class LeleozTapa(GenericTapasticComic):
4589
    """Class to retrieve Leleoz comics."""
4590
    # Also on http://leleozcomics.tumblr.com
4591
    name = 'leleoz-tapa'
4592
    long_name = 'Leleoz (from Tapastic)'
4593
    url = 'https://tapastic.com/series/Leleoz'
4594
4595
4596
class TheAwkwardYetiTapa(GenericTapasticComic):
4597
    """Class to retrieve The Awkward Yeti comics."""
4598
    # Also on http://www.gocomics.com/the-awkward-yeti
4599
    # Also on http://theawkwardyeti.com
4600
    # Also on http://larstheyeti.tumblr.com
4601
    name = 'yeti-tapa'
4602
    long_name = 'The Awkward Yeti (from Tapastic)'
4603
    url = 'https://tapastic.com/series/TheAwkwardYeti'
4604
    _categories = ('YETI', )
4605
4606
4607
class AsPerUsualTapa(GenericTapasticComic):
4608
    """Class to retrieve As Per Usual comics."""
4609
    # Also on http://as-per-usual.tumblr.com
4610
    name = 'usual-tapa'
4611
    long_name = 'As Per Usual (from Tapastic)'
4612
    url = 'https://tapastic.com/series/AsPerUsual'
4613
    categories = ('DAMILEE', )
4614
4615
4616
class HotComicsForCoolPeopleTapa(GenericTapasticComic):
4617
    """Class to retrieve Hot Comics For Cool People."""
4618
    # Also on http://hotcomicsforcoolpeople.tumblr.com
4619
    # Also on http://hotcomics.biz (links to tumblr)
4620
    # Also on http://hcfcp.com (links to tumblr)
4621
    name = 'hotcomics-tapa'
4622
    long_name = 'Hot Comics For Cool People (from Tapastic)'
4623
    url = 'https://tapastic.com/series/Hot-Comics-For-Cool-People'
4624
    categories = ('DAMILEE', )
4625
4626
4627
class OneOneOneOneComicTapa(GenericTapasticComic):
4628
    """Class to retrieve 1111 Comics."""
4629
    # Also on http://www.1111comics.me
4630
    # Also on http://comics1111.tumblr.com
4631
    name = '1111-tapa'
4632
    long_name = '1111 Comics (from Tapastic)'
4633
    url = 'https://tapastic.com/series/1111-Comics'
4634
    _categories = ('ONEONEONEONE', )
4635
4636
4637
class TumbleDryTapa(GenericTapasticComic):
4638
    """Class to retrieve Tumble Dry comics."""
4639
    # Also on http://tumbledrycomics.com
4640
    name = 'tumbledry-tapa'
4641
    long_name = 'Tumblr Dry (from Tapastic)'
4642
    url = 'https://tapastic.com/series/TumbleDryComics'
4643
4644
4645
class DeadlyPanelTapa(GenericTapasticComic):
4646
    """Class to retrieve Deadly Panel comics."""
4647
    # Also on http://www.deadlypanel.com
4648
    name = 'deadly-tapa'
4649
    long_name = 'Deadly Panel (from Tapastic)'
4650
    url = 'https://tapastic.com/series/deadlypanel'
4651
4652
4653
class ChrisHallbeckMaxiTapa(GenericTapasticComic):
4654
    """Class to retrieve Chris Hallbeck comics."""
4655
    # Also on http://chrishallbeck.tumblr.com
4656
    # Also on http://maximumble.com
4657
    name = 'hallbeckmaxi-tapa'
4658
    long_name = 'Chris Hallback - Maximumble (from Tapastic)'
4659
    url = 'https://tapastic.com/series/Maximumble'
4660
    _categories = ('HALLBACK', )
4661
4662
4663
class ChrisHallbeckMiniTapa(GenericTapasticComic):
4664
    """Class to retrieve Chris Hallbeck comics."""
4665
    # Also on http://chrishallbeck.tumblr.com
4666
    # Also on http://minimumble.com
4667
    name = 'hallbeckmini-tapa'
4668
    long_name = 'Chris Hallback - Minimumble (from Tapastic)'
4669
    url = 'https://tapastic.com/series/Minimumble'
4670
    _categories = ('HALLBACK', )
4671
4672
4673
class ChrisHallbeckBiffTapa(GenericTapasticComic):
4674
    """Class to retrieve Chris Hallbeck comics."""
4675
    # Also on http://chrishallbeck.tumblr.com
4676
    # Also on http://thebookofbiff.com
4677
    name = 'hallbeckbiff-tapa'
4678
    long_name = 'Chris Hallback - The Book of Biff (from Tapastic)'
4679
    url = 'https://tapastic.com/series/Biff'
4680
    _categories = ('HALLBACK', )
4681
4682
4683
class RandoWisTapa(GenericTapasticComic):
4684
    """Class to retrieve RandoWis comics."""
4685
    # Also on https://randowis.com
4686
    name = 'randowis-tapa'
4687
    long_name = 'RandoWis (from Tapastic)'
4688
    url = 'https://tapastic.com/series/RandoWis'
4689
4690
4691
class PigeonGazetteTapa(GenericTapasticComic):
4692
    """Class to retrieve The Pigeon Gazette comics."""
4693
    # Also on http://thepigeongazette.tumblr.com
4694
    name = 'pigeon-tapa'
4695
    long_name = 'The Pigeon Gazette (from Tapastic)'
4696
    url = 'https://tapastic.com/series/The-Pigeon-Gazette'
4697
4698
4699
class TheOdd1sOutTapa(GenericTapasticComic):
4700
    """Class to retrieve The Odd 1s Out comics."""
4701
    # Also on http://theodd1sout.com
4702
    # Also on http://theodd1sout.tumblr.com
4703
    name = 'theodd-tapa'
4704
    long_name = 'The Odd 1s Out (from Tapastic)'
4705
    url = 'https://tapastic.com/series/Theodd1sout'
4706
4707
4708
class TheWorldIsFlatTapa(GenericTapasticComic):
4709
    """Class to retrieve The World Is Flat Comics."""
4710
    # Also on http://theworldisflatcomics.tumblr.com
4711
    name = 'flatworld-tapa'
4712
    long_name = 'The World Is Flat (from Tapastic)'
4713
    url = 'https://tapastic.com/series/The-World-is-Flat'
4714
4715
4716
class MisterAndMeTapa(GenericTapasticComic):
4717
    """Class to retrieve Mister & Me Comics."""
4718
    # Also on http://www.mister-and-me.com
4719
    # Also on http://www.gocomics.com/mister-and-me
4720
    name = 'mister-tapa'
4721
    long_name = 'Mister & Me (from Tapastic)'
4722
    url = 'https://tapastic.com/series/Mister-and-Me'
4723
4724
4725
class TalesOfAbsurdityTapa(GenericTapasticComic):
4726
    """Class to retrieve Tales Of Absurdity comics."""
4727
    # Also on http://talesofabsurdity.com
4728
    # Also on http://talesofabsurdity.tumblr.com
4729
    name = 'absurdity-tapa'
4730
    long_name = 'Tales of Absurdity (from Tapastic)'
4731
    url = 'http://tapastic.com/series/Tales-Of-Absurdity'
4732
    _categories = ('ABSURDITY', )
4733
4734
4735
class BFGFSTapa(GenericTapasticComic):
4736
    """Class to retrieve BFGFS comics."""
4737
    # Also on http://bfgfs.com
4738
    # Also on http://bfgfs.tumblr.com
4739
    name = 'bfgfs-tapa'
4740
    long_name = 'BFGFS (from Tapastic)'
4741
    url = 'https://tapastic.com/series/BFGFS'
4742
4743
4744
class DoodleForFoodTapa(GenericTapasticComic):
4745
    """Class to retrieve Doodle For Food comics."""
4746
    # Also on http://doodleforfood.com
4747
    name = 'doodle-tapa'
4748
    long_name = 'Doodle For Food (from Tapastic)'
4749
    url = 'https://tapastic.com/series/Doodle-for-Food'
4750
4751
4752
class MrLovensteinTapa(GenericTapasticComic):
4753
    """Class to retrieve Mr Lovenstein comics."""
4754
    # Also on  https://tapastic.com/series/MrLovenstein
4755
    name = 'mrlovenstein-tapa'
4756
    long_name = 'Mr. Lovenstein (from Tapastic)'
4757
    url = 'https://tapastic.com/series/MrLovenstein'
4758
4759
4760
class CassandraCalinTapa(GenericTapasticComic):
4761
    """Class to retrieve C. Cassandra comics."""
4762
    # Also on http://cassandracalin.com
4763
    # Also on http://c-cassandra.tumblr.com
4764
    name = 'cassandra-tapa'
4765
    long_name = 'Cassandra Calin (from Tapastic)'
4766
    url = 'https://tapastic.com/series/C-Cassandra-comics'
4767
4768
4769
class WafflesAndPancakes(GenericTapasticComic):
4770
    """Class to retrieve Waffles And Pancakes comics."""
4771
    # Also on http://wandpcomic.com
4772
    name = 'waffles'
4773
    long_name = 'Waffles And Pancakes'
4774
    url = 'https://tapastic.com/series/Waffles-and-Pancakes'
4775
4776
4777
class YesterdaysPopcornTapastic(GenericTapasticComic):
4778
    """Class to retrieve Yesterday's Popcorn comics."""
4779
    # Also on http://www.yesterdayspopcorn.com
4780
    # Also on http://yesterdayspopcorn.tumblr.com
4781
    name = 'popcorn-tapa'
4782
    long_name = 'Yesterday\'s Popcorn (from Tapastic)'
4783
    url = 'https://tapastic.com/series/Yesterdays-Popcorn'
4784
4785
4786
class OurSuperAdventureTapastic(GenericTapasticComic):
4787
    """Class to retrieve Our Super Adventure comics."""
4788
    # Also on http://www.oursuperadventure.com
4789
    # http://sarahssketchbook.tumblr.com
4790
    # http://sarahgraley.com
4791
    name = 'superadventure-tapastic'
4792
    long_name = 'Our Super Adventure (from Tapastic)'
4793
    url = 'https://tapastic.com/series/Our-Super-Adventure'
4794
4795
4796
class NamelessPCs(GenericTapasticComic):
4797
    """Class to retrieve Nameless PCs comics."""
4798
    # Also on http://namelesspcs.com
4799
    name = 'namelesspcs-tapa'
4800
    long_name = 'NamelessPCs (from Tapastic)'
4801
    url = 'https://tapastic.com/series/NamelessPC'
4802
4803
4804
class UbertoolTapa(GenericTapasticComic):
4805
    """Class to retrieve Ubertool comics."""
4806
    # Also on http://ubertoolcomic.com
4807
    # Also on http://ubertool.tumblr.com
4808
    name = 'ubertool-tapa'
4809
    long_name = 'Ubertool (from Tapastic)'
4810
    url = 'https://tapastic.com/series/ubertool'
4811
    _categories = ('UBERTOOL', )
4812
4813
4814
class SmallBlueYonderTapa(GenericTapasticComic):
4815
    """Class to retrieve Small Blue Yonder comics."""
4816
    # Also on http://www.smallblueyonder.com
4817
    name = 'smallblue-tapa'
4818
    long_name = 'Small Blue Yonder (from Tapastic)'
4819
    url = 'https://tapastic.com/series/Small-Blue-Yonder'
4820
4821
4822
def get_subclasses(klass):
4823
    """Gets the list of direct/indirect subclasses of a class"""
4824
    subclasses = klass.__subclasses__()
4825
    for derived in list(subclasses):
4826
        subclasses.extend(get_subclasses(derived))
4827
    return subclasses
4828
4829
4830
def remove_st_nd_rd_th_from_date(string):
4831
    """Function to transform 1st/2nd/3rd/4th in a parsable date format."""
4832
    # Hackish way to convert string with numeral "1st"/"2nd"/etc to date
4833
    return (string.replace('st', '')
4834
            .replace('nd', '')
4835
            .replace('rd', '')
4836
            .replace('th', '')
4837
            .replace('Augu', 'August'))
4838
4839
4840
def string_to_date(string, date_format, local=DEFAULT_LOCAL):
4841
    """Function to convert string to date object.
4842
    Wrapper around datetime.datetime.strptime."""
4843
    # format described in https://docs.python.org/2/library/datetime.html#strftime-and-strptime-behavior
4844
    prev_locale = locale.setlocale(locale.LC_ALL)
4845
    if local != prev_locale:
4846
        locale.setlocale(locale.LC_ALL, local)
4847
    ret = datetime.datetime.strptime(string, date_format).date()
4848
    if local != prev_locale:
4849
        locale.setlocale(locale.LC_ALL, prev_locale)
4850
    return ret
4851
4852
4853
COMICS = set(get_subclasses(GenericComic))
4854
VALID_COMICS = [c for c in COMICS if c.name is not None]
4855
COMIC_NAMES = {c.name: c for c in VALID_COMICS}
4856
assert len(VALID_COMICS) == len(COMIC_NAMES)
4857
CLASS_NAMES = {c.__name__ for c in VALID_COMICS}
4858
assert len(VALID_COMICS) == len(CLASS_NAMES)
4859