Code Duplication    Length = 18-20 lines in 9 locations

comics.py 9 locations

@@ 2397-2416 (lines=20) @@
2394
                return link
2395
        return None
2396
2397
    @classmethod
2398
    def get_comic_info(cls, soup, link):
2399
        """Get information about a particular comics."""
2400
        title = soup.find('meta', attrs={'name': 'description'})["content"]
2401
        description = soup.find('div', itemprop='articleBody').text
2402
        author = soup.find('span', itemprop='author copyrightHolder').string
2403
        imgs = soup.find_all('img', itemprop='image')
2404
        assert all(i['title'] == i['alt'] for i in imgs)
2405
        alt = imgs[0]['alt'] if imgs else ""
2406
        date_str = soup.find('time', itemprop='datePublished')["datetime"]
2407
        day = string_to_date(date_str, "%Y-%m-%d %H:%M:%S")
2408
        return {
2409
            'img': [urljoin_wrapper(cls.url, i['src']) for i in imgs],
2410
            'month': day.month,
2411
            'year': day.year,
2412
            'day': day.day,
2413
            'author': author,
2414
            'title': title,
2415
            'alt': alt,
2416
            'description': description,
2417
        }
2418
2419
@@ 2596-2614 (lines=19) @@
2593
    get_first_comic_link = get_a_comicnavbase_comicnavfirst
2594
    get_navi_link = get_link_rel_next
2595
2596
    @classmethod
2597
    def get_comic_info(cls, soup, link):
2598
        """Get information about a particular comics."""
2599
        title = soup.find('h2', class_='post-title').string
2600
        author = soup.find("span", class_="post-author").find("a").string
2601
        date_str = soup.find("span", class_="post-date").string
2602
        day = string_to_date(date_str, "%B %d, %Y")
2603
        imgs = soup.find("div", id="comic").find_all("img")
2604
        assert all(i['alt'] == i['title'] for i in imgs)
2605
        assert len(imgs) <= 1
2606
        alt = imgs[0]['alt'] if imgs else ""
2607
        return {
2608
            'img': [i['src'] for i in imgs],
2609
            'title': title,
2610
            'alt': alt,
2611
            'author': author,
2612
            'day': day.day,
2613
            'month': day.month,
2614
            'year': day.year
2615
        }
2616
2617
@@ 2566-2584 (lines=19) @@
2563
    get_first_comic_link = get_a_comicnavbase_comicnavfirst
2564
    get_navi_link = get_link_rel_next
2565
2566
    @classmethod
2567
    def get_comic_info(cls, soup, link):
2568
        """Get information about a particular comics."""
2569
        title = soup.find('h2', class_='post-title').string
2570
        author = soup.find("span", class_="post-author").find("a").string
2571
        date_str = soup.find("span", class_="post-date").string
2572
        day = string_to_date(date_str, "%B %d, %Y")
2573
        imgs = soup.find("div", id="comic").find_all("img")
2574
        assert all(i['alt'] == i['title'] for i in imgs)
2575
        assert len(imgs) <= 1
2576
        alt = imgs[0]['alt'] if imgs else ""
2577
        return {
2578
            'img': [i['src'] for i in imgs],
2579
            'title': title,
2580
            'alt': alt,
2581
            'author': author,
2582
            'day': day.day,
2583
            'month': day.month,
2584
            'year': day.year
2585
        }
2586
2587
@@ 2485-2503 (lines=19) @@
2482
    get_first_comic_link = get_a_navi_navifirst
2483
    get_navi_link = get_link_rel_next
2484
2485
    @classmethod
2486
    def get_comic_info(cls, soup, link):
2487
        """Get information about a particular comics."""
2488
        title = soup.find("h1", class_="entry-title").string
2489
        author = soup.find("span", class_="author vcard").find("a").string
2490
        date_str = soup.find("span", class_="entry-date").string
2491
        day = string_to_date(date_str, "%B %d, %Y")
2492
        imgs = soup.find("div", id="comic").find_all("img")
2493
        assert all(i['alt'] == i['title'] for i in imgs)
2494
        assert len(imgs) == 1
2495
        alt = imgs[0]['alt']
2496
        return {
2497
            'img': [i['src'] for i in imgs],
2498
            'title': title,
2499
            'alt': alt,
2500
            'author': author,
2501
            'day': day.day,
2502
            'month': day.month,
2503
            'year': day.year
2504
        }
2505
2506
@@ 2011-2029 (lines=19) @@
2008
    get_first_comic_link = get_a_navi_navifirst
2009
    get_navi_link = get_a_navi_navinext
2010
2011
    @classmethod
2012
    def get_comic_info(cls, soup, link):
2013
        """Get information about a particular comics."""
