Repository navigation
Expand file tree
/
Copy pathMultiHoster.py
More file actions
99 lines (67 loc) · 3.19 KB
/
Copy pathMultiHoster.py
File metadata and controls
99 lines (67 loc) · 3.19 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
# -*- coding: utf-8 -*-
import re
from module.plugins.internal.Plugin import Fail
from module.plugins.internal.SimpleHoster import SimpleHoster
class MultiHoster(SimpleHoster):
__name__ = "MultiHoster"
__type__ = "hoster"
__version__ = "0.60"
__status__ = "stable"
__pattern__ = r'^unmatchable$'
__config__ = [("activated" , "bool", "Activated" , True ),
("use_premium" , "bool", "Use premium account if available" , True ),
("fallback" , "bool", "Fallback to free download if premium fails" , False),
("chk_filesize" , "bool", "Check file size" , True ),
("max_wait" , "int" , "Reconnect if waiting time is greater than minutes", 10 ),
("revert_failed", "bool", "Revert to standard download if fails" , True )]
__description__ = """Multi hoster plugin"""
__license__ = "GPLv3"
__authors__ = [("Walter Purcaro", "vuolter@gmail.com")]
OFFLINE_PATTERN = r'^unmatchable$'
DIRECT_LINK = None
LEECH_HOSTER = False
LOGIN_ACCOUNT = True
def init(self):
self.PLUGIN_NAME = self.pyload.pluginManager.hosterPlugins.get(self.classname)['name']
def _log(self, level, plugintype, pluginname, messages):
messages = (self.PLUGIN_NAME,) + messages
return super(MultiHoster, self)._log(level, plugintype, pluginname, messages)
def setup(self):
self.chunk_limit = 1
self.multiDL = bool(self.account)
self.resume_download = self.premium
#@TODO: Recheck in 0.4.10
def setup_base(self):
klass = self.pyload.pluginManager.loadClass("hoster", self.classname)
self.get_info = klass.get_info
super(MultiHoster, self).setup_base()
def _prepare(self):
super(MultiHoster, self)._prepare()
if self.DIRECT_LINK is None:
self.direct_dl = self.__pattern__ != r'^unmatchable$' and re.match(self.__pattern__, self.pyfile.url)
else:
self.direct_dl = self.DIRECT_LINK
def _process(self, thread):
try:
super(MultiHoster, self)._process(thread)
except Fail, e:
if self.config.get('revert_failed', True) and \
self.pyload.pluginManager.hosterPlugins.get(self.classname).get('new_module'):
hdict = self.pyload.pluginManager.hosterPlugins.get(self.classname)
tmp_module = hdict['new_module']
tmp_name = hdict['new_name']
hdict.pop('new_module', None)
hdict.pop('new_name', None)
self.pyfile.initPlugin()
hdict['new_module'] = tmp_module
hdict['new_name'] = tmp_name
self.restart(_("Revert to original hoster plugin"))
else:
raise Fail(e)
def handle_premium(self, pyfile):
return self.handle_free(pyfile)
def handle_free(self, pyfile):
if self.premium:
raise NotImplementedError
else:
self.fail(_("Required premium account not found"))