summaryrefslogtreecommitdiffstats
path: root/module/plugins/hoster/HotfileCom.py
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2010-08-25 18:22:27 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2010-08-25 18:22:27 +0200
commit29f9dc8fb3396b03d732ebcbeb1cc8f00fe13897 (patch)
treef2a910cbea747a7b0c0a50d6c66691e54f5ef47f /module/plugins/hoster/HotfileCom.py
parentmerged gui (diff)
downloadpyload-29f9dc8fb3396b03d732ebcbeb1cc8f00fe13897.tar.xz
new dirs
Diffstat (limited to 'module/plugins/hoster/HotfileCom.py')
-rw-r--r--module/plugins/hoster/HotfileCom.py127
1 files changed, 127 insertions, 0 deletions
diff --git a/module/plugins/hoster/HotfileCom.py b/module/plugins/hoster/HotfileCom.py
new file mode 100644
index 000000000..8f231fcd5
--- /dev/null
+++ b/module/plugins/hoster/HotfileCom.py
@@ -0,0 +1,127 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import re
+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.3"
+ __description__ = """Hotfile.com Download Hoster"""
+ __author_name__ = ("sitacuisses","spoob","mkaay")
+ __author_mail__ = ("sitacuisses@yhoo.de","spoob@pyload.org","mkaay@mkaay.de")
+
+ def setup(self):
+ self.html = [None, None]
+ self.wantReconnect = False
+ self.multiDL = False
+ self.htmlwithlink = None
+ self.url = None
+
+ 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.wantReconnect = False
+
+ 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.apiData["name"]
+
+ if not self.account:
+ self.downloadHTML()
+
+ self.setWait(self.getWaitTime())
+ self.wait()
+
+ self.freeDownload()
+ else:
+ dl = self.account.apiCall("getdirectdownloadlink", {"link":self.pyfile.url})
+ self.download(dl)
+
+ def downloadHTML(self):
+ self.html[0] = self.load(self.pyfile.url, get={"lang":"en"}, cookies=True)
+
+ 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)
+
+ self.html[1] = self.load(self.pyfile.url, post=form_posts, cookies=True)
+
+ re_captcha = ReCaptcha(self)
+
+ challenge = re.search(r"http://api\.recaptcha\.net/challenge\?k=([0-9A-Za-z]+)", self.html[1])
+
+ if challenge:
+ challenge, result = re_captcha.challenge(challenge.group(1))
+
+ url = re.search(r'<form action="(/dl/[^"]+)', self.html[1] )
+
+ self.html[1] = self.load("http://hotfile.com"+url.group(1), post={"action": "checkcaptcha",
+ "recaptcha_challenge_field" : challenge,
+ "recaptcha_response_field": result})
+
+ if "Wrong Code. Please try again." in self.html[1]:
+ 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 getWaitTime(self):
+ free_limit_pattern = re.compile(r"timerend=d\.getTime\(\)\+(\d+);")
+ matches = free_limit_pattern.findall(self.html[0])
+ if matches:
+ for match in matches:
+ if int(match) == 60000:
+ continue
+ if int(match) == 0:
+ continue
+ else:
+ self.wantReconnect = True
+ return int(match)/1000 + 65
+ return 65