2014
        title = soup.find('h2', class_='post-title').string
2015
        author = soup.find('span', class_='post-author').contents[1].string
2016
        date_str = soup.find('span', class_='post-date').string
2017
        day = string_to_date(date_str, '%B %d, %Y')
2018
        imgs = soup.find('div', class_='comicpane').find_all('img')
2019
        assert imgs
2020
        alt = imgs[0]['title']
2021
        assert all(i['title'] == i['alt'] == alt for i in imgs)
2022
        return {
2023
            'month': day.month,
2024
            'year': day.year,
2025
            'day': day.day,
2026
            'img': [i['src'] for i in imgs],
2027
            'title': title,
2028
            'alt': alt,
2029
            'author': author,
2030
        }
2031
2032
@@ 2658-2675 (lines=18) @@
2655
    get_first_comic_link = get_a_navi_navifirst
2656
    get_navi_link = get_link_rel_next
2657
2658
    @classmethod
2659
    def get_comic_info(cls, soup, link):
2660
        """Get information about a particular comics."""
2661
        title = soup.find('h2', class_='post-title').string
2662
        author = soup.find("span", class_="post-author").find("a").string
2663
        date_str = soup.find("span", class_="post-date").string
2664
        day = string_to_date(date_str, "%B %d, %Y")
2665
        imgs = soup.find("div", id="comic").find_all("img")
2666
        assert all(i['alt'] == i['title'] for i in imgs)
2667
        alt = imgs[0]['alt'] if imgs else ""
2668
        return {
2669
            'img': [i['src'] for i in imgs],
2670
            'title': title,
2671
            'alt': alt,
2672
            'author': author,
2673
            'day': day.day,
2674
            'month': day.month,
2675
            'year': day.year
2676
        }
2677
2678
@@ 2629-2646 (lines=18) @@
2626
    get_first_comic_link = get_a_navi_navifirst
2627
    get_navi_link = get_a_navi_comicnavnext_navinext
2628
2629
    @classmethod
2630
    def get_comic_info(cls, soup, link):
2631
        """Get information about a particular comics."""
2632
        title = soup.find('h2', class_='post-title').string
2633
        author = soup.find("span", class_="post-author").find("a").string
2634
        date_str = soup.find("span", class_="post-date").string
2635
        day = string_to_date(date_str, "%B %d, %Y")
2636
        imgs = soup.find("div", id="comic").find_all("img")
2637
        assert all(i['alt'] == i['title'] for i in imgs)
2638
        alt = imgs[0]['alt'] if imgs else ""
2639
        return {
2640
            'img': [i['src'] for i in imgs],
2641
            'title': title,
2642
            'alt': alt,
2643
            'author': author,
2644
            'day': day.day,
2645
            'month': day.month,
2646
            'year': day.year
2647
        }
2648
2649
@@ 2428-2445 (lines=18) @@
2425
    get_first_comic_link = get_a_navi_navifirst
2426
    get_navi_link = get_a_rel_next
2427
2428
    @classmethod
2429
    def get_comic_info(cls, soup, link):
2430
        """Get information about a particular comics."""
2431
        title = soup.find('h2', class_='post-title').string
2432
        author = soup.find("span", class_="post-author").find("a").string
2433
        date_str = soup.find("span", class_="post-date").string
2434
        day = string_to_date(date_str, "%B %d, %Y")
2435
        imgs = soup.find("div", id="comic").find_all("img")
2436
        alt = imgs[0]['alt']
2437
        assert all(i['alt'] == i['title'] == alt for i in imgs)
2438
        return {
2439
            'img': [i['src'] for i in imgs],
2440
            'title': title,
2441
            'alt': alt,
2442
            'author': author,
2443
            'day': day.day,
2444
            'month': day.month,
2445
            'year': day.year
2446
        }
2447
2448
@@ 934-951 (lines=18) @@
931
    get_first_comic_link = get_div_navfirst_a
932
    get_navi_link = get_a_rel_next
933
934
    @classmethod
935
    def get_comic_info(cls, soup, link):
936
        """Get information about a particular comics."""
937
        title = soup.find('h2', class_='post-title').string
938
        author = soup.find("span", class_="post-author").find("a").string
939
        date_str = soup.find('span', class_='post-date').string
940
        day = string_to_date(date_str, '%B %d, %Y')
941
        imgs = soup.find('div', class_='comicpane').find_all('img')
942
        assert all(i['alt'] == i['title'] for i in imgs)
943
        title2 = imgs[0]['title']
944
        return {
945
            'day': day.day,
946
            'month': day.month,
947
            'year': day.year,
948
            'img': [i['src'] for i in imgs],
949
            'title': title,
950
            'title2': title2,
951
            'author': author,
952
        }
953
954