File: common.py

package info (click to toggle)
dosage 3.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,400 kB
  • sloc: python: 12,703; sh: 55; makefile: 6
file content (55 lines) | stat: -rw-r--r-- 1,767 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# SPDX-License-Identifier: MIT
# Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs
# Copyright (C) 2012-2014 Bastian Kleineidam
# Copyright (C) 2015-2022 Tobias Gruetzmacher
# Copyright (C) 2019-2020 Daniel Ring
from typing import Sequence, Union

from ..scraper import ParserScraper

# Common base classes for comics with the same structure (same hosting
# software, for example) go here. Since those are shared by many modules,
# please don't use lists of expression, as that makes it hard to track which
# expression is for which comics.
__all__ = (
    'ComicControlScraper',
    'WordPressNavi',
    'WordPressNaviIn',
    'WordPressScraper',
    'WordPressSpliced',
    'WordPressWebcomic',
)


class ComicControlScraper(ParserScraper):
    imageSearch: Union[Sequence[str], str] = '//img[@id="cc-comic"]'
    prevSearch = '//a[@rel="prev"]'
    nextSearch = '//a[@rel="next"]'
    latestSearch = '//a[@rel="last"]'


class WordPressScraper(ParserScraper):
    imageSearch = '//div[@id="comic"]//img'
    prevSearch = '//a[d:class("comic-nav-previous")]'
    nextSearch = '//a[d:class("comic-nav-next")]'
    latestSearch = '//a[d:class("comic-nav-last")]'


class WordPressSpliced(ParserScraper):
    imageSearch = '//div[@id="one-comic-option"]//img'
    prevSearch = '//a[d:class("previous-comic")]'


class WordPressNavi(WordPressScraper):
    prevSearch = '//a[d:class("navi-prev")]'


class WordPressNaviIn(WordPressScraper):
    prevSearch = '//a[d:class("navi-prev-in")]'


class WordPressWebcomic(ParserScraper):
    imageSearch = '//div[d:class("webcomic-image")]//img'
    prevSearch = '//a[d:class("previous-webcomic-link")]'
    nextSearch = '///a[d:class("next-webcomic-link")]'
    latestSearch = '//a[d:class("last-webcomic-link")]'