Completed
Push — master ( 886efd...4f4d42 )
by De
01:15
created

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