summaryrefslogtreecommitdiffstats
path: root/pyload/plugin/container
diff options
context:
space:
mode:
Diffstat (limited to 'pyload/plugin/container')
-rw-r--r--pyload/plugin/container/CCF.py49
-rw-r--r--pyload/plugin/container/DLC.py72
-rw-r--r--pyload/plugin/container/RSDF.py61
-rw-r--r--pyload/plugin/container/TXT.py69
-rw-r--r--pyload/plugin/container/__init__.py1
5 files changed, 252 insertions, 0 deletions
diff --git a/pyload/plugin/container/CCF.py b/pyload/plugin/container/CCF.py
new file mode 100644
index 000000000..65f96033a
--- /dev/null
+++ b/pyload/plugin/container/CCF.py
@@ -0,0 +1,49 @@
+# -*- coding: utf-8 -*-
+
+from __future__ import with_statement
+
+import re
+
+from urllib2 import build_opener
+
+from MultipartPostHandler import MultipartPostHandler
+
+from pyload.plugin.Container import Container
+from pyload.utils import fs_encode, fs_join
+
+
+class CCF(Container):
+ __name__ = "CCF"
+ __type__ = "container"
+ __version__ = "0.23"
+
+ __pattern__ = r'.+\.ccf$'
+
+ __description__ = """CCF container decrypter plugin"""
+ __license__ = "GPLv3"
+ __authors__ = [("Willnix", "Willnix@pyload.org"),
+ ("Walter Purcaro", "vuolter@gmail.com")]
+
+
+ def decrypt(self, pyfile):
+ fs_filename = fs_encode(pyfile.url.strip())
+ opener = build_opener(MultipartPostHandler)
+
+ dlc_content = opener.open('http://service.jdownloader.net/dlcrypt/getDLC.php',
+ {'src' : "ccf",
+ 'filename': "test.ccf",
+ 'upload' : open(fs_filename, "rb")}).read()
+
+ download_folder = self.config['general']['download_folder']
+ dlc_file = fs_join(download_folder, "tmp_%s.dlc" % pyfile.name)
+
+ try:
+ dlc = re.search(r'<dlc>(.+)</dlc>', dlc_content, re.S).group(1).decode('base64')
+
+ except AttributeError:
+ self.fail(_("Container is corrupted"))
+
+ with open(dlc_file, "w") as tempdlc:
+ tempdlc.write(dlc)
+
+ self.urls = [dlc_file]
diff --git a/pyload/plugin/container/DLC.py b/pyload/plugin/container/DLC.py
new file mode 100644
index 000000000..04dabb6b2
--- /dev/null
+++ b/pyload/plugin/container/DLC.py
@@ -0,0 +1,72 @@
+# -*- coding: utf-8 -*-
+
+from __future__ import with_statement
+
+import re
+import xml.dom.minidom
+
+from Crypto.Cipher import AES
+
+from pyload.plugin.Container import Container
+from pyload.utils import decode, fs_encode
+
+
+class DLC(Container):
+ __name__ = "DLC"
+ __type__ = "container"
+ __version__ = "0.24"
+
+ __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"),
+ ("Walter Purcaro", "vuolter@gmail.com")]
+
+
+ KEY = "cb99b5cbc24db398"
+ IV = "9bc24cb995cb8db3"
+ API_URL = "http://service.jdownloader.org/dlcrypt/service.php?srcType=dlc&destType=pylo&data=%s"
+
+
+ def decrypt(self, pyfile):
+ fs_filename = fs_encode(pyfile.url.strip())
+ with open(fs_filename) as dlc:
+ data = dlc.read().strip()
+
+ data += '=' * (-len(data) % 4)
+
+ dlc_key = data[-88:]
+ dlc_data = data[:-88].decode('base64')
+ dlc_content = self.load(self.API_URL % dlc_key)
+
+ try:
+ rc = re.search(r'<rc>(.+)</rc>', dlc_content, re.S).group(1).decode('base64')
+
+ except AttributeError:
+ self.fail(_("Container is corrupted"))
+
+ key = iv = AES.new(self.KEY, AES.MODE_CBC, self.IV).decrypt(rc)
+
+ self.data = AES.new(key, AES.MODE_CBC, iv).decrypt(dlc_data).decode('base64')
+ self.packages = [(name or pyfile.name, links, name or pyfile.name) \
+ for name, links in self.getPackages()]
+
+
+ def getPackages(self):
+ root = xml.dom.minidom.parseString(self.data).documentElement
+ content = root.getElementsByTagName("content")[0]
+ return self.parsePackages(content)
+
+
+ def parsePackages(self, startNode):
+ return [(decode(node.getAttribute("name")).decode('base64'), self.parseLinks(node)) \
+ for node in startNode.getElementsByTagName("package")]
+
+
+ def parseLinks(self, startNode):
+ return [node.getElementsByTagName("url")[0].firstChild.data.decode('base64') \
+ for node in startNode.getElementsByTagName("file")]
diff --git a/pyload/plugin/container/RSDF.py b/pyload/plugin/container/RSDF.py
new file mode 100644
index 000000000..e43eb4c2b
--- /dev/null
+++ b/pyload/plugin/container/RSDF.py
@@ -0,0 +1,61 @@
+# -*- coding: utf-8 -*-
+
+from __future__ import with_statement
+
+import binascii
+import re
+
+from Crypto.Cipher import AES
+
+from pyload.plugin.Container import Container
+from pyload.utils import fs_encode
+
+
+class RSDF(Container):
+ __name__ = "RSDF"
+ __type__ = "container"
+ __version__ = "0.29"
+
+ __pattern__ = r'.+\.rsdf$'
+
+ __description__ = """RSDF container decrypter plugin"""
+ __license__ = "GPLv3"
+ __authors__ = [("RaNaN", "RaNaN@pyload.org"),
+ ("spoob", "spoob@pyload.org"),
+ ("Walter Purcaro", "vuolter@gmail.com")]
+
+
+ KEY = "8C35192D964DC3182C6F84F3252239EB4A320D2500000000"
+ IV = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
+
+
+ def decrypt(self, pyfile):
+ KEY = binascii.unhexlify(self.KEY)
+ IV = binascii.unhexlify(self.IV)
+
+ iv = AES.new(KEY, AES.MODE_ECB).encrypt(IV)
+ cipher = AES.new(KEY, AES.MODE_CFB, iv)
+
+ try:
+ fs_filename = fs_encode(pyfile.url.strip())
+ with open(fs_filename, 'r') as rsdf:
+ data = rsdf.read()
+
+ except IOError, e:
+ self.fail(e)
+
+ if re.search(r"<title>404 - Not Found</title>", data):
+ pyfile.setStatus("offline")
+
+ else:
+ try:
+ raw_links = binascii.unhexlify(''.join(data.split())).splitlines()
+
+ except TypeError:
+ self.fail(_("Container is corrupted"))
+
+ for link in raw_links:
+ if not link:
+ continue
+ link = cipher.decrypt(link.decode('base64')).replace('CCF: ', '')
+ self.urls.append(link)
diff --git a/pyload/plugin/container/TXT.py b/pyload/plugin/container/TXT.py
new file mode 100644
index 000000000..75940f55d
--- /dev/null
+++ b/pyload/plugin/container/TXT.py
@@ -0,0 +1,69 @@
+# -*- coding: utf-8 -*-
+
+import codecs
+
+from pyload.plugin.Container import Container
+from pyload.utils import fs_encode
+
+
+class TXT(Container):
+ __name__ = "TXT"
+ __type__ = "container"
+ __version__ = "0.15"
+
+ __pattern__ = r'.+\.(txt|text)$'
+ __config__ = [("flush" , "bool" , "Flush list after adding", False ),
+ ("encoding", "string", "File encoding" , "utf-8")]
+
+ __description__ = """Read link lists in plain text formats"""
+ __license__ = "GPLv3"
+ __authors__ = [("spoob", "spoob@pyload.org"),
+ ("jeix", "jeix@hasnomail.com")]
+
+
+ def decrypt(self, pyfile):
+ try:
+ encoding = codecs.lookup(self.getConfig('encoding')).name
+
+ except Exception:
+ encoding = "utf-8"
+
+ fs_filename = fs_encode(pyfile.url.strip())
+ txt = codecs.open(fs_filename, 'r', encoding)
+ curPack = "Parsed links from %s" % pyfile.name
+ packages = {curPack:[],}
+
+ for link in txt.readlines():
+ link = link.strip()
+
+ if not link:
+ continue
+
+ if link.startswith(";"):
+ continue
+
+ if link.startswith("[") and link.endswith("]"):
+ # new package
+ curPack = link[1:-1]
+ packages[curPack] = []
+ continue
+
+ packages[curPack].append(link)
+
+ txt.close()
+
+ # empty packages fix
+ for key, value in packages.iteritems():
+ if not value:
+ packages.pop(key, None)
+
+ if self.getConfig('flush'):
+ try:
+ txt = open(fs_filename, 'wb')
+ txt.close()
+
+ except IOError:
+ self.logWarning(_("Failed to flush list"))
+
+ for name, links in packages.iteritems():
+ self.packages.append((name, links, name))
diff --git a/pyload/plugin/container/__init__.py b/pyload/plugin/container/__init__.py
new file mode 100644
index 000000000..40a96afc6
--- /dev/null
+++ b/pyload/plugin/container/__init__.py
@@ -0,0 +1 @@
+# -*- coding: utf-8 -*-