Completed
Push — master ( 443e2d...44ac5a )
by De
27s
created

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