summaryrefslogtreecommitdiffstats
path: root/module/plugins
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-12-20 18:17:34 +0100
committerGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-12-27 22:39:32 +0100
commit585651ad0f5dbfe984242b232662e830739d2eae (patch)
tree9325fafc26c69004291ce4c238fc5936b438997e /module/plugins
parent[misc] Fix encoding (diff)
downloadpyload-585651ad0f5dbfe984242b232662e830739d2eae.tar.xz
Improve Container
Diffstat (limited to 'module/plugins')
-rw-r--r--module/plugins/container/CCF.py2
-rw-r--r--module/plugins/container/DLC.py2
-rw-r--r--module/plugins/container/RSDF.py2
-rw-r--r--module/plugins/container/TXT.py2
-rw-r--r--module/plugins/internal/Container.py39
5 files changed, 24 insertions, 23 deletions
diff --git a/module/plugins/container/CCF.py b/module/plugins/container/CCF.py
index 2feccee0a..f082e1142 100644
--- a/module/plugins/container/CCF.py
+++ b/module/plugins/container/CCF.py
@@ -29,7 +29,7 @@ class CCF(Container):
def decrypt(self, pyfile):
- fs_filename = encode(pyfile.url.strip())
+ fs_filename = encode(pyfile.url)
opener = urllib2.build_opener(MultipartPostHandler.MultipartPostHandler)
dlc_content = opener.open('http://service.jdownloader.net/dlcrypt/getDLC.php',
diff --git a/module/plugins/container/DLC.py b/module/plugins/container/DLC.py
index 10a2899c8..6e8b0cf83 100644
--- a/module/plugins/container/DLC.py
+++ b/module/plugins/container/DLC.py
@@ -37,7 +37,7 @@ class DLC(Container):
def decrypt(self, pyfile):
- fs_filename = encode(pyfile.url.strip())
+ fs_filename = encode(pyfile.url)
with open(fs_filename) as dlc:
data = dlc.read().strip()
diff --git a/module/plugins/container/RSDF.py b/module/plugins/container/RSDF.py
index b0bfdc3bd..f35bc5136 100644
--- a/module/plugins/container/RSDF.py
+++ b/module/plugins/container/RSDF.py
@@ -41,7 +41,7 @@ class RSDF(Container):
cipher = Crypto.Cipher.AES.new(KEY, Crypto.Cipher.AES.MODE_CFB, iv)
try:
- fs_filename = encode(pyfile.url.strip())
+ fs_filename = encode(pyfile.url)
with open(fs_filename, 'r') as rsdf:
data = rsdf.read()
diff --git a/module/plugins/container/TXT.py b/module/plugins/container/TXT.py
index b31f42d49..e607d5150 100644
--- a/module/plugins/container/TXT.py
+++ b/module/plugins/container/TXT.py
@@ -32,7 +32,7 @@ class TXT(Container):
except Exception:
encoding = "utf-8"
- fs_filename = encode(pyfile.url.strip())
+ fs_filename = encode(pyfile.url)
txt = codecs.open(fs_filename, 'r', encoding)
curPack = "Parsed links from %s" % pyfile.name
packages = {curPack:[],}
diff --git a/module/plugins/internal/Container.py b/module/plugins/internal/Container.py
index b2d52a204..61ac0c6e2 100644
--- a/module/plugins/internal/Container.py
+++ b/module/plugins/internal/Container.py
@@ -4,9 +4,10 @@ from __future__ import with_statement
import os
import re
+import urlparse
from module.plugins.internal.Crypter import Crypter
-from module.plugins.internal.misc import encode, exists, fsjoin
+from module.plugins.internal.misc import encode, exists
class Container(Crypter):
@@ -30,31 +31,39 @@ class Container(Crypter):
"""
Main method
"""
- self._load2disk()
+ self._make_tmpfile()
self.decrypt(pyfile)
- if self.pyfile.name.startswith("tmp_"):
- self.remove(pyfile.url, trash=False)
-
if self.links:
self._generate_packages()
elif not self.packages:
self.error(_("No link grabbed"), "decrypt")
+ self._delete_tmpfile()
+
self._create_packages()
- def _load2disk(self):
+ def _delete_tmpfile(self):
+ if self.pyfile.name.startswith("tmp_"):
+ self.remove(pyfile.url, trash=False)
+
+
+ def _make_tmpfile(self):
"""
Loads container to disk if its stored remotely and overwrite url,
or check existent on several places at disk
"""
- if self.pyfile.url.startswith("http"):
- self.pyfile.name = re.findall("([^\/=]+)", self.pyfile.url)[-1]
+ remote = bool(urlparse.urlparse(self.pyfile.url).netloc)
+
+ if remote:
content = self.load(self.pyfile.url)
- self.pyfile.url = fsjoin(self.pyload.config.get("general", "download_folder"), self.pyfile.name)
+
+ self.pyfile.name = "tmp_" + self.pyfile.name
+ self.pyfile.url = os.path.join(self.pyload.config.get("general", "download_folder"), self.pyfile.name)
+
try:
with open(self.pyfile.url, "wb") as f:
f.write(encode(content))
@@ -62,13 +71,5 @@ class Container(Crypter):
except IOError, e:
self.fail(e)
- else:
- self.pyfile.name = os.path.basename(self.pyfile.url)
-
- if not exists(self.pyfile.url):
- if exists(fsjoin(pypath, self.pyfile.url)):
- self.pyfile.url = fsjoin(pypath, self.pyfile.url)
- else:
- self.fail(_("File not exists"))
- else:
- self.data = self.pyfile.url #@NOTE: ???
+ elif not exists(self.pyfile.url):
+ self.fail(_("File not found"))