diff options
| author | 2014-05-04 15:47:11 +0200 | |
|---|---|---|
| committer | 2014-05-04 15:47:11 +0200 | |
| commit | dd57d1155d5dd2a2dc36578b37a7ab4e49d0cec9 (patch) | |
| tree | 22858f5b16cd9060d1bea1a50fa451b03f0f7423 | |
| parent | File4safe premium (diff) | |
| download | pyload-dd57d1155d5dd2a2dc36578b37a7ab4e49d0cec9.tar.xz | |
New multihoster: Linksnappy
| -rw-r--r-- | module/plugins/accounts/LinksnappyCom.py | 43 | ||||
| -rw-r--r-- | module/plugins/hooks/LinksnappyCom.py | 26 | ||||
| -rw-r--r-- | module/plugins/hoster/LinksnappyCom.py | 53 | 
3 files changed, 122 insertions, 0 deletions
| diff --git a/module/plugins/accounts/LinksnappyCom.py b/module/plugins/accounts/LinksnappyCom.py new file mode 100644 index 000000000..4a8cd92c6 --- /dev/null +++ b/module/plugins/accounts/LinksnappyCom.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- + +from hashlib import md5 + +from module.plugins.Account import Account +from module.common.json_layer import json_loads + + +class LinksnappyCom(Account): +    __name__ = "LinksnappyCom" +    __version__ = "0.01" +    __type__ = "account" +    __description__ = """Linksnappy.com account plugin""" +    __author_name__ = "stickell" +    __author_mail__ = "l.stickell@yahoo.it" + +    def loadAccountInfo(self, user, req): +        data = self.getAccountData(user) +        r = req.load('http://gen.linksnappy.com/lseAPI.php', +                     get={'act': 'USERDETAILS', 'username': user, 'password': md5(data['password']).hexdigest()}) +        self.logDebug("JSON data: " + r) +        j = json_loads(r) + +        if j['error']: +            return {"premium": False} + +        validuntil = float(j['return']['expire']) +        if validuntil == 'lifetime': +            validuntil = -1 + +        if 'trafficleft' not in j['return'] or isinstance(j['return']['trafficleft'], str): +            trafficleft = -1 +        else: +            trafficleft = int(j['return']['trafficleft']) * 1024 + +        return {"premium": True, "validuntil": validuntil, "trafficleft": trafficleft} + +    def login(self, user, data, req): +        r = req.load('http://gen.linksnappy.com/lseAPI.php', +                     get={'act': 'USERDETAILS', 'username': user, 'password': md5(data['password']).hexdigest()}) + +        if 'Invalid Account Details' in r: +            self.wrongPassword() diff --git a/module/plugins/hooks/LinksnappyCom.py b/module/plugins/hooks/LinksnappyCom.py new file mode 100644 index 000000000..110731228 --- /dev/null +++ b/module/plugins/hooks/LinksnappyCom.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- + +from module.plugins.internal.MultiHoster import MultiHoster +from module.network.RequestFactory import getURL +from module.common.json_layer import json_loads + + +class LinksnappyCom(MultiHoster): +    __name__ = "LinksnappyCom" +    __version__ = "0.01" +    __type__ = "hook" +    __config__ = [("activated", "bool", "Activated", False), +                  ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), +                  ("hosterList", "str", "Hoster list (comma separated)", ""), +                  ("unloadFailing", "bool", "Revert to standard download if download fails", False), +                  ("interval", "int", "Reload interval in hours (0 to disable)", 24)] + +    __description__ = """Linksnappy.com hook plugin""" +    __author_name__ = "stickell" +    __author_mail__ = "l.stickell@yahoo.it" + +    def getHoster(self): +        json_data = getURL('http://gen.linksnappy.com/lseAPI.php?act=FILEHOSTS') +        json_data = json_loads(json_data) + +        return json_data['return'].keys() diff --git a/module/plugins/hoster/LinksnappyCom.py b/module/plugins/hoster/LinksnappyCom.py new file mode 100644 index 000000000..a2d07d9d8 --- /dev/null +++ b/module/plugins/hoster/LinksnappyCom.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- + +import re +from urlparse import urlsplit + +from module.plugins.Hoster import Hoster +from module.common.json_layer import json_loads, json_dumps + + +class LinksnappyCom(Hoster): +    __name__ = "LinksnappyCom" +    __version__ = "0.01" +    __type__ = "hoster" +    __pattern__ = r'https?://(?:[^/]*\.)?linksnappy\.com' +    __description__ = """Linksnappy.com hoster plugin""" +    __author_name__ = "stickell" +    __author_mail__ = "l.stickell@yahoo.it" + +    def setup(self): +        self.chunkLimit = -1 +        self.resumeDownload = True + +    def process(self, pyfile): +        if re.match(self.__pattern__, pyfile.url): +            new_url = pyfile.url +        elif not self.account: +            self.logError(_("Please enter your %s account or deactivate this plugin") % "Linksnappy.com") +            self.fail("No Linksnappy.com account provided") +        else: +            self.logDebug("Old URL: %s" % pyfile.url) +            host = urlsplit(pyfile.url).netloc +            host = re.search(r'[\w-]+\.\w+$', host).group(0) +            json_params = json_dumps({'link': pyfile.url, +                                      'type': host, +                                      'username': self.user, +                                      'password': self.account.getAccountData(self.user)["password"]}) +            r = self.load('http://gen.linksnappy.com/genAPI.php', +                          post={'genLinks': json_params}) +            self.logDebug("JSON data: " + r) + +            j = json_loads(r)['links'][0] + +            if j['error']: +                self.logError('Error converting the link: %s' % j['error']) +                self.fail('Error converting the link') + +            pyfile.name = j['filename'] +            new_url = j['generated'] + +        if new_url != pyfile.url: +            self.logDebug("New URL: " + new_url) + +        self.download(new_url, disposition=True) | 
