Repository navigation
Expand file tree
/
Copy pathReloadCc.py
More file actions
65 lines (50 loc) · 2.24 KB
/
Copy pathReloadCc.py
File metadata and controls
65 lines (50 loc) · 2.24 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
from module.plugins.internal.MultiHoster import MultiHoster
from module.common.json_layer import json_loads
from module.network.RequestFactory import getURL
class ReloadCc(MultiHoster):
__name__ = "ReloadCc"
__version__ = "0.3"
__type__ = "hook"
__description__ = """Reload.cc hook plugin"""
__config__ = [("activated", "bool", "Activated", "False"),
("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported):", "all"),
("hosterList", "str", "Hoster list (comma separated)", "")]
__author_name__ = ("Reload Team")
__author_mail__ = ("hello@reload.cc")
interval = 0 # Disable periodic calls
def getHoster(self):
# If no accounts are available there will be no hosters available
if not self.account or not self.account.canUse():
print "ReloadCc: No accounts available"
return []
# Get account data
(user, data) = self.account.selectAccount()
# Get supported hosters list from reload.cc using the json API v1
query_params = dict(
via='pyload',
v=1,
get_supported='true',
get_traffic='true',
user=user
)
try:
query_params.update(dict(hash=self.account.infos[user]['pwdhash']))
except Exception:
query_params.update(dict(pwd=data['password']))
answer = getURL("http://api.reload.cc/login", get=query_params)
data = json_loads(answer)
# If account is not valid thera are no hosters available
if data['status'] != "ok":
print "ReloadCc: Status is not ok: %s" % data['status']
return []
# Extract hosters from json file
return data['msg']['supportedHosters']
def coreReady(self):
# Get account plugin and check if there is a valid account available
self.account = self.core.accountManager.getAccountPlugin("ReloadCc")
if not self.account.canUse():
self.account = None
self.logError("Please add a valid reload.cc account first and restart pyLoad.")
return
# Run the overwriten core ready which actually enables the multihoster hook
return MultiHoster.coreReady(self)