diff options
| author | 2014-12-05 10:56:05 +0100 | |
|---|---|---|
| committer | 2014-12-05 10:56:05 +0100 | |
| commit | 3d5aa943fafd4c84261465ba17b402dd07e5a2d5 (patch) | |
| tree | 66622255f6ddc233a81ebe91a585c281872c663a /module/plugins | |
| parent | Merge pull request #946 from AndroKev/premiumTo (diff) | |
| download | pyload-3d5aa943fafd4c84261465ba17b402dd07e5a2d5.tar.xz | |
[FastshareCz] Cleanup
Diffstat (limited to 'module/plugins')
| -rw-r--r-- | module/plugins/hoster/FastshareCz.py | 67 | 
1 files changed, 29 insertions, 38 deletions
| diff --git a/module/plugins/hoster/FastshareCz.py b/module/plugins/hoster/FastshareCz.py index 14931f681..8b01b5edd 100644 --- a/module/plugins/hoster/FastshareCz.py +++ b/module/plugins/hoster/FastshareCz.py @@ -1,7 +1,4 @@  # -*- coding: utf-8 -*- -# -# Test links: -# http://www.fastshare.cz/2141189/random.bin  import re @@ -13,33 +10,41 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo  class FastshareCz(SimpleHoster):      __name__    = "FastshareCz"      __type__    = "hoster" -    __version__ = "0.23" +    __version__ = "0.24"      __pattern__ = r'http://(?:www\.)?fastshare\.cz/\d+/.+'      __description__ = """FastShare.cz hoster plugin"""      __license__     = "GPLv3" -    __authors__     = [("zoidberg", "zoidberg@mujmail.cz"), -                       ("stickell", "l.stickell@yahoo.it"), -                       ("Walter Purcaro", "vuolter@gmail.com")] +    __authors__     = [("Walter Purcaro", "vuolter@gmail.com")] +    URL_REPLACEMENTS = [("#.*", "")] + +    COOKIES             = [("fastshare.cz", "lang", "en")] +    CONTENT_DISPOSITION = True -    INFO_PATTERN = r'<h1 class="dwp">(?P<N>[^<]+)</h1>\s*<div class="fileinfo">\s*Size\s*: (?P<S>\d+) (?P<U>[\w^_]+),' +    INFO_PATTERN    = r'<h1 class="dwp">(?P<N>[^<]+)</h1>\s*<div class="fileinfo">\s*Size\s*: (?P<S>\d+) (?P<U>[\w^_]+),'      OFFLINE_PATTERN = r'>(The file has been deleted|Requested page not found)' -    URL_REPLACEMENTS = [("#.*", "")] +    LINK_FREE_PATTERN    = r'action=(/free/.*?)>\s*<img src="([^"]*)"><br' +    LINK_PREMIUM_PATTERN = r'(http://data\d+\.fastshare\.cz/download\.php\?id=\d+&)' -    COOKIES = [("fastshare.cz", "lang", "en")] +    SLOT_ERROR   = "> 100% of FREE slots are full" +    CREDIT_ERROR = " credit for " -    FREE_URL_PATTERN = r'action=(/free/.*?)>\s*<img src="([^"]*)"><br' -    PREMIUM_URL_PATTERN = r'(http://data\d+\.fastshare\.cz/download\.php\?id=\d+&)' -    CREDIT_PATTERN = r' credit for ' +    def checkErrors(self): +        if self.SLOT_ERROR in self.html: +            e = self.info['error'] = _("No free slots") +            self.retry(12, 60, e) + +        if self.CREDIT_ERROR in self.html: +            e = self.info['error'] = _("Not enough traffic left") +            self.logWarning(e) +            self.resetAccount() -    def handleFree(self): -        if "> 100% of FREE slots are full" in self.html: -            self.retry(12, 60, _("No free slots")) +    def handleFree(self):          m = re.search(self.FREE_URL_PATTERN, self.html)          if m:              action, captcha_src = m.groups() @@ -48,37 +53,23 @@ class FastshareCz(SimpleHoster):          baseurl = "http://www.fastshare.cz"          captcha = self.decryptCaptcha(urljoin(baseurl, captcha_src)) -        self.download(urljoin(baseurl, action), post={"code": captcha, "btn.x": 77, "btn.y": 18}) +        self.download(urljoin(baseurl, action), post={'code': captcha, 'btn.x': 77, 'btn.y': 18}) + +    def checkFile(self):          check = self.checkDownload({ -            'paralell_dl': "<title>FastShare.cz</title>|<script>alert\('Pres FREE muzete stahovat jen jeden soubor najednou.'\)", -            'wrong_captcha': "Download for FREE" +            'paralell_dl'  : re.compile(r"<title>FastShare.cz</title>|<script>alert\('Pres FREE muzete stahovat jen jeden soubor najednou.'\)"), +            'wrong_captcha': re.compile(r'Download for FREE'), +            'credit'       : re.compile(self.CREDIT_ERROR)          })          if check == "paralell_dl":              self.retry(6, 10 * 60, _("Paralell download")) +          elif check == "wrong_captcha":              self.retry(max_tries=5, reason=_("Wrong captcha")) - -    def handlePremium(self): -        header = self.load(self.pyfile.url, just_header=True) -        if "location" in header: -            url = header['location'] -        elif self.CREDIT_PATTERN in self.html: -            self.logWarning(_("Not enough traffic left")) -            self.resetAccount() -        else: -            m = re.search(self.PREMIUM_URL_PATTERN, self.html) -            if m: -                url = m.group(1) -            else: -                self.error(_("PREMIUM_URL_PATTERN not found")) - -        self.download(url, disposition=True) - -        check = self.checkDownload({"credit": re.compile(self.CREDIT_PATTERN)}) -        if check == "credit": +        elif check == "credit":              self.resetAccount() | 
