Code Duplication    Length = 18-20 lines in 9 locations

comics.py 9 locations

@@ 2461-2480 (lines=20) @@
2458
                return link
2459
        return None
2460
2461
    @classmethod
2462
    def get_comic_info(cls, soup, link):
2463
        """Get information about a particular comics."""
2464
        title = soup.find('meta', attrs={'name': 'description'})["content"]
2465
        description = soup.find('div', itemprop='articleBody').text
2466
        author = soup.find('span', itemprop='author copyrightHolder').string
2467
        imgs = soup.find_all('img', itemprop='image')
2468
        assert all(i['title'] == i['alt'] for i in imgs)
2469
        alt = imgs[0]['alt'] if imgs else ""
2470
        date_str = soup.find('time', itemprop='datePublished')["datetime"]
2471
        day = string_to_date(date_str, "%Y-%m-%d %H:%M:%S")
2472
        return {
2473
            'img': [urljoin_wrapper(cls.url, i['src']) for i in imgs],
2474
            'month': day.month,
2475
            'year': day.year,
2476
            'day': day.day,
2477
            'author': author,
2478
            'title': title,
2479
            'alt': alt,
2480
            'description': description,
2481
        }
2482
2483
@@ 2660-2678 (lines=19) @@
2657
    get_first_comic_link = get_a_comicnavbase_comicnavfirst
2658
    get_navi_link = get_link_rel_next
2659
2660
    @classmethod
2661
    def get_comic_info(cls, soup, link):
2662
        """Get information about a particular comics."""
2663
        title = soup.find('h2', class_='post-title').string
2664
        author = soup.find("span", class_="post-author").find("a").string
2665
        date_str = soup.find("span", class_="post-date").string
2666
        day = string_to_date(date_str, "%B %d, %Y")
2667
        imgs = soup.find("div", id="comic").find_all("img")
2668
        assert all(i['alt'] == i['title'] for i in imgs)
2669
        assert len(imgs) <= 1, imgs
2670
        alt = imgs[0]['alt'] if imgs else ""
2671
        return {
2672
            'img': [i['src'] for i in imgs],
2673
            'title': title,
2674
            'alt': alt,
2675
            'author': author,
2676
            'day': day.day,
2677
            'month': day.month,
2678
            'year': day.year
2679
        }
2680
2681
@@ 2630-2648 (lines=19) @@
2627
    get_first_comic_link = get_a_comicnavbase_comicnavfirst
2628
    get_navi_link = get_link_rel_next
2629
2630
    @classmethod
2631
    def get_comic_info(cls, soup, link):
2632
        """Get information about a particular comics."""
2633
        title = soup.find('h2', class_='post-title').string
2634
        author = soup.find("span", class_="post-author").find("a").string
2635
        date_str = soup.find("span", class_="post-date").string
2636
        day = string_to_date(date_str, "%B %d, %Y")
2637
        imgs = soup.find("div", id="comic").find_all("img")
2638
        assert all(i['alt'] == i['title'] for i in imgs)
2639
        assert len(imgs) <= 1, imgs
2640
        alt = imgs[0]['alt'] if imgs else ""
2641
        return {
2642
            'img': [i['src'] for i in imgs],
2643
            'title': title,
2644
            'alt': alt,
2645
            'author': author,
2646
            'day': day.day,
2647
            'month': day.month,
2648
            'year': day.year
2649
        }
2650
2651
@@ 2549-2567 (lines=19) @@
2546
    get_first_comic_link = get_a_navi_navifirst
2547
    get_navi_link = get_link_rel_next
2548
2549
    @classmethod
2550
    def get_comic_info(cls, soup, link):
2551
        """Get information about a particular comics."""
2552
        title = soup.find("h1", class_="entry-title").string
2553
        author = soup.find("span", class_="author vcard").find("a").string
2554
        date_str = soup.find("span", class_="entry-date").string
2555
        day = string_to_date(date_str, "%B %d, %Y")
2556
        imgs = soup.find("div", id="comic").find_all("img")
2557
        assert all(i['alt'] == i['title'] for i in imgs)
2558
        assert len(imgs) == 1, imgs
