forked from SickChill/sickchill
-
Notifications
You must be signed in to change notification settings - Fork 0
/
__init__.py
92 lines (74 loc) · 3.59 KB
/
__init__.py
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
# coding=utf-8
# Author: Nic Wolfe <nic@wolfeden.ca>
#
# URL: https://sickrage.github.io
#
# This file is part of SickRage.
#
# SickRage is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# SickRage is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with SickRage. If not, see <http://www.gnu.org/licenses/>.
from os import sys
from random import shuffle
import sickbeard
from sickbeard.providers import btn, newznab, rsstorrent, womble, thepiratebay, torrentleech, kat, iptorrents, torrentz, \
omgwtfnzbs, scc, hdtorrents, torrentday, hdbits, hounddawgs, speedcd, nyaatorrents, bluetigers, xthor, abnormal, phxbit, torrentbytes, cpasbien,\
freshontv, morethantv, bitsoup, t411, tokyotoshokan, shazbat, rarbg, alpharatio, tntvillage, binsearch, torrentproject, extratorrent, \
scenetime, btdigg, transmitthenet, tvchaosuk, bitcannon, pretome, gftracker, hdspace, newpct, elitetorrent, bitsnoop, danishbits, hd4free, limetorrents, \
binnewz
__all__ = [
'womble', 'btn', 'thepiratebay', 'kat', 'torrentleech', 'scc', 'hdtorrents',
'torrentday', 'hdbits', 'hounddawgs', 'iptorrents', 'omgwtfnzbs',
'speedcd', 'nyaatorrents', 'torrentbytes', 'freshontv', 'cpasbien',
'morethantv', 'bitsoup', 't411', 'tokyotoshokan', 'alpharatio',
'shazbat', 'rarbg', 'tntvillage', 'binsearch', 'bluetigers',
'xthor', 'abnormal', 'phxbit', 'scenetime', 'btdigg', 'transmitthenet', 'tvchaosuk',
'torrentproject', 'extratorrent', 'bitcannon', 'torrentz', 'pretome', 'gftracker',
'hdspace', 'newpct', 'elitetorrent', 'bitsnoop', 'danishbits', 'hd4free', 'limetorrents',
'binnewz'
]
def sortedProviderList(randomize=False):
initialList = sickbeard.providerList + sickbeard.newznabProviderList + sickbeard.torrentRssProviderList
providerDict = dict(zip([x.get_id() for x in initialList], initialList))
newList = []
# add all modules in the priority list, in order
for curModule in sickbeard.PROVIDER_ORDER:
if curModule in providerDict:
newList.append(providerDict[curModule])
# add all enabled providers first
for curModule in providerDict:
if providerDict[curModule] not in newList and providerDict[curModule].is_enabled():
newList.append(providerDict[curModule])
# add any modules that are missing from that list
for curModule in providerDict:
if providerDict[curModule] not in newList:
newList.append(providerDict[curModule])
if randomize:
shuffle(newList)
return newList
def makeProviderList():
return [x.provider for x in [getProviderModule(y) for y in __all__] if x]
def getProviderModule(name):
name = name.lower()
prefix = "sickbeard.providers."
if name in __all__ and prefix + name in sys.modules:
return sys.modules[prefix + name]
else:
raise Exception("Can't find " + prefix + name + " in " + "Providers")
def getProviderClass(provider_id):
providerMatch = [x for x in
sickbeard.providerList + sickbeard.newznabProviderList + sickbeard.torrentRssProviderList if
x and x.get_id() == provider_id]
if len(providerMatch) != 1:
return None
else:
return providerMatch[0]