summaryrefslogtreecommitdiffstats
path: root/module/plugins/hoster
diff options
context:
space:
mode:
Diffstat (limited to 'module/plugins/hoster')
-rw-r--r--module/plugins/hoster/BasePlugin.py89
-rw-r--r--module/plugins/hoster/HugefilesNet.py9
-rw-r--r--module/plugins/hoster/SafesharingEu.py36
3 files changed, 87 insertions, 47 deletions
diff --git a/module/plugins/hoster/BasePlugin.py b/module/plugins/hoster/BasePlugin.py
index bdd7f782d..01a234d3b 100644
--- a/module/plugins/hoster/BasePlugin.py
+++ b/module/plugins/hoster/BasePlugin.py
@@ -13,7 +13,7 @@ from module.plugins.Hoster import Hoster
class BasePlugin(Hoster):
__name__ = "BasePlugin"
__type__ = "hoster"
- __version__ = "0.23"
+ __version__ = "0.24"
__pattern__ = r'^unmatchable$'
@@ -25,7 +25,7 @@ class BasePlugin(Hoster):
@classmethod
def getInfo(cls, url="", html=""): #@TODO: Move to hoster class in 0.4.10
- return {'name': urlparse(url).path.split('/')[-1] or _("Unknown"), 'size': 0, 'status': 3, 'url': url or ""}
+ return {'name': urlparse(url).path.split('/')[-1] or _("Unknown"), 'size': 0, 'status': 3 if url else 1, 'url': url or ""}
def setup(self):
@@ -38,40 +38,40 @@ class BasePlugin(Hoster):
pyfile.name = self.getInfo(pyfile.url)['name']
- if pyfile.url.startswith("http"):
- for _i in xrange(2):
- try:
- self.downloadFile(pyfile)
+ if not pyfile.url.startswith("http"):
+ self.fail(_("No plugin matched"))
+
+ for _i in xrange(5):
+ try:
+ self.downloadFile(pyfile)
- except BadHeader, e:
- if e.code is 404:
- self.offline()
+ except BadHeader, e:
+ if e.code is 404:
+ self.offline()
- elif e.code in (401, 403):
- self.logDebug("Auth required")
+ elif e.code in (401, 403):
+ self.logDebug("Auth required")
- account = self.core.accountManager.getAccountPlugin('Http')
- servers = [x['login'] for x in account.getAllAccounts()]
- server = urlparse(pyfile.url).netloc
+ account = self.core.accountManager.getAccountPlugin('Http')
+ servers = [x['login'] for x in account.getAllAccounts()]
+ server = urlparse(pyfile.url).netloc
- if server in servers:
- self.logDebug("Logging on to %s" % server)
- self.req.addAuth(account.accounts[server]['password'])
- else:
- for pwd in pyfile.package().password.splitlines():
- if ":" in pwd:
- self.req.addAuth(pwd.strip())
- break
- else:
- self.fail(_("Authorization required (username:password)"))
+ if server in servers:
+ self.logDebug("Logging on to %s" % server)
+ self.req.addAuth(account.accounts[server]['password'])
else:
- self.fail(e)
+ for pwd in pyfile.package().password.splitlines():
+ if ":" in pwd:
+ self.req.addAuth(pwd.strip())
+ break
+ else:
+ self.fail(_("Authorization required (username:password)"))
else:
- break
+ self.fail(e)
else:
- self.fail(_("No file downloaded")) #@TODO: Move to hoster class (check if self.lastDownload) in 0.4.10
+ break
else:
- self.fail(_("No plugin matched"))
+ self.fail(_("No file downloaded")) #@TODO: Move to hoster class (check if self.lastDownload) in 0.4.10
# if self.checkDownload({'empty': re.compile(r"^$")}) is "empty":
# self.fail(_("Empty file"))
@@ -80,27 +80,30 @@ class BasePlugin(Hoster):
def downloadFile(self, pyfile):
url = pyfile.url
- for _i in xrange(5):
- header = self.load(url, just_header=True)
+ for i in xrange(1, 7): #@TODO: retrieve the pycurl.MAXREDIRS value set by req
+ header = self.load(url, ref=True, cookies=True, just_header=True, decode=True)
- # self.load does not raise a BadHeader on 404 responses, do it here
- if 'code' in header and header['code'] == 404:
- raise BadHeader(404)
+ if 'location' not in header or not header['location']:
+ if 'code' in header and header['code'] not in (200, 201, 203, 206):
+ self.fail(_("File not found"), _("HTTP status code: %d") % header['code'])
+ else:
+ break
- if 'location' in header:
- self.logDebug("Location: " + header['location'])
+ location = header['location']
- base = re.match(r'https?://[^/]+', url).group(0)
+ self.logDebug("Redirect #%d to: %s" % (i, location))
- if header['location'].startswith("http"):
- url = header['location']
+ base = re.match(r'https?://[^/]+', url).group(0)
- elif header['location'].startswith("/"):
- url = base + unquote(header['location'])
+ if location.startswith("http"):
+ url = location
+
+ elif location.startswith("/"):
+ url = base + unquote(location)
- else:
- url = '%s/%s' % (base, unquote(header['location']))
else:
- break
+ url = "%s/%s" % (base, unquote(location))
+ else:
+ self.fail(_("Too many redirects"))
self.download(url, disposition=True)
diff --git a/module/plugins/hoster/HugefilesNet.py b/module/plugins/hoster/HugefilesNet.py
index cbbce119f..f7221f8c5 100644
--- a/module/plugins/hoster/HugefilesNet.py
+++ b/module/plugins/hoster/HugefilesNet.py
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
-#
-# Test links:
-# http://hugefiles.net/prthf9ya4w6s
+
+import re
from module.plugins.internal.XFSHoster import XFSHoster, create_getInfo
@@ -9,7 +8,7 @@ from module.plugins.internal.XFSHoster import XFSHoster, create_getInfo
class HugefilesNet(XFSHoster):
__name__ = "HugefilesNet"
__type__ = "hoster"
- __version__ = "0.04"
+ __version__ = "0.05"
__pattern__ = r'http://(?:www\.)?hugefiles\.net/\w{12}'
@@ -22,5 +21,7 @@ class HugefilesNet(XFSHoster):
SIZE_PATTERN = r'File Size:</span>\s*<span[^>]*>(?P<S>[^<]+)</span></div>'
+ FORM_INPUTS_MAP = {'ctype': re.compile(r'\d+')}
+
getInfo = create_getInfo(HugefilesNet)
diff --git a/module/plugins/hoster/SafesharingEu.py b/module/plugins/hoster/SafesharingEu.py
new file mode 100644
index 000000000..92a0ff932
--- /dev/null
+++ b/module/plugins/hoster/SafesharingEu.py
@@ -0,0 +1,36 @@
+# -*- coding: utf-8 -*-
+
+from module.plugins.internal.XFSHoster import XFSHoster, create_getInfo
+
+
+class SafesharingEu(XFSHoster):
+ __name__ = "SafesharingEu"
+ __type__ = "hoster"
+ __version__ = "0.04"
+
+ __pattern__ = r'https?://(?:\w+\.)?safesharing.eu/\w+'
+
+ __description__ = """Safesharing.eu hoster plugin"""
+ __license__ = "GPLv3"
+ __authors__ = [("zapp-brannigan", "fuerst.reinje@web.de")]
+
+ HOSTER_DOMAIN = "safesharing.eu"
+
+ FILE_NAME_PATTERN = r'Filename:</b></td><td nowrap>(?P<N>.*)</td></tr>'
+ FILE_SIZE_PATTERN = r'Size:</b></td><td>(?P<S>.*) (?P<U>[kKmMbB]*) <small>'
+
+ FILE_ID_PATTERN = r'<input type="hidden" name="id" value="(.*)">'
+ OFFLINE_PATTERN = r'<b>File Not Found</b>'
+ TEMP_OFFLINE_PATTERN = r'This server is in maintenance mode'
+
+
+ WAIT_PATTERN = r'You have to wait (\d+) minutes'
+ COUNTDOWN_PATTERN = r'<br><span id="countdown_str">Wait <span id=".*">(\d+)</span> seconds</span>'
+
+ RECAPTCHA_KEY_PATTERN = r'<script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge\?k=(.*)"></script>'
+ RANDOM_STRING_PATTERN = r'<input type="hidden" name="rand" value="(.*)">'
+
+ ERROR_PATTERN = r'(?:<div class="alert alert-danger">)(.+?)(?:</div>)'
+
+
+getInfo = create_getInfo(SafesharingEu)