diff options
Diffstat (limited to 'module')
| -rw-r--r-- | module/RequestFactory.py | 5 | ||||
| -rw-r--r-- | module/plugins/accounts/HotfileCom.py | 85 | ||||
| -rw-r--r-- | module/plugins/hoster/HotfileCom.py | 103 | ||||
| -rw-r--r-- | module/plugins/hoster/ShareonlineBiz.py | 2 | 
4 files changed, 147 insertions, 48 deletions
| diff --git a/module/RequestFactory.py b/module/RequestFactory.py index 04d5d671a..3885cae19 100644 --- a/module/RequestFactory.py +++ b/module/RequestFactory.py @@ -80,7 +80,10 @@ class CookieJar():          return self.cookies.values()      def parseCookie(self, name): -        return self.cookies[name].split("\t")[6] +        if cookies.has_key(name): +            return self.cookies[name].split("\t")[6] +        else: +            return None      def getCookie(self, name):          return self.parseCookie(name) diff --git a/module/plugins/accounts/HotfileCom.py b/module/plugins/accounts/HotfileCom.py new file mode 100644 index 000000000..af38b56a3 --- /dev/null +++ b/module/plugins/accounts/HotfileCom.py @@ -0,0 +1,85 @@ +# -*- coding: utf-8 -*- + +""" +    This program is free software; you can redistribute it and/or modify +    it under the terms of the GNU General Public License as published by +    the Free Software Foundation; either version 3 of the License, +    or (at your option) any later version. + +    This program is distributed in the hope that it will be useful, +    but WITHOUT ANY WARRANTY; without even the implied warranty of +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +    See the GNU General Public License for more details. + +    You should have received a copy of the GNU General Public License +    along with this program; if not, see <http://www.gnu.org/licenses/>. +     +    @author: mkaay +""" + +from module.plugins.Account import Account +import re +from time import strptime, mktime +import hashlib + +class HotfileCom(Account): +    __name__ = "HotfileCom" +    __version__ = "0.1" +    __type__ = "account" +    __description__ = """hotfile.com account plugin""" +    __author_name__ = ("mkaay") +    __author_mail__ = ("mkaay@mkaay.de") +     +    def getAccountInfo(self, user): +        req = self.core.requestFactory.getRequest(self.__name__, user) +         +        resp = self.apiCall("getuserinfo", user=user) +        if resp.startswith("."): +            self.core.debug("HotfileCom API Error: %s" % resp) +            return None +        info = {} +        for p in resp.split("&"): +            key, value = p.split("=") +            info[key] = value +             +        info["premium_until"] = info["premium_until"].replace("T"," ") +        zone = info["premium_until"][19:] +        info["premium_until"] = info["premium_until"][:19] +        zone = int(zone[:3]) +         +        validuntil = int(mktime(strptime(info["premium_until"], "%Y-%m-%d %H:%M:%S"))) + (zone*3600) +        out = Account.getAccountInfo(self, user) +        tmp = {"validuntil":validuntil, "trafficleft":-1} +        out.update(tmp) +        return out +     +    def apiCall(self, method, post={}, user=None): +        if user: +            data = None +            for account in self.accounts.items(): +                if account[0] == user: +                    data = account[1] +        else: +            user, data = self.accounts.items()[0] +         +        req = self.core.requestFactory.getRequest(self.__name__, user) +     +        digest = req.load("http://api.hotfile.com/", post={"action":"getdigest"}) +        h = hashlib.md5() +        h.update(data["password"]) +        hp = h.hexdigest() +        h = hashlib.md5() +        h.update(hp) +        h.update(digest) +        pwhash = h.hexdigest() +         +        post.update({"action": method}) +        post.update({"username":user, "passwordmd5dig":pwhash, "digest":digest}) +        return req.load("http://api.hotfile.com/", post=post) +     +    def login(self, user, data): +        req = self.core.requestFactory.getRequest(self.__name__, user) +        cj = self.core.requestFactory.getCookieJar(self.__name__, user) +        cj.setCookie("hotfile.com", "lang", "en") +        req.load("http://hotfile.com/", cookies=True) +        req.load("http://hotfile.com/login.php", post={"returnto": "/", "user": user, "pass": data["password"]}, cookies=True) 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: diff --git a/module/plugins/hoster/ShareonlineBiz.py b/module/plugins/hoster/ShareonlineBiz.py index 42a2bc560..50a9654ce 100644 --- a/module/plugins/hoster/ShareonlineBiz.py +++ b/module/plugins/hoster/ShareonlineBiz.py @@ -35,7 +35,7 @@ def getInfo(urls):              else:                  status = 3 -                result.append((fields[2], int(fields[3]), status, chunk[i])) +            result.append((fields[2], int(fields[3]), status, chunk[i]))          yield result  class ShareonlineBiz(Hoster): | 
