diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-06-07 13:18:08 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-06-07 13:18:08 +0200 |
commit | a6f863c3030f1789b12e407e197e05f55bb92afc (patch) | |
tree | ea682653bd887ff84d11b5bc7c4f419d48a474ab /module/plugins | |
parent | New multi hoster plugin: UnrestrictLi (diff) | |
parent | Added plugin to support megacrypter.com (diff) | |
download | pyload-a6f863c3030f1789b12e407e197e05f55bb92afc.tar.xz |
Merge pull request #153 from gonzalosr/patch-1
Added plugin to support megacrypter.com
Diffstat (limited to 'module/plugins')
-rw-r--r-- | module/plugins/hoster/MegacrypterCom.py | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/module/plugins/hoster/MegacrypterCom.py b/module/plugins/hoster/MegacrypterCom.py new file mode 100644 index 000000000..9f012e5be --- /dev/null +++ b/module/plugins/hoster/MegacrypterCom.py @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- +import re + +from module.common.json_layer import json +from module.plugins.hoster.MegaNz import MegaNz + + +class MegacrypterCom(MegaNz): + __name__ = "MegacrypterCom" + __type__ = "hoster" + __pattern__ = r"(https?://[a-z0-9]{0,10}\.?megacrypter\.com/[a-zA-Z0-9!_\-]+)" + __version__ = "0.1" + __description__ = """megacrypter plugin, based and inherits from RaNaN's MegaNz plugin""" + __author_name__ = ("GonzaloSR", ) + __author_mail__ = ("gonzalo@gonzalosr.com", ) + + API_URL = "http://megacrypter.com/api" + FILE_SUFFIX = ".crypted" + + + def callApi(self, **kwargs): + """ Dispatch a call to the api, see megacrypter.com/api_doc """ + self.logDebug("JSON request: " + json.dumps(kwargs)) + resp = self.load(self.API_URL, post=json.dumps(kwargs)) + self.logDebug("API Response: " + resp) + return json.loads(resp) + + + def process(self, pyfile): + + key = None + + # match is guaranteed because plugin was chosen to handle url + node = re.search(self.__pattern__, pyfile.url).group(1) + + + # get Mega.co.nz link info + info = self.callApi(link=node, m="info") + + # get crypted file URL + dl = self.callApi(link=node, m="dl") + + + # TODO: map error codes, implement password protection + # if info["pass"] == true: + # crypted_file_key, md5_file_key = info["key"].split("#") + + + key = self.b64_decode(info["key"]) + + pyfile.name = info["name"] + self.FILE_SUFFIX + + self.download(dl["url"]) + self.decryptFile(key) + + # Everything is finished and final name can be set + pyfile.name = info["name"] + + |