summaryrefslogtreecommitdiffstats
path: root/module/plugins/hoster/HotfileCom.py
diff options
context:
space:
mode:
authorGravatar mkaay <mkaay@mkaay.de> 2010-08-18 11:28:20 +0200
committerGravatar mkaay <mkaay@mkaay.de> 2010-08-18 11:28:20 +0200
commit38e99b7f813536cd9cbfaa2a761ce439f9f2116f (patch)
treec9a0aefe17370659d138f4c0dd4c84d73c909ae5 /module/plugins/hoster/HotfileCom.py
parentfixed SerienjunkiesOrg error on bad formated season pages (diff)
downloadpyload-38e99b7f813536cd9cbfaa2a761ce439f9f2116f.tar.xz
HotfileCom refactoring + premium support + prefetching, ShareonlineBiz prefetching fix
Diffstat (limited to 'module/plugins/hoster/HotfileCom.py')
-rw-r--r--module/plugins/hoster/HotfileCom.py103
1 files changed, 57 insertions, 46 deletions
diff --git a/module/plugins/hoster/HotfileCom.py b/module/plugins/hoster/HotfileCom.py
index bbd87bd09..8f231fcd5 100644
--- a/module/plugins/hoster/HotfileCom.py
+++ b/module/plugins/hoster/HotfileCom.py
@@ -6,12 +6,34 @@ from time import time
from module.plugins.Hoster import Hoster
from module.plugins.ReCaptcha import ReCaptcha
+from module.network.Request import getURL
+from module.plugins.Plugin import chunks
+
+def getInfo(urls):
+ api_url_base = "http://api.hotfile.com/"
+
+ for chunk in chunks(urls, 90):
+ api_param_file = {"action":"checklinks","links": ",".join(chunk),"fields":"id,status,name,size"} #api only supports old style links
+ src = getURL(api_url_base, post=api_param_file)
+ result = []
+ for i, res in enumerate(src.split("\n")):
+ if not res:
+ continue
+ fields = res.split(",")
+
+ if fields[1] in ("1", "2"):
+ status = 2
+ elif fields[1]:
+ status = 1
+
+ result.append((fields[2], int(fields[3]), status, chunk[i]))
+ yield result
class HotfileCom(Hoster):
__name__ = "HotfileCom"
__type__ = "hoster"
__pattern__ = r"http://hotfile.com/dl/"
- __version__ = "0.2"
+ __version__ = "0.3"
__description__ = """Hotfile.com Download Hoster"""
__author_name__ = ("sitacuisses","spoob","mkaay")
__author_mail__ = ("sitacuisses@yhoo.de","spoob@pyload.org","mkaay@mkaay.de")
@@ -23,46 +45,47 @@ class HotfileCom(Hoster):
self.htmlwithlink = None
self.url = None
- # if self.config['premium']:
- # self.multiDL = True
- # self.req.canContinue = True
+ if self.account:
+ self.multiDL = True
+ self.req.canContinue = True
+
+ def apiCall(self, method, post, login=False):
+ if not self.account and login:
+ return
+ elif self.account and login:
+ return self.account.apiCall(method, post)
+ post.update({"action": method})
+ return self.load("http://api.hotfile.com/", post=post)
def process(self, pyfile):
- self.pyfile = pyfile
- self.prepare()
- self.get_file_url()
-
-
- def prepare(self):
- pyfile = self.pyfile
self.wantReconnect = False
- self.download_html()
-
- if not self.file_exists():
+ args = {"links":self.pyfile.url, "fields":"id,status,name,size,sha1"}
+ resp = self.apiCall("checklinks", args)
+ self.apiData = {}
+ for k, v in zip(args["fields"].split(","), resp.strip().split(",")):
+ self.apiData[k] = v
+
+ if self.apiData["status"] == "0":
self.offline()
- pyfile.name = self.get_file_name()
-
- # if self.config['premium']:
- # pyfile.status.url = self.get_file_url()
- # return True
+ pyfile.name = self.apiData["name"]
+
+ if not self.account:
+ self.downloadHTML()
+
+ self.setWait(self.getWaitTime())
+ self.wait()
- self.setWait( self.get_wait_time() )
- self.wait()
-
- return True
+ self.freeDownload()
+ else:
+ dl = self.account.apiCall("getdirectdownloadlink", {"link":self.pyfile.url})
+ self.download(dl)
- def download_html(self):
- # if self.config['premium']:
- # self.req.add_auth(self.config['username'], self.config['password'])
+ def downloadHTML(self):
self.html[0] = self.load(self.pyfile.url, get={"lang":"en"}, cookies=True)
- def get_file_url(self):
- # if self.config['premium']:
- # file_url_pattern = r'<td><a href="(http://hotfile.com/get/.+?)" class="click_download">'
- # file_url = re.search(file_url_pattern, self.html[0]).group(1)
- # else:
+ def freeDownload(self):
form_content = re.search(r"<form style=.*(\n<.*>\s*)*?\n<tr>", self.html[0]).group(0)
form_posts = re.findall(r"<input\stype=hidden\sname=(\S*)\svalue=(\S*)>", form_content)
@@ -83,25 +106,13 @@ class HotfileCom(Hoster):
"recaptcha_response_field": result})
if "Wrong Code. Please try again." in self.html[1]:
- self.get_file_url()
+ self.freeDownload()
return
-
-
file_url = re.search(r'a href="(http://hotfile\.com/get/\S*?)"', self.html[1]).group(1)
self.download(file_url)
-
-
- def get_file_name(self):
- file_name = re.search(r':</strong> (.+?) <span>\|</span>', self.html[0]).group(1)
- return file_name
-
- def file_exists(self):
- if re.search(r"404 - Not Found", self.html[0]) != None or self.html[0] == "":
- return False
- return True
-
- def get_wait_time(self):
+
+ def getWaitTime(self):
free_limit_pattern = re.compile(r"timerend=d\.getTime\(\)\+(\d+);")
matches = free_limit_pattern.findall(self.html[0])
if matches: