summaryrefslogtreecommitdiffstats
path: root/module/plugins/hoster/GigapetaCom.py
diff options
context:
space:
mode:
Diffstat (limited to 'module/plugins/hoster/GigapetaCom.py')
-rw-r--r--module/plugins/hoster/GigapetaCom.py36
1 files changed, 14 insertions, 22 deletions
diff --git a/module/plugins/hoster/GigapetaCom.py b/module/plugins/hoster/GigapetaCom.py
index 37af7f216..c2feeb6f8 100644
--- a/module/plugins/hoster/GigapetaCom.py
+++ b/module/plugins/hoster/GigapetaCom.py
@@ -1,67 +1,59 @@
# -*- coding: utf-8 -*-
+import pycurl
+import random
import re
-from pycurl import FOLLOWLOCATION
-from random import randint
-
from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo
class GigapetaCom(SimpleHoster):
__name__ = "GigapetaCom"
__type__ = "hoster"
- __version__ = "0.02"
+ __version__ = "0.04"
__pattern__ = r'http://(?:www\.)?gigapeta\.com/dl/\w+'
+ __config__ = [("use_premium", "bool", "Use premium account if available", True)]
__description__ = """GigaPeta.com hoster plugin"""
__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>'
+ 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">'
+ DOWNLOAD_PATTERN = r'"All threads for IP'
+
COOKIES = [("gigapeta.com", "lang", "us")]
- def handleFree(self):
- captcha_key = str(randint(1, 100000000))
+ def handleFree(self, pyfile):
+ captcha_key = str(random.randint(1, 100000000))
captcha_url = "http://gigapeta.com/img/captcha.gif?x=%s" % captcha_key
- self.req.http.c.setopt(FOLLOWLOCATION, 0)
+ self.req.http.c.setopt(pycurl.FOLLOWLOCATION, 0)
for _i in xrange(5):
self.checkErrors()
captcha = self.decryptCaptcha(captcha_url)
- self.html = self.load(self.pyfile.url, post={
+ self.html = self.load(pyfile.url, post={
"captcha_key": captcha_key,
"captcha": captcha,
"download": "Download"})
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
+ self.link = m.group(1).rstrip() #@TODO: Remove .rstrip() in 0.4.10
break
elif "Entered figures don&#96;t coincide with the picture" in self.html:
self.invalidCaptcha()
else:
self.fail(_("No valid captcha code entered"))
- self.req.http.c.setopt(FOLLOWLOCATION, 1)
- self.download(download_url)
-
-
- def checkErrors(self):
- if "All threads for IP" in self.html:
- self.logDebug("Your IP is already downloading a file")
- self.wait(5 * 60, True)
- self.retry()
-
- self.info.pop('error', None)
+ self.req.http.c.setopt(pycurl.FOLLOWLOCATION, 1)
getInfo = create_getInfo(GigapetaCom)