2014-03-10 01:18:05 -04:00
|
|
|
# Author: Nic Wolfe <nic@wolfeden.ca>
|
|
|
|
# URL: http://code.google.com/p/sickbeard/
|
|
|
|
#
|
2014-05-23 08:37:22 -04:00
|
|
|
# This file is part of SickRage.
|
2014-03-10 01:18:05 -04:00
|
|
|
#
|
2014-05-23 08:37:22 -04:00
|
|
|
# SickRage is free software: you can redistribute it and/or modify
|
2014-03-10 01:18:05 -04:00
|
|
|
# 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.
|
|
|
|
#
|
2014-05-23 08:37:22 -04:00
|
|
|
# SickRage is distributed in the hope that it will be useful,
|
2014-03-10 01:18:05 -04:00
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2014-08-29 01:16:25 -04:00
|
|
|
# GNU General Public License for more details.
|
2014-03-10 01:18:05 -04:00
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
2014-05-23 08:37:22 -04:00
|
|
|
# along with SickRage. If not, see <http://www.gnu.org/licenses/>.
|
2014-03-10 01:18:05 -04:00
|
|
|
|
|
|
|
__all__ = ['ezrss',
|
|
|
|
'womble',
|
|
|
|
'btn',
|
|
|
|
'thepiratebay',
|
2015-01-31 13:48:20 -05:00
|
|
|
'oldpiratebay',
|
2014-03-10 01:18:05 -04:00
|
|
|
'kat',
|
|
|
|
'torrentleech',
|
|
|
|
'scc',
|
|
|
|
'hdtorrents',
|
|
|
|
'torrentday',
|
|
|
|
'hdbits',
|
2015-01-19 03:28:21 -05:00
|
|
|
'hounddawgs',
|
2014-03-10 01:18:05 -04:00
|
|
|
'iptorrents',
|
|
|
|
'omgwtfnzbs',
|
2014-04-26 09:35:37 -04:00
|
|
|
'nextgen',
|
2014-05-26 02:29:22 -04:00
|
|
|
'speedcd',
|
|
|
|
'nyaatorrents',
|
2014-07-10 10:15:44 -04:00
|
|
|
'fanzub',
|
2014-07-11 05:52:44 -04:00
|
|
|
'torrentbytes',
|
2014-07-12 22:29:53 -04:00
|
|
|
'animezb',
|
2014-07-19 23:14:39 -04:00
|
|
|
'freshontv',
|
2014-09-05 20:16:04 -04:00
|
|
|
'bitsoup',
|
2014-09-11 13:26:17 -04:00
|
|
|
't411',
|
|
|
|
'tokyotoshokan',
|
2015-02-12 10:46:21 -05:00
|
|
|
'shazbat',
|
2014-03-25 01:57:24 -04:00
|
|
|
]
|
2014-03-10 01:18:05 -04:00
|
|
|
|
|
|
|
import sickbeard
|
2014-05-01 00:09:03 -04:00
|
|
|
import generic
|
2014-12-20 00:57:11 -05:00
|
|
|
|
2014-03-10 01:18:05 -04:00
|
|
|
from sickbeard import logger
|
|
|
|
from os import sys
|
2014-12-03 09:41:51 -05:00
|
|
|
from random import shuffle
|
2014-03-10 01:18:05 -04:00
|
|
|
|
2014-12-03 09:41:51 -05:00
|
|
|
def sortedProviderList(randomize=False):
|
2014-03-10 01:18:05 -04:00
|
|
|
initialList = sickbeard.providerList + sickbeard.newznabProviderList + sickbeard.torrentRssProviderList
|
|
|
|
providerDict = dict(zip([x.getID() 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 any modules that are missing from that list
|
|
|
|
for curModule in providerDict:
|
|
|
|
if providerDict[curModule] not in newList:
|
|
|
|
newList.append(providerDict[curModule])
|
|
|
|
|
2014-12-03 09:41:51 -05:00
|
|
|
if randomize:
|
|
|
|
shuffle(newList)
|
|
|
|
|
2014-03-10 01:18:05 -04:00
|
|
|
return newList
|
|
|
|
|
2014-08-29 01:16:25 -04:00
|
|
|
|
2014-03-25 01:57:24 -04:00
|
|
|
def makeProviderList():
|
2014-03-10 01:18:05 -04:00
|
|
|
return [x.provider for x in [getProviderModule(y) for y in __all__] if x]
|
|
|
|
|
|
|
|
|
2014-03-25 01:57:24 -04:00
|
|
|
def getNewznabProviderList(data):
|
2014-03-10 01:18:05 -04:00
|
|
|
defaultList = [makeNewznabProvider(x) for x in getDefaultNewznabProviders().split('!!!')]
|
|
|
|
providerList = filter(lambda x: x, [makeNewznabProvider(x) for x in data.split('!!!')])
|
|
|
|
|
2014-05-20 16:51:54 -04:00
|
|
|
seen_values = set()
|
|
|
|
providerListDeduped = []
|
|
|
|
for d in providerList:
|
|
|
|
value = d.name
|
|
|
|
if value not in seen_values:
|
|
|
|
providerListDeduped.append(d)
|
|
|
|
seen_values.add(value)
|
|
|
|
|
|
|
|
providerList = providerListDeduped
|
2014-03-10 01:18:05 -04:00
|
|
|
providerDict = dict(zip([x.name for x in providerList], providerList))
|
|
|
|
|
|
|
|
for curDefault in defaultList:
|
|
|
|
if not curDefault:
|
|
|
|
continue
|
|
|
|
|
|
|
|
if curDefault.name not in providerDict:
|
|
|
|
curDefault.default = True
|
|
|
|
providerList.append(curDefault)
|
|
|
|
else:
|
|
|
|
providerDict[curDefault.name].default = True
|
|
|
|
providerDict[curDefault.name].name = curDefault.name
|
|
|
|
providerDict[curDefault.name].url = curDefault.url
|
|
|
|
providerDict[curDefault.name].needs_auth = curDefault.needs_auth
|
2014-05-17 01:23:11 -04:00
|
|
|
providerDict[curDefault.name].search_mode = curDefault.search_mode
|
|
|
|
providerDict[curDefault.name].search_fallback = curDefault.search_fallback
|
2014-08-29 01:16:25 -04:00
|
|
|
providerDict[curDefault.name].enable_daily = curDefault.enable_daily
|
|
|
|
providerDict[curDefault.name].enable_backlog = curDefault.enable_backlog
|
2014-03-25 01:57:24 -04:00
|
|
|
|
2014-03-10 01:18:05 -04:00
|
|
|
return filter(lambda x: x, providerList)
|
|
|
|
|
|
|
|
|
|
|
|
def makeNewznabProvider(configString):
|
|
|
|
if not configString:
|
|
|
|
return None
|
|
|
|
|
2014-05-17 01:23:11 -04:00
|
|
|
search_mode = 'eponly'
|
|
|
|
search_fallback = 0
|
2014-08-29 01:16:25 -04:00
|
|
|
enable_daily = 0
|
|
|
|
enable_backlog = 0
|
2014-05-17 01:23:11 -04:00
|
|
|
|
2014-03-10 01:18:05 -04:00
|
|
|
try:
|
2014-08-29 01:52:02 -04:00
|
|
|
values = configString.split('|')
|
|
|
|
if len(values) == 9:
|
|
|
|
name, url, key, catIDs, enabled, search_mode, search_fallback, enable_daily, enable_backlog = values
|
|
|
|
else:
|
|
|
|
name = values[0]
|
|
|
|
url = values[1]
|
|
|
|
key = values[2]
|
|
|
|
catIDs = values[3]
|
|
|
|
enabled = values[4]
|
2014-08-29 01:30:30 -04:00
|
|
|
except ValueError:
|
2014-08-29 01:52:02 -04:00
|
|
|
logger.log(u"Skipping Newznab provider string: '" + configString + "', incorrect format", logger.ERROR)
|
|
|
|
return None
|
2014-03-10 01:18:05 -04:00
|
|
|
|
|
|
|
newznab = sys.modules['sickbeard.providers.newznab']
|
|
|
|
|
2014-05-20 23:22:48 -04:00
|
|
|
newProvider = newznab.NewznabProvider(name, url, key=key, catIDs=catIDs, search_mode=search_mode,
|
2014-08-29 01:16:25 -04:00
|
|
|
search_fallback=search_fallback, enable_daily=enable_daily,
|
|
|
|
enable_backlog=enable_backlog)
|
2014-03-10 01:18:05 -04:00
|
|
|
newProvider.enabled = enabled == '1'
|
|
|
|
|
|
|
|
return newProvider
|
|
|
|
|
2014-03-25 01:57:24 -04:00
|
|
|
|
2014-03-10 01:18:05 -04:00
|
|
|
def getTorrentRssProviderList(data):
|
|
|
|
providerList = filter(lambda x: x, [makeTorrentRssProvider(x) for x in data.split('!!!')])
|
2014-05-20 23:22:48 -04:00
|
|
|
|
|
|
|
seen_values = set()
|
|
|
|
providerListDeduped = []
|
|
|
|
for d in providerList:
|
|
|
|
value = d.name
|
|
|
|
if value not in seen_values:
|
|
|
|
providerListDeduped.append(d)
|
|
|
|
seen_values.add(value)
|
|
|
|
|
2014-03-10 01:18:05 -04:00
|
|
|
return filter(lambda x: x, providerList)
|
|
|
|
|
|
|
|
|
2014-03-25 01:57:24 -04:00
|
|
|
def makeTorrentRssProvider(configString):
|
2014-03-10 01:18:05 -04:00
|
|
|
if not configString:
|
|
|
|
return None
|
|
|
|
|
2014-05-25 03:28:13 -04:00
|
|
|
cookies = None
|
2014-05-20 23:22:48 -04:00
|
|
|
search_mode = 'eponly'
|
|
|
|
search_fallback = 0
|
2014-08-29 01:16:25 -04:00
|
|
|
enable_daily = 0
|
|
|
|
enable_backlog = 0
|
2014-05-20 23:22:48 -04:00
|
|
|
|
|
|
|
try:
|
2014-08-29 01:52:02 -04:00
|
|
|
values = configString.split('|')
|
|
|
|
if len(values) == 8:
|
|
|
|
name, url, cookies, enabled, search_mode, search_fallback, enable_daily, enable_backlog = values
|
|
|
|
else:
|
|
|
|
name = values[0]
|
|
|
|
url = values[1]
|
|
|
|
enabled = values[3]
|
2014-05-20 23:22:48 -04:00
|
|
|
except ValueError:
|
2014-08-29 01:52:02 -04:00
|
|
|
logger.log(u"Skipping RSS Torrent provider string: '" + configString + "', incorrect format",
|
|
|
|
logger.ERROR)
|
|
|
|
return None
|
2014-03-10 01:18:05 -04:00
|
|
|
|
2014-06-11 04:34:28 -04:00
|
|
|
try:
|
|
|
|
torrentRss = sys.modules['sickbeard.providers.rsstorrent']
|
|
|
|
except:
|
|
|
|
return
|
2014-03-10 01:18:05 -04:00
|
|
|
|
2014-08-29 01:16:25 -04:00
|
|
|
newProvider = torrentRss.TorrentRssProvider(name, url, cookies, search_mode, search_fallback, enable_daily,
|
|
|
|
enable_backlog)
|
2014-03-10 01:18:05 -04:00
|
|
|
newProvider.enabled = enabled == '1'
|
|
|
|
|
|
|
|
return newProvider
|
|
|
|
|
2014-03-25 01:57:24 -04:00
|
|
|
|
2014-03-10 01:18:05 -04:00
|
|
|
def getDefaultNewznabProviders():
|
2014-09-03 03:36:42 -04:00
|
|
|
return 'Sick Beard Index|http://lolo.sickbeard.com/|0|5030,5040|0|eponly|0|0|0!!!NZBs.org|https://nzbs.org/||5030,5040|0|eponly|0|0|0!!!Usenet-Crawler|https://www.usenet-crawler.com/||5030,5040|0|eponly|0|0|0'
|
2014-03-10 01:18:05 -04:00
|
|
|
|
2014-03-25 01:57:24 -04:00
|
|
|
|
2014-03-10 01:18:05 -04:00
|
|
|
def getProviderModule(name):
|
|
|
|
name = name.lower()
|
|
|
|
prefix = "sickbeard.providers."
|
2014-03-25 01:57:24 -04:00
|
|
|
if name in __all__ and prefix + name in sys.modules:
|
|
|
|
return sys.modules[prefix + name]
|
2014-03-10 01:18:05 -04:00
|
|
|
else:
|
2014-03-25 01:57:24 -04:00
|
|
|
raise Exception("Can't find " + prefix + name + " in " + "Providers")
|
2014-03-10 01:18:05 -04:00
|
|
|
|
|
|
|
|
2014-03-25 01:57:24 -04:00
|
|
|
def getProviderClass(id):
|
|
|
|
providerMatch = [x for x in
|
|
|
|
sickbeard.providerList + sickbeard.newznabProviderList + sickbeard.torrentRssProviderList if
|
|
|
|
x.getID() == id]
|
2014-03-10 01:18:05 -04:00
|
|
|
|
|
|
|
if len(providerMatch) != 1:
|
|
|
|
return None
|
|
|
|
else:
|
|
|
|
return providerMatch[0]
|