Code Duplication    Length = 18-20 lines in 9 locations

comics.py 9 locations

@@ 2479-2498 (lines=20) @@
2476
                return link
2477
        return None
2478
2479
    @classmethod
2480
    def get_comic_info(cls, soup, link):
2481
        """Get information about a particular comics."""
2482
        title = soup.find('meta', attrs={'name': 'description'})["content"]
2483
        description = soup.find('div', itemprop='articleBody').text
2484
        author = soup.find('span', itemprop='author copyrightHolder').string
2485
        imgs = soup.find_all('img', itemprop='image')
2486
        assert all(i['title'] == i['alt'] for i in imgs)
2487
        alt = imgs[0]['alt'] if imgs else ""
2488
        date_str = soup.find('time', itemprop='datePublished')["datetime"]
2489
        day = string_to_date(date_str, "%Y-%m-%d %H:%M:%S")
2490
        return {
2491
            'img': [urljoin_wrapper(cls.url, i['src']) for i in imgs],
2492
            'month': day.month,
2493
            'year': day.year,
2494
            'day': day.day,
2495
            'author': author,
2496
            'title': title,
2497
            'alt': alt,
2498
            'description': description,
2499
        }
2500
2501
@@ 2678-2696 (lines=19) @@
2675
    get_first_comic_link = get_a_comicnavbase_comicnavfirst
2676
    get_navi_link = get_link_rel_next
2677
2678
    @classmethod
2679
    def get_comic_info(cls, soup, link):
2680
        """Get information about a particular comics."""
2681
        title = soup.find('h2', class_='post-title').string
2682
        author = soup.find("span", class_="post-author").find("a").string
2683
        date_str = soup.find("span", class_="post-date").string
2684
        day = string_to_date(date_str, "%B %d, %Y")
2685
        imgs = soup.find("div", id="comic").find_all("img")
2686
        assert all(i['alt'] == i['title'] for i in imgs)
2687
        assert len(imgs) <= 1
2688
        alt = imgs[0]['alt'] if imgs else ""
2689
        return {
2690
            'img': [i['src'] for i in imgs],
2691
            'title': title,
2692
            'alt': alt,
2693
            'author': author,
2694
            'day': day.day,
2695
            'month': day.month,
2696
            'year': day.year
2697
        }
2698
2699
@@ 2648-2666 (lines=19) @@
2645
    get_first_comic_link = get_a_comicnavbase_comicnavfirst
2646
    get_navi_link = get_link_rel_next
2647
2648
    @classmethod
2649
    def get_comic_info(cls, soup, link):
2650
        """Get information about a particular comics."""
2651
        title = soup.find('h2', class_='post-title').string
2652
        author = soup.find("span", class_="post-author").find("a").string
2653
        date_str = soup.find("span", class_="post-date").string
2654
        day = string_to_date(date_str, "%B %d, %Y")
2655
        imgs = soup.find("div", id="comic").find_all("img")
2656
        assert all(i['alt'] == i['title'] for i in imgs)
2657
        assert len(imgs) <= 1
2658
        alt = imgs[0]['alt'] if imgs else ""
2659
        return {
2660
            'img': [i['src'] for i in imgs],
2661
            'title': title,
2662
            'alt': alt,
2663
            'author': author,
2664
            'day': day.day,
2665
            'month': day.month,
2666
            'year': day.year
2667
        }
2668
2669
@@ 2567-2585 (lines=19) @@
2564
    get_first_comic_link = get_a_navi_navifirst
2565
    get_navi_link = get_link_rel_next
2566
2567
    @classmethod
2568
    def get_comic_info(cls, soup, link):
2569
        """Get information about a particular comics."""
2570
        title = soup.find("h1", class_="entry-title").string
2571
        author = soup.find("span", class_="author vcard").find("a").string
2572
        date_str = soup.find("span", class_="entry-date").string
2573
        day = string_to_date(date_str, "%B %d, %Y")
2574
        imgs = soup.find("div", id="comic").find_all("img")
2575
        assert all(i['alt'] == i['title'] for i in imgs)
2576
        assert len(imgs) == 1
2577
        alt = imgs[0]['alt']
2578
        return {
2579
            'img': [i['src'] for i in imgs],
2580
            'title': title,
2581
            'alt': alt,
2582
            'author': author,
2583
            'day': day.day,
2584
            'month': day.month,
2585
            'year': day.year
2586
        }
2587
2588
@@ 2041-2059 (lines=19) @@
2038
    get_first_comic_link = get_a_navi_navifirst
2039
    get_navi_link = get_a_navi_navinext
2040
2041
    @classmethod
2042
    def get_comic_info(cls, soup, link):
2043
        """Get information about a particular comics."""
