diff options
Diffstat (limited to 'module')
| -rw-r--r-- | module/plugins/accounts/ReloadCc.py | 46 | ||||
| -rw-r--r-- | module/plugins/hooks/ReloadCc.py | 59 | ||||
| -rw-r--r-- | module/plugins/hoster/ReloadCc.py | 65 | 
3 files changed, 170 insertions, 0 deletions
| diff --git a/module/plugins/accounts/ReloadCc.py b/module/plugins/accounts/ReloadCc.py new file mode 100644 index 000000000..c1efd05c5 --- /dev/null +++ b/module/plugins/accounts/ReloadCc.py @@ -0,0 +1,46 @@ +from module.plugins.Account   import Account + +from module.common.json_layer import json_loads + +class ReloadCc(Account): +    __name__ = "ReloadCc" +    __version__ = "0.1" +    __type__ = "account" +    __description__ = """Reload.Cc account plugin""" +     +    __author_name__ = ("Reload Team") +    __author_mail__ = ("hello@reload.cc") + +    def loadAccountInfo(self, user, req): +         +        # Get user data from reload.cc +        status = self.getAccountStatus(user, req) +             +        # Parse account info +        account_info = {"validuntil": float(status['msg']['expires']), +                        "pwdhash": status['msg']['hash'], +                        "trafficleft": -1} + +        return account_info + +    def login(self, user, data, req): +         +        # Get user data from reload.cc +        status = self.getAccountStatus(user, req) +         +        # Check if user and password are valid +        if status['status'] != "ok": +            self.wrongPassword() + +     +    def getAccountStatus(self, user, req): +        pwd = "pwd=%s" % self.accounts[user]['password'] + +        try: +            pwd = "hash=%s" % self.accounts[user]['pwdhash'] +        except Exception: +            pass + +        # Use reload.cc API v1 to retrieve account info and return the parsed json answer +        answer = req.load("https://api.reload.cc/login?via=pyload&v=1&get_traffic=true&user=%s&%s" % (user, pwd))             +        return json_loads(answer)
\ No newline at end of file diff --git a/module/plugins/hooks/ReloadCc.py b/module/plugins/hooks/ReloadCc.py new file mode 100644 index 000000000..1d4adfbe3 --- /dev/null +++ b/module/plugins/hooks/ReloadCc.py @@ -0,0 +1,59 @@ +from module.plugins.internal.MultiHoster import MultiHoster + +from module.common.json_layer      import json_loads +from module.network.RequestFactory import getURL + +class ReloadCc(MultiHoster): +    __name__ = "ReloadCc" +    __version__ = "0.1" +    __type__ = "hook" +    __description__ = """Reload.cc hook plugin""" + +    __config__ = [("activated", "bool", "Activated", "False"), +                  ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported):", "all"),  +                  ("hosterList", "str", "Hoster list (comma separated)", "")] + +    __author_name__ = ("Reload Team") +    __author_mail__ = ("hello@reload.cc") + +    interval = 0 # Disable periodic calls, we dont use them anyway +     +    def getHoster(self):      +        # If no accounts are available there will be no hosters available +        if not self.account or not self.account.canUse(): +            print "ReloadCc: No accounts available" +            return [] +         +        # Get account data +        (user, data) = self.account.selectAccount() +         +        pwd = "pwd=%s" % data['password'] + +        try: +            pwd = "hash=%s" % data['pwdhash'] +        except Exception: +            pass + +        # Get supported hosters list from reload.cc using the json API v1 +        answer = getURL("https://api.reload.cc/login?via=pyload&v=1&get_supported=true&get_traffic=true&user=%s&%s" % (user, pwd)) +        data = json_loads(answer) +         +         +        # If account is not valid thera are no hosters available +        if data['status'] != "ok": +            print "ReloadCc: Status is not ok: %s" % data['status'] +            return [] +         +        # Extract hosters from json file  +        return data['msg']['supportedHosters']  +             +    def coreReady(self): +        # Get account plugin and check if there is a valid account available +        self.account = self.core.accountManager.getAccountPlugin("ReloadCc")      +        if not self.account.canUse(): +            self.account = None +            self.logError(_("Please add a valid reload.cc account first and restart pyLoad.")) +            return +                   +        # Run the overwriten core ready which actually enables the multihoster hook  +        return MultiHoster.coreReady(self)
\ No newline at end of file diff --git a/module/plugins/hoster/ReloadCc.py b/module/plugins/hoster/ReloadCc.py new file mode 100644 index 000000000..36e76226c --- /dev/null +++ b/module/plugins/hoster/ReloadCc.py @@ -0,0 +1,65 @@ +from module.plugins.Hoster    import Hoster + +from module.common.json_layer import json_loads + +class ReloadCc(Hoster): +    __name__ = "ReloadCc" +    __version__ = "0.1.1" +    __type__ = "hoster" +    __description__ = """Reload.Cc hoster plugin""" +         +    # Since we want to allow the user to specify the list of hoster to use we let MultiHoster.coreReady create the regex patterns for us using getHosters in our ReloadCc hook. +    __pattern__ = None +     +    __author_name__ = ("Reload Team") +    __author_mail__ = ("hello@reload.cc") + +    def process(self, pyfile): +        # Check account +        if not self.account or not self.account.canUse(): +            self.logError(_("Please enter a valid reload.cc account or deactivate this plugin")) +            self.fail("No valid reload.cc account provided") +         +        # In some cases hostsers do not supply us with a filename at download, so we are going to set a fall back filename (e.g. for freakshare or xfileshare) +        self.pyfile.name = self.pyfile.name.split('/').pop() # Remove everthing before last slash +         +        # Correction for automatic assigned filename: Removing html at end if needed +        suffix_to_remove = ["html", "htm", "php", "php3", "asp", "shtm", "shtml", "cfml", "cfm"] +        temp = self.pyfile.name.split('.') +        if temp.pop() in suffix_to_remove: +            self.pyfile.name = ".".join(temp) + +        # Get account data +        (user, data) = self.account.selectAccount() +         +        pwd = "pwd=%s" % data['password'] + +        try: +            pwd = "hash=%s" % data['pwdhash'] +        except Exception: +            pass + +        # Get rewritten link using the reload.cc api v1 +        answer = self.load("https://api.reload.cc/dl?via=pyload&v=1&user=%s&%s&uri=%s" % (user, pwd, self.pyfile.url)) +        data = json_loads(answer)                 + +        # Check status and decide what to do +        status = data['status'] +        if status == "ok": +            self.download(data['link'], disposition=True) +        elif status == 400: +            self.fail("Unsupported URI") +        elif status == 401: +            self.fail("Invalid login") +        elif status == 402: +            self.fail("Payment required") +        elif status == 403: +            self.fail("User is disabled") +        elif status == 404: +            self.offline() +        elif status == 509: +            self.fail("Fairuse traffic exceeded") +        elif status >= 500: +            self.tempOffline() +        else: +            self.fail(data['msg']) | 
