summaryrefslogtreecommitdiffstats
path: root/module/plugins/hoster
diff options
context:
space:
mode:
Diffstat (limited to 'module/plugins/hoster')
-rw-r--r--module/plugins/hoster/BasePlugin.py78
-rw-r--r--module/plugins/hoster/DepositfilesCom.py46
-rw-r--r--module/plugins/hoster/HellshareCz.py4
-rw-r--r--module/plugins/hoster/HotfileCom.py9
4 files changed, 90 insertions, 47 deletions
diff --git a/module/plugins/hoster/BasePlugin.py b/module/plugins/hoster/BasePlugin.py
index ed11c378b..15e35ce24 100644
--- a/module/plugins/hoster/BasePlugin.py
+++ b/module/plugins/hoster/BasePlugin.py
@@ -1,13 +1,13 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-
-from module.plugins.Hoster import Hoster
-from module.utils import html_unescape
-
from urlparse import urlparse
from re import search
from urllib import unquote
+from module.network.HTTPRequest import BadHeader
+from module.plugins.Hoster import Hoster
+from module.utils import html_unescape, removeChars
+
class BasePlugin(Hoster):
__name__ = "BasePlugin"
__type__ = "hoster"
@@ -41,31 +41,49 @@ class BasePlugin(Hoster):
#
# return
if pyfile.url.startswith("http"):
- header = self.load(pyfile.url, just_header = True)
- #self.logDebug(header)
-
- if 'location' in header:
- self.logDebug("Location: " + header['location'])
- url = unquote(header['location'])
- else:
- url = pyfile.url
-
- name = html_unescape(urlparse(url).path.split("/")[-1])
-
- if 'content-disposition' in header:
- self.logDebug("Content-Disposition: " + header['content-disposition'])
- m = search("filename(?P<type>=|\*=(?P<enc>.+)'')(?P<name>.*)", header['content-disposition'])
- if m:
- disp = m.groupdict()
- self.logDebug(disp)
- if not disp['enc']: disp['enc'] = 'utf-8'
- name = disp['name'].replace('"', "").replace("'", "").replace(";", "").strip()
- name = unicode(unquote(name), disp['enc'])
-
- if not name: self.offline()
- pyfile.name = name
- self.logDebug("Filename: %s" % pyfile.name)
- self.download(url, disposition=True)
+
+ try:
+ self.downloadFile(pyfile)
+ except BadHeader, e:
+ if e.code in (401, 403):
+ self.logDebug("Auth required")
+
+ pwd = pyfile.package().password.strip()
+ if ":" not in pwd:
+ self.fail(_("Authorization required (username:password)"))
+
+ self.req.addAuth(pwd)
+ self.downloadFile(pyfile)
+ else:
+ raise
else:
- self.fail("No Plugin matched and not a downloadable url.") \ No newline at end of file
+ self.fail("No Plugin matched and not a downloadable url.")
+
+
+ def downloadFile(self, pyfile):
+ header = self.load(pyfile.url, just_header = True)
+ #self.logDebug(header)
+
+ if 'location' in header:
+ self.logDebug("Location: " + header['location'])
+ url = unquote(header['location'])
+ else:
+ url = pyfile.url
+
+ name = html_unescape(urlparse(url).path.split("/")[-1])
+
+ if 'content-disposition' in header:
+ self.logDebug("Content-Disposition: " + header['content-disposition'])
+ m = search("filename(?P<type>=|\*=(?P<enc>.+)'')(?P<name>.*)", header['content-disposition'])
+ if m:
+ disp = m.groupdict()
+ self.logDebug(disp)
+ if not disp['enc']: disp['enc'] = 'utf-8'
+ name = removeChars(disp['name'], "\"';").strip()
+ name = unicode(unquote(name), disp['enc'])
+
+ if not name: name = url
+ pyfile.name = name
+ self.logDebug("Filename: %s" % pyfile.name)
+ self.download(url, disposition=True) \ No newline at end of file
diff --git a/module/plugins/hoster/DepositfilesCom.py b/module/plugins/hoster/DepositfilesCom.py
index 1fba3bad5..81e6aa4d6 100644
--- a/module/plugins/hoster/DepositfilesCom.py
+++ b/module/plugins/hoster/DepositfilesCom.py
@@ -5,6 +5,7 @@ import re
import urllib
from module.plugins.Hoster import Hoster
from module.network.RequestFactory import getURL
+from module.plugins.ReCaptcha import ReCaptcha
def getInfo(urls):
result = []
@@ -29,13 +30,15 @@ class DepositfilesCom(Hoster):
__name__ = "DepositfilesCom"
__type__ = "hoster"
__pattern__ = r"http://[\w\.]*?depositfiles\.com(/\w{1,3})?/files/[\w]+"
- __version__ = "0.33"
+ __version__ = "0.34"
__description__ = """Depositfiles.com Download Hoster"""
__author_name__ = ("spoob", "zoidberg")
__author_mail__ = ("spoob@pyload.org", "zoidberg@mujmail.cz")
FILE_INFO_PATTERN = r'File name: <b title="([^"]+)">.*\s*<span class="nowrap">File size: <b>([0-9.]+)&nbsp;(KB|MB|GB)</b>'
FILE_OFFLINE_PATTERN = r'<span class="html_download_api-not_exists"></span>'
+ RECAPTCHA_PATTERN = r"Recaptcha.create\('([^']+)', this\);"
+ DOWNLOAD_LINK_PATTERN = r'<form action="(http://.+?\.depositfiles.com/.+?)" method="get"'
def setup(self):
self.resumeDownload = self.multiDL = True if self.account else False
@@ -96,27 +99,42 @@ class DepositfilesCom(Hoster):
found = re.search(r"var fid = '(\w+)';", self.html)
if not found: self.retry(wait_time=5)
- fid = found.group(1)
- self.logDebug ("FID: %s" % fid)
+ params = {'fid' : found.group(1)}
+ self.logDebug ("FID: %s" % params['fid'])
- self.wait()
-
- #form = re.search(r"\$\('#download_container'\)\.load\('([^']+)", self.html)
+ captcha_key = None
+ found = re.search(self.RECAPTCHA_PATTERN, self.html)
+ if found: captcha_key = found.group(1)
+ self.logDebug ("CAPTCHA_KEY: %s" % captcha_key)
- #self.html = self.load("http://depositfiles.com/"+ form.group(1))
+ self.wait()
+ recaptcha = ReCaptcha(self)
+
+ for i in range(5):
+ self.html = self.load("http://depositfiles.com/get_file.php", get = params)
+ if '<input type=button value="Continue" onclick="check_recaptcha' in self.html:
+ if not captcha_key: self.fail('Parse error (Captcha key)')
+ if 'response' in params: self.invalidCaptcha()
+ params['challenge'], params['response'] = recaptcha.challenge(captcha_key)
+ self.logDebug(params)
+ continue
+
+ found = re.search(self.DOWNLOAD_LINK_PATTERN, self.html)
+ if found:
+ if 'response' in params: self.correctCaptcha()
+ link = urllib.unquote(found.group(1))
+ self.logDebug ("LINK: %s" % link)
+ break
+ else:
+ self.fail('Parse error (Download link)')
+ else:
+ self.fail('No valid captcha response received')
- self.html = self.load("http://depositfiles.com/get_file.php?fid=" + fid)
- link = urllib.unquote(re.search('<form action="(http://.+?\.depositfiles.com/.+?)" method="get"', self.html).group(1))
- self.logDebug ("LINK: %s" % link)
try:
self.download(link)
except:
self.retry(wait_time = 60)
- #wait_time = int(re.search(r'<span id="download_waiter_remain">(.*?)</span>', self.html).group(1))
- #self.setWait(wait_time)
- #self.log.debug("DepositFiles.com: Waiting %d seconds." % wait_time)
-
def handlePremium(self):
link = urllib.unquote(re.search('<div id="download_url">\s*<a href="(http://.+?\.depositfiles.com/.+?)"', self.html).group(1))
self.download(link) \ No newline at end of file
diff --git a/module/plugins/hoster/HellshareCz.py b/module/plugins/hoster/HellshareCz.py
index 7986ecf11..8c90e8099 100644
--- a/module/plugins/hoster/HellshareCz.py
+++ b/module/plugins/hoster/HellshareCz.py
@@ -48,7 +48,7 @@ class HellshareCz(Hoster):
__name__ = "HellshareCz"
__type__ = "hoster"
__pattern__ = r"http://(.*\.)*hellshare\.(cz|com|sk|hu)/.*"
- __version__ = "0.70"
+ __version__ = "0.71"
__description__ = """Hellshare.cz"""
__author_name__ = ("zoidberg")
@@ -97,7 +97,7 @@ class HellshareCz(Hoster):
def handleFree(self):
# hellshare is very generous
- if 'You exceeded your today's limit for free download. You can download only 1 files per 24 hours.' in self.html:
+ if "You exceeded your today's limit for free download. You can download only 1 files per 24 hours." in self.html:
t = datetime.datetime.today().replace(hour=1, minute=0, second=0) + datetime.timedelta(
days=1) - datetime.datetime.today()
self.setWait(t.seconds, True)
diff --git a/module/plugins/hoster/HotfileCom.py b/module/plugins/hoster/HotfileCom.py
index 96927a9fc..9c056d899 100644
--- a/module/plugins/hoster/HotfileCom.py
+++ b/module/plugins/hoster/HotfileCom.py
@@ -37,6 +37,8 @@ class HotfileCom(Hoster):
__author_name__ = ("sitacuisses","spoob","mkaay")
__author_mail__ = ("sitacuisses@yhoo.de","spoob@pyload.org","mkaay@mkaay.de")
+ FILE_OFFLINE_PATTERN = r'File is removed'
+
def setup(self):
self.html = [None, None]
self.wantReconnect = False
@@ -73,7 +75,10 @@ class HotfileCom(Hoster):
if not self.account:
self.downloadHTML()
-
+
+ if self.FILE_OFFLINE_PATTERN in self.html[0]:
+ self.offline()
+
self.setWait(self.getWaitTime())
self.wait()
@@ -131,3 +136,5 @@ class HotfileCom(Hoster):
self.wantReconnect = True
return waittime
return 65
+ else:
+ self.fail("Don't know how long to wait. Cannot proceed.")