2044
        title = soup.find('h2', class_='post-title').string
2045
        author = soup.find('span', class_='post-author').contents[1].string
2046
        date_str = soup.find('span', class_='post-date').string
2047
        day = string_to_date(date_str, '%B %d, %Y')
2048
        imgs = soup.find('div', class_='comicpane').find_all('img')
2049
        assert imgs
2050
        alt = imgs[0]['title']
2051
        assert all(i['title'] == i['alt'] == alt for i in imgs)
2052
        return {
2053
            'month': day.month,
2054
            'year': day.year,
2055
            'day': day.day,
2056
            'img': [i['src'] for i in imgs],
2057
            'title': title,
2058
            'alt': alt,
2059
            'author': author,
2060
        }
2061
2062
@@ 2740-2757 (lines=18) @@
2737
    get_first_comic_link = get_a_navi_navifirst
2738
    get_navi_link = get_link_rel_next
2739
2740
    @classmethod
2741
    def get_comic_info(cls, soup, link):
2742
        """Get information about a particular comics."""
2743
        title = soup.find('h2', class_='post-title').string
2744
        author = soup.find("span", class_="post-author").find("a").string
2745
        date_str = soup.find("span", class_="post-date").string
2746
        day = string_to_date(date_str, "%B %d, %Y")
2747
        imgs = soup.find("div", id="comic").find_all("img")
2748
        assert all(i['alt'] == i['title'] for i in imgs)
2749
        alt = imgs[0]['alt'] if imgs else ""
2750
        return {
2751
            'img': [i['src'] for i in imgs],
2752
            'title': title,
2753
            'alt': alt,
2754
            'author': author,
2755
            'day': day.day,
2756
            'month': day.month,
2757
            'year': day.year
2758
        }
2759
2760
@@ 2711-2728 (lines=18) @@
2708
    get_first_comic_link = get_a_navi_navifirst
2709
    get_navi_link = get_a_navi_comicnavnext_navinext
2710
2711
    @classmethod
2712
    def get_comic_info(cls, soup, link):
2713
        """Get information about a particular comics."""
2714
        title = soup.find('h2', class_='post-title').string
2715
        author = soup.find("span", class_="post-author").find("a").string
2716
        date_str = soup.find("span", class_="post-date").string
2717
        day = string_to_date(date_str, "%B %d, %Y")
2718
        imgs = soup.find("div", id="comic").find_all("img")
2719
        assert all(i['alt'] == i['title'] for i in imgs)
2720
        alt = imgs[0]['alt'] if imgs else ""
2721
        return {
2722
            'img': [i['src'] for i in imgs],
2723
            'title': title,
2724
            'alt': alt,
2725
            'author': author,
2726
            'day': day.day,
2727
            'month': day.month,
2728
            'year': day.year
2729
        }
2730
2731
@@ 2510-2527 (lines=18) @@
2507
    get_first_comic_link = get_a_navi_navifirst
2508
    get_navi_link = get_a_rel_next
2509
2510
    @classmethod
2511
    def get_comic_info(cls, soup, link):
2512
        """Get information about a particular comics."""
2513
        title = soup.find('h2', class_='post-title').string
2514
        author = soup.find("span", class_="post-author").find("a").string
2515
        date_str = soup.find("span", class_="post-date").string
2516
        day = string_to_date(date_str, "%B %d, %Y")
2517
        imgs = soup.find("div", id="comic").find_all("img")
2518
        alt = imgs[0]['alt']
2519
        assert all(i['alt'] == i['title'] == alt for i in imgs)
2520
        return {
2521
            'img': [i['src'] for i in imgs],
2522
            'title': title,
2523
            'alt': alt,
2524
            'author': author,
2525
            'day': day.day,
2526
            'month': day.month,
2527
            'year': day.year
2528
        }
2529
2530
@@ 964-981 (lines=18) @@
961
    get_first_comic_link = get_div_navfirst_a
962
    get_navi_link = get_a_rel_next
963
964
    @classmethod
965
    def get_comic_info(cls, soup, link):
966
        """Get information about a particular comics."""
967
        title = soup.find('h2', class_='post-title').string
968
        author = soup.find("span", class_="post-author").find("a").string
969
        date_str = soup.find('span', class_='post-date').string
970
        day = string_to_date(date_str, '%B %d, %Y')
971
        imgs = soup.find('div', class_='comicpane').find_all('img')
972
        assert all(i['alt'] == i['title'] for i in imgs)
973
        title2 = imgs[0]['title']
974
        return {
975
            'day': day.day,
976
            'month': day.month,
977
            'year': day.year,
978
            'img': [i['src'] for i in imgs],
979
            'title': title,
980
            'title2': title2,
981
            'author': author,
982
        }
983
984