diff options
author | Walter Purcaro <vuolter@gmail.com> | 2015-01-23 00:50:06 +0100 |
---|---|---|
committer | Walter Purcaro <vuolter@gmail.com> | 2015-01-23 00:50:06 +0100 |
commit | 6022f5885243ef9589ab1296ff758f98a4002aa5 (patch) | |
tree | 96b60896418ec5c1d4f58c719fa26e23ec162e29 /module | |
parent | Merge pull request #1064 from Nippey/patch-1 (diff) | |
download | pyload-6022f5885243ef9589ab1296ff758f98a4002aa5.tar.xz |
[DLC] Cleanup
Diffstat (limited to 'module')
-rw-r--r-- | module/plugins/container/DLC.py | 85 |
1 files changed, 43 insertions, 42 deletions
diff --git a/module/plugins/container/DLC.py b/module/plugins/container/DLC.py index 5af41ac94..446e96221 100644 --- a/module/plugins/container/DLC.py +++ b/module/plugins/container/DLC.py @@ -1,69 +1,70 @@ # -*- coding: utf-8 -*- -import base64 +from __future__ import with_statement + import re +import xml +from base64 import standard_b64decode from Crypto.Cipher import AES -from xml.dom.minidom import parseString from module.plugins.Container import Container class DLC(Container): __name__ = "DLC" - __pattern__ = r'.*\.dlc$' - __version__ = "0.2" - __description__ = """DLC Container Decode Plugin""" - __author_name__ = ("RaNaN", "spoob", "mkaay", "Schnusch") - __author_mail__ = ("RaNaN@pyload.org", "spoob@pyload.org", "mkaay@mkaay.de", "Schnusch@users.noreply.github.com") + __version__ = "0.20" + __pattern__ = r'.+\.dlc$' + + __description__ = """DLC container decrypter plugin""" + __license__ = "GPLv3" + __authors__ = [("RaNaN", "RaNaN@pyload.org"), + ("spoob", "spoob@pyload.org"), + ("mkaay", "mkaay@mkaay.de"), + ("Schnusch", "Schnusch@users.noreply.github.com")] + + + def setup(self): + self.key = "cb99b5cbc24db398" + self.iv = "9bc24cb995cb8db3" + self.api_url = "http://service.jdownloader.org/dlcrypt/service.php?srcType=dlc&destType=pylo&data=" - key = "cb99b5cbc24db398" - iv = "9bc24cb995cb8db3" - dlc_api_url = "http://service.jdownloader.org/dlcrypt/service.php?srcType=dlc&destType=pylo&data=" def decrypt(self, pyfile): - infile = pyfile.url.replace("\n", "") + with open(pyfile.url.replace("\n", "")) as dlc: + data = dlc.read().strip() - dlc = open(infile, "r") - data = dlc.read().strip() - dlc.close() if not data.endswith("=="): - if data.endswith("="): - data += "=" - else: - data += "==" - dlckey = data[-88:] + data += "=" if data.endswith("=") else "==" + + dlckey = data[-88:] dlcdata = data[:-88] - dlcdata = base64.standard_b64decode(dlcdata) - rc = self.req.load(self.dlc_api_url + dlckey) + dlcdata = standard_b64decode(dlcdata) + + rc = self.req.load(self.api_url + dlckey) rc = re.search(r'<rc>(.+)</rc>', rc).group(1) - rc = base64.standard_b64decode(rc) - obj = AES.new(self.key, AES.MODE_CBC, self.iv) + rc = standard_b64decode(rc) + + obj = AES.new(self.key, AES.MODE_CBC, self.iv) dlckey = obj.decrypt(rc) - obj = AES.new(dlckey, AES.MODE_CBC, dlckey) - self.data = base64.standard_b64decode(obj.decrypt(dlcdata)) - for entry in self.getPackages(): - self.packages.append((entry[0] if entry[0] else pyfile.name, entry[1], entry[0] if entry[0] else pyfile.name)) + obj = AES.new(dlckey, AES.MODE_CBC, dlckey) + + self.data = standard_b64decode(obj.decrypt(dlcdata)) + self.packages = [(entry[0] if entry[0] else pyfile.name, entry[1], entry[0] if entry[0] else pyfile.name) \ + for entry in self.getPackages()] - def createNewPackage(self): - return True def getPackages(self): - xml = parseString(self.data) - root = xml.documentElement - contentNode = root.getElementsByTagName("content")[0] - return self.parsePackages(contentNode) + root = xml.dom.minidom.parseString(self.data).documentElement + content = root.getElementsByTagName("content")[0] + return self.parsePackages(content) + def parsePackages(self, startNode): - c = [] - for node in startNode.getElementsByTagName("package"): - c.append((base64.standard_b64decode(node.getAttribute("name")).decode("utf8", "replace"), self.parseLinks(node))) + return [(standard_b64decode(node.getAttribute("name")).decode("utf8", "replace"), self.parseLinks(node)) \ + for node in startNode.getElementsByTagName("package")] - return c def parseLinks(self, startNode): - c = [] - for node in startNode.getElementsByTagName("file"): - c.append(base64.standard_b64decode(node.getElementsByTagName("url")[0].firstChild.data)) - - return c + return [standard_b64decode(node.getElementsByTagName("url")[0].firstChild.data) \ + for node in startNode.getElementsByTagName("file")] |