Repository navigation
Expand file tree
/
Copy pathContainer.py
More file actions
64 lines (45 loc) · 1.76 KB
/
Copy pathContainer.py
File metadata and controls
64 lines (45 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# -*- coding: utf-8 -*-
from __future__ import with_statement
import os
import re
from pyload.plugin.Crypter import Crypter
from pyload.utils import fs_join
class Container(Crypter):
__name = "Container"
__type = "container"
__version = "0.01"
__pattern = r'^unmatchable$'
__config = [] #: [("name", "type", "desc", "default")]
__description = """Base container decrypter plugin"""
__license = "GPLv3"
__authors = [("mkaay", "mkaay@mkaay.de")]
def preprocessing(self, thread):
"""prepare"""
self.setup()
self.thread = thread
self.loadToDisk()
self.decrypt(self.pyfile)
self.deleteTmp()
self.createPackages()
def loadToDisk(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]
content = self.load(self.pyfile.url)
self.pyfile.url = fs_join(self.core.config.get("general", "download_folder"), self.pyfile.name)
try:
with open(self.pyfile.url, "wb") as f:
f.write(content)
except IOError, e:
self.fail(str(e))
else:
self.pyfile.name = os.path.basename(self.pyfile.url)
if not os.path.exists(self.pyfile.url):
if os.path.exists(fs_join(pypath, self.pyfile.url)):
self.pyfile.url = fs_join(pypath, self.pyfile.url)
else:
self.fail(_("File not exists"))
def deleteTmp(self):
if self.pyfile.name.startswith("tmp_"):
os.remove(self.pyfile.url)