2559
        alt = imgs[0]['alt']
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
@@ 2024-2042 (lines=19) @@
2021
    get_first_comic_link = get_a_navi_navifirst
2022
    get_navi_link = get_a_navi_navinext
2023
2024
    @classmethod
2025
    def get_comic_info(cls, soup, link):
2026
        """Get information about a particular comics."""
2027
        title = soup.find('h2', class_='post-title').string
2028
        author = soup.find('span', class_='post-author').contents[1].string
2029
        date_str = soup.find('span', class_='post-date').string
2030
        day = string_to_date(date_str, '%B %d, %Y')
2031
        imgs = soup.find('div', class_='comicpane').find_all('img')
2032
        assert imgs
2033
        alt = imgs[0]['title']
2034
        assert all(i['title'] == i['alt'] == alt for i in imgs)
2035
        return {
2036
            'month': day.month,
2037
            'year': day.year,
2038
            'day': day.day,
2039
            'img': [i['src'] for i in imgs],
2040
            'title': title,
2041
            'alt': alt,
2042
            'author': author,
2043
        }
2044
2045
@@ 2722-2739 (lines=18) @@
2719
    get_first_comic_link = get_a_navi_navifirst
2720
    get_navi_link = get_link_rel_next
2721
2722
    @classmethod
2723
    def get_comic_info(cls, soup, link):
2724
        """Get information about a particular comics."""
2725
        title = soup.find('h2', class_='post-title').string
2726
        author = soup.find("span", class_="post-author").find("a").string
2727
        date_str = soup.find("span", class_="post-date").string
2728
        day = string_to_date(date_str, "%B %d, %Y")
2729
        imgs = soup.find("div", id="comic").find_all("img")
2730
        assert all(i['alt'] == i['title'] for i in imgs)
2731
        alt = imgs[0]['alt'] if imgs else ""
2732
        return {
2733
            'img': [i['src'] for i in imgs],
2734
            'title': title,
2735
            'alt': alt,
2736
            'author': author,
2737
            'day': day.day,
2738
            'month': day.month,
2739
            'year': day.year
2740
        }
2741
2742
@@ 2693-2710 (lines=18) @@
2690
    get_first_comic_link = get_a_navi_navifirst
2691
    get_navi_link = get_a_navi_comicnavnext_navinext
2692
2693
    @classmethod
2694
    def get_comic_info(cls, soup, link):
2695
        """Get information about a particular comics."""
2696
        title = soup.find('h2', class_='post-title').string
2697
        author = soup.find("span", class_="post-author").find("a").string
2698
        date_str = soup.find("span", class_="post-date").string
2699
        day = string_to_date(date_str, "%B %d, %Y")
2700
        imgs = soup.find("div", id="comic").find_all("img")
2701
        assert all(i['alt'] == i['title'] for i in imgs)
2702
        alt = imgs[0]['alt'] if imgs else ""
2703
        return {
2704
            'img': [i['src'] for i in imgs],
2705
            'title': title,
2706
            'alt': alt,
2707
            'author': author,
2708
            'day': day.day,
2709
            'month': day.month,
2710
            'year': day.year
2711
        }
2712
2713
@@ 2492-2509 (lines=18) @@
2489
    get_first_comic_link = get_a_navi_navifirst
2490
    get_navi_link = get_a_rel_next
2491
2492
    @classmethod
2493
    def get_comic_info(cls, soup, link):
2494
        """Get information about a particular comics."""
2495
        title = soup.find('h2', class_='post-title').string
2496
        author = soup.find("span", class_="post-author").find("a").string
2497
        date_str = soup.find("span", class_="post-date").string
2498
        day = string_to_date(date_str, "%B %d, %Y")
2499
        imgs = soup.find("div", id="comic").find_all("img")
2500
        alt = imgs[0]['alt']
2501
        assert all(i['alt'] == i['title'] == alt for i in imgs)
2502
        return {
2503
            'img': [i['src'] for i in imgs],
2504
            'title': title,
2505
            'alt': alt,
2506
            'author': author,
2507
            'day': day.day,
2508
            'month': day.month,
2509
            'year': day.year
2510
        }
2511
2512
@@ 983-1000 (lines=18) @@
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