diff options
Diffstat (limited to 'module/plugins/hoster/GigapetaCom.py')
-rw-r--r-- | module/plugins/hoster/GigapetaCom.py | 59 |
1 files changed, 25 insertions, 34 deletions
diff --git a/module/plugins/hoster/GigapetaCom.py b/module/plugins/hoster/GigapetaCom.py index 1282c996d..37af7f216 100644 --- a/module/plugins/hoster/GigapetaCom.py +++ b/module/plugins/hoster/GigapetaCom.py @@ -1,42 +1,31 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. - - @author: zoidberg -""" - import re -from random import randint + from pycurl import FOLLOWLOCATION +from random import randint from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class GigapetaCom(SimpleHoster): - __name__ = "GigapetaCom" - __type__ = "hoster" + __name__ = "GigapetaCom" + __type__ = "hoster" + __version__ = "0.02" + __pattern__ = r'http://(?:www\.)?gigapeta\.com/dl/\w+' - __version__ = "0.01" + __description__ = """GigaPeta.com hoster plugin""" - __author_name__ = "zoidberg" - __author_mail__ = "zoidberg@mujmail.cz" + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] + + + NAME_PATTERN = r'<img src=".*" alt="file" />-->\s*(?P<N>.*?)\s*</td>' + SIZE_PATTERN = r'<th>\s*Size\s*</th>\s*<td>\s*(?P<S>.*?)\s*</td>' + OFFLINE_PATTERN = r'<div id="page_error">' + + COOKIES = [("gigapeta.com", "lang", "us")] - SH_COOKIES = [("http://gigapeta.com", "lang", "us")] - FILE_NAME_PATTERN = r'<img src=".*" alt="file" />-->\s*(?P<N>.*?)\s*</td>' - FILE_SIZE_PATTERN = r'<th>\s*Size\s*</th>\s*<td>\s*(?P<S>.*?)\s*</td>' - FILE_OFFLINE_PATTERN = r'<div id="page_error">' def handleFree(self): captcha_key = str(randint(1, 100000000)) @@ -44,7 +33,7 @@ class GigapetaCom(SimpleHoster): self.req.http.c.setopt(FOLLOWLOCATION, 0) - for _ in xrange(5): + for _i in xrange(5): self.checkErrors() captcha = self.decryptCaptcha(captcha_url) @@ -53,24 +42,26 @@ class GigapetaCom(SimpleHoster): "captcha": captcha, "download": "Download"}) - found = re.search(r"Location\s*:\s*(.*)", self.req.http.header, re.I) - if found: - download_url = found.group(1) + m = re.search(r'Location\s*:\s*(.+)', self.req.http.header, re.I) + if m: + download_url = m.group(1).rstrip() #@TODO: Remove .rstrip() in 0.4.10 break elif "Entered figures don`t coincide with the picture" in self.html: self.invalidCaptcha() else: - self.fail("No valid captcha code entered") + self.fail(_("No valid captcha code entered")) self.req.http.c.setopt(FOLLOWLOCATION, 1) - self.logDebug("Download URL: %s" % download_url) self.download(download_url) + def checkErrors(self): if "All threads for IP" in self.html: - self.logDebug("Your IP is already downloading a file - wait and retry") + self.logDebug("Your IP is already downloading a file") self.wait(5 * 60, True) self.retry() + self.info.pop('error', None) + getInfo = create_getInfo(GigapetaCom) |