File: wrongside.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 (75 lines) | stat: -rw-r--r-- 2,902 bytes parent folder | download
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: © 2019 Tobias Gruetzmacher
# SPDX-FileCopyrightText: © 2019 Daniel Ring
from ..scraper import ParserScraper
from ..helpers import indirectStarter


class Wrongside(ParserScraper):
    baseUrl = 'http://ayzewi.com/maingallery3/'
    url = baseUrl + 'index.php?/category/5'
    stripUrl = baseUrl + 'picture.php?%s'
    firstStripUrl = stripUrl % '/175/category/21'
    imageSearch = '//img[@id="theMainImage"]/@src'
    prevSearch = '//a[contains(@title, "Previous :")]'

    def starter(self):
        archivePage = self.getPage(self.url)
        chapterUrls = self.match(archivePage, '//ul[d:class("albThumbs")]//a/@href')
        self.archive = []
        for chapterUrl in chapterUrls:
            chapterPage = self.getPage(chapterUrl)
            self.archive.append(self.match(chapterPage, '(//ul[@id="thumbnails"]//a/@href)[last()]')[0])
        return self.archive[0]

    def getPrevUrl(self, url, data):
        if self.match(data, self.prevSearch) == [] and len(self.archive) > 0:
            return self.archive.pop()
        return super(Wrongside, self).getPrevUrl(url, data)

    def namer(self, imageUrl, pageUrl):
        page = self.getPage(pageUrl)
        title = self.match(page, '//div[d:class("browsePath")]/h2/text()')[0]
        return title.replace('"', '') + '.' + imageUrl.rsplit('.', 1)[-1]


class WrongsideBeginnings(Wrongside):
    name = 'Wrongside/Beginnings'
    baseUrl = 'http://ayzewi.com/maingallery3/'
    url = baseUrl + 'index.php?/category/4'
    stripUrl = baseUrl + 'picture.php?%s'
    firstStripUrl = stripUrl % '/2/category/18'


class WrongsideSideStories(ParserScraper):
    baseUrl = 'http://ayzewi.com/maingallery3/'
    stripUrl = baseUrl + 'picture.php?%s'
    imageSearch = '//img[@id="theMainImage"]/@src'
    prevSearch = '//a[contains(@title, "Previous :")]'
    latestSearch = '(//ul[@id="thumbnails"]//a/@href)[last()]'
    starter = indirectStarter

    def __init__(self, name, category, first, last=None):
        super().__init__('Wrongside/' + name)
        self.url = self.baseUrl + 'index.php?/category/' + category
        self.firstStripUrl = self.stripUrl % ('/' + first + '/category/' + category)

        if last:
            self.endOfLife = True

    @classmethod
    def getmodules(cls):
        return (
            cls('AnarkisRising', '7', '302'),
            cls('CommonsDreams', '9', '324'),
            cls('Faith', '11', '349'),
            cls('Sarah', '10', '337'),
            cls('ThereAreNoAviansHere', '8', '313'),
            cls('TheScientificProphet', '13', '358'),
            cls('TheStrangers', '12', '361'),
        )

    def namer(self, imageUrl, pageUrl):
        page = self.getPage(pageUrl)
        title = self.match(page, '//div[d:class("browsePath")]/h2/text()')[0]
        return title.replace('"', '') + '.' + imageUrl.rsplit('.', 1)[-1]