forked from pyload/pyload
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDecrypter.py
More file actions
100 lines (73 loc) · 2.55 KB
/
Copy pathDecrypter.py
File metadata and controls
100 lines (73 loc) · 2.55 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# -*- coding: utf-8 -*-
# @author: RaNaN
import Queue
import os
import sys
import time
import traceback
from pyload.Thread.Plugin import PluginThread
from pyload.plugin.Plugin import Abort, Fail, Retry
class DecrypterThread(PluginThread):
"""thread for decrypting"""
def __init__(self, manager, pyfile):
"""constructor"""
PluginThread.__init__(self, manager)
self.active = pyfile
manager.localThreads.append(self)
pyfile.setStatus("decrypting")
self.start()
def getActiveFiles(self):
return [self.active]
def run(self):
"""run method"""
pyfile = self.active
retry = False
try:
self.m.core.log.info(_("Decrypting starts: %s") % pyfile.name)
pyfile.error = ""
pyfile.plugin.preprocessing(self)
except NotImplementedError:
self.m.core.log.error(_("Plugin %s is missing a function.") % pyfile.pluginname)
return
except Fail, e:
msg = e.args[0]
if msg == "offline":
pyfile.setStatus("offline")
self.m.core.log.warning(
_("Download is offline: %s") % pyfile.name)
else:
pyfile.setStatus("failed")
self.m.core.log.error(
_("Decrypting failed: %(name)s | %(msg)s") % {"name": pyfile.name, "msg": msg})
pyfile.error = msg
if self.m.core.debug:
traceback.print_exc()
return
except Abort:
self.m.core.log.info(_("Download aborted: %s") % pyfile.name)
pyfile.setStatus("aborted")
if self.m.core.debug:
traceback.print_exc()
return
except Retry:
self.m.core.log.info(_("Retrying %s") % pyfile.name)
retry = True
return self.run()
except Exception, e:
pyfile.setStatus("failed")
self.m.core.log.error(_("Decrypting failed: %(name)s | %(msg)s") % {
"name": pyfile.name, "msg": str(e)})
pyfile.error = str(e)
if self.m.core.debug:
traceback.print_exc()
self.writeDebugReport(pyfile)
return
finally:
if not retry:
pyfile.release()
self.active = False
self.m.core.files.save()
self.m.localThreads.remove(self)
sys.exc_clear()
if not retry:
pyfile.delete()