Change to consolidate and tidy some provider code

This commit is contained in:
Adam 2015-04-15 14:16:27 +08:00
parent 48365ae1f6
commit 7477a79cb8
30 changed files with 21 additions and 150 deletions

View file

@ -2,6 +2,7 @@
* Add ToTV provider * Add ToTV provider
* Fix Backlog scheduler initialization and change backlog frequency from minutes to days * Fix Backlog scheduler initialization and change backlog frequency from minutes to days
* Change to consolidate and tidy some provider code
### 0.8.1 (2015-04-15 04:16:00 UTC) ### 0.8.1 (2015-04-15 04:16:00 UTC)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 726 B

View file

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

View file

Before

Width:  |  Height:  |  Size: 681 B

After

Width:  |  Height:  |  Size: 681 B

View file

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

View file

@ -36,7 +36,6 @@ class animenzb(generic.NZBProvider):
generic.NZBProvider.__init__(self, 'animenzb') generic.NZBProvider.__init__(self, 'animenzb')
self.supportsBacklog = False self.supportsBacklog = False
self.supportsAbsoluteNumbering = True
self.anime_only = True self.anime_only = True
self.enabled = False self.enabled = False
@ -45,12 +44,6 @@ class animenzb(generic.NZBProvider):
self.url = 'http://animenzb.com/' self.url = 'http://animenzb.com/'
def isEnabled(self):
return self.enabled
def imageName(self):
return 'animenzb.gif'
def _get_season_search_strings(self, ep_obj): def _get_season_search_strings(self, ep_obj):
return [x for x in show_name_helpers.makeSceneSeasonSearchString(self.show, ep_obj)] return [x for x in show_name_helpers.makeSceneSeasonSearchString(self.show, ep_obj)]

View file

@ -64,12 +64,6 @@ class BitSoupProvider(generic.TorrentProvider):
self.categories = "&c42=1&c45=1&c49=1&c7=1" self.categories = "&c42=1&c45=1&c49=1&c7=1"
def isEnabled(self):
return self.enabled
def imageName(self):
return 'bitsoup.png'
def getQuality(self, item, anime=False): def getQuality(self, item, anime=False):
quality = Quality.sceneQuality(item[0], anime) quality = Quality.sceneQuality(item[0], anime)

View file

@ -39,8 +39,6 @@ class BTNProvider(generic.TorrentProvider):
generic.TorrentProvider.__init__(self, "BTN") generic.TorrentProvider.__init__(self, "BTN")
self.supportsBacklog = True self.supportsBacklog = True
self.supportsAbsoluteNumbering = True
self.enabled = False self.enabled = False
self.api_key = None self.api_key = None
self.ratio = None self.ratio = None
@ -49,12 +47,6 @@ class BTNProvider(generic.TorrentProvider):
self.url = "http://api.btnapps.net" self.url = "http://api.btnapps.net"
def isEnabled(self):
return self.enabled
def imageName(self):
return 'btn.png'
def _checkAuth(self): def _checkAuth(self):
if not self.api_key: if not self.api_key:
raise AuthException("Your authentication credentials for " + self.name + " are missing, check your config.") raise AuthException("Your authentication credentials for " + self.name + " are missing, check your config.")

View file

@ -47,12 +47,6 @@ class EZRSSProvider(generic.TorrentProvider):
self.url = 'https://www.ezrss.it/' self.url = 'https://www.ezrss.it/'
def isEnabled(self):
return self.enabled
def imageName(self):
return 'ezrss.png'
def getQuality(self, item, anime=False): def getQuality(self, item, anime=False):
filename = item.filename filename = item.filename

View file

@ -64,12 +64,6 @@ class FreshOnTVProvider(generic.TorrentProvider):
self.url = self.urls['base_url'] self.url = self.urls['base_url']
self.cookies = None self.cookies = None
def isEnabled(self):
return self.enabled
def imageName(self):
return 'freshontv.png'
def getQuality(self, item, anime=False): def getQuality(self, item, anime=False):
quality = Quality.sceneQuality(item[0], anime) quality = Quality.sceneQuality(item[0], anime)

View file

@ -51,11 +51,11 @@ class GenericProvider:
self.show = None self.show = None
self.supportsBacklog = False self.supportsBacklog = False
self.supportsAbsoluteNumbering = False
self.anime_only = False self.anime_only = False
self.search_mode = None self.search_mode = None
self.search_fallback = False self.search_fallback = False
self.enabled = False
self.enable_recentsearch = False self.enable_recentsearch = False
self.enable_backlog = False self.enable_backlog = False
@ -97,7 +97,7 @@ class GenericProvider:
""" """
This should be overridden and should return the config setting eg. sickbeard.MYPROVIDER This should be overridden and should return the config setting eg. sickbeard.MYPROVIDER
""" """
return False return self.enabled
def getResult(self, episodes): def getResult(self, episodes):
""" """

View file

@ -55,9 +55,6 @@ class HDBitsProvider(generic.TorrentProvider):
self.rss_url = 'https://hdbits.org/api/torrents' self.rss_url = 'https://hdbits.org/api/torrents'
self.download_url = 'https://hdbits.org/download.php?' self.download_url = 'https://hdbits.org/download.php?'
def isEnabled(self):
return self.enabled
def _checkAuth(self): def _checkAuth(self):
if not self.username or not self.passkey: if not self.username or not self.passkey:
@ -216,5 +213,4 @@ class HDBitsCache(tvcache.TVCache):
return [] return []
provider = HDBitsProvider() provider = HDBitsProvider()

View file

@ -71,12 +71,6 @@ class HDTorrentsProvider(generic.TorrentProvider):
self.cookies = None self.cookies = None
def isEnabled(self):
return self.enabled
def imageName(self):
return 'hdtorrents.png'
def getQuality(self, item, anime=False): def getQuality(self, item, anime=False):
quality = Quality.sceneQuality(item[0]) quality = Quality.sceneQuality(item[0])

View file

@ -63,12 +63,6 @@ class IPTorrentsProvider(generic.TorrentProvider):
self.categorie = 'l73=1&l78=1&l66=1&l65=1&l79=1&l5=1&l4=1' self.categorie = 'l73=1&l78=1&l66=1&l65=1&l79=1&l5=1&l4=1'
def isEnabled(self):
return self.enabled
def imageName(self):
return 'iptorrents.png'
def getQuality(self, item, anime=False): def getQuality(self, item, anime=False):
quality = Quality.sceneQuality(item[0], anime) quality = Quality.sceneQuality(item[0], anime)

View file

@ -64,12 +64,6 @@ class KATProvider(generic.TorrentProvider):
self.urls = ['https://kat.ph/', 'http://katproxy.com/', 'http://www.kickmirror.com/'] self.urls = ['https://kat.ph/', 'http://katproxy.com/', 'http://www.kickmirror.com/']
self.url = 'https://kat.ph/' self.url = 'https://kat.ph/'
def isEnabled(self):
return self.enabled
def imageName(self):
return 'kat.png'
def getQuality(self, item, anime=False): def getQuality(self, item, anime=False):
quality = Quality.sceneQuality(item[0], anime) quality = Quality.sceneQuality(item[0], anime)

View file

@ -86,9 +86,6 @@ class NewznabProvider(generic.NZBProvider):
return self.getID() + '.png' return self.getID() + '.png'
return 'newznab.png' return 'newznab.png'
def isEnabled(self):
return self.enabled
def _getURL(self, url, post_data=None, params=None, timeout=30, json=False): def _getURL(self, url, post_data=None, params=None, timeout=30, json=False):
""" """
By default this is just a simple urlopen call but this method should be overridden By default this is just a simple urlopen call but this method should be overridden
@ -218,7 +215,7 @@ class NewznabProvider(generic.NZBProvider):
params['q'] = helpers.sanitizeSceneName(cur_exception) params['q'] = helpers.sanitizeSceneName(cur_exception)
paramsNoEp = params.copy() paramsNoEp = params.copy()
paramsNoEp['q'] = paramsNoEp['q'] + " " + str(paramsNoEp['ep']) paramsNoEp['q'] = '%s.%02d' % (paramsNoEp['q'], paramsNoEp['ep'])
if "ep" in paramsNoEp: if "ep" in paramsNoEp:
paramsNoEp.pop("ep") paramsNoEp.pop("ep")
to_return.append(paramsNoEp) to_return.append(paramsNoEp)

View file

@ -71,12 +71,6 @@ class NextGenProvider(generic.TorrentProvider):
self.login_opener = None self.login_opener = None
def isEnabled(self):
return self.enabled
def imageName(self):
return 'nextgen.png'
def getQuality(self, item, anime=False): def getQuality(self, item, anime=False):
quality = Quality.sceneQuality(item[0], anime) quality = Quality.sceneQuality(item[0], anime)

View file

@ -35,7 +35,6 @@ class NyaaProvider(generic.TorrentProvider):
generic.TorrentProvider.__init__(self, "NyaaTorrents") generic.TorrentProvider.__init__(self, "NyaaTorrents")
self.supportsBacklog = True self.supportsBacklog = True
self.supportsAbsoluteNumbering = True
self.anime_only = True self.anime_only = True
self.enabled = False self.enabled = False
self.ratio = None self.ratio = None
@ -44,12 +43,6 @@ class NyaaProvider(generic.TorrentProvider):
self.url = 'http://www.nyaa.se/' self.url = 'http://www.nyaa.se/'
def isEnabled(self):
return self.enabled
def imageName(self):
return 'nyaatorrents.png'
def getQuality(self, item, anime=False): def getQuality(self, item, anime=False):
title = item.title title = item.title
quality = Quality.sceneQuality(title, anime) quality = Quality.sceneQuality(title, anime)

View file

@ -49,9 +49,6 @@ class OmgwtfnzbsProvider(generic.NZBProvider):
self.url = 'https://omgwtfnzbs.org/' self.url = 'https://omgwtfnzbs.org/'
self.supportsBacklog = True self.supportsBacklog = True
def isEnabled(self):
return self.enabled
def _checkAuth(self): def _checkAuth(self):
if not self.username or not self.api_key: if not self.username or not self.api_key:

View file

@ -69,9 +69,6 @@ class TorrentRssProvider(generic.TorrentProvider):
return self.getID() + '.png' return self.getID() + '.png'
return 'torrentrss.png' return 'torrentrss.png'
def isEnabled(self):
return self.enabled
def _get_title_and_url(self, item): def _get_title_and_url(self, item):
title, url = None, None title, url = None, None

View file

@ -66,12 +66,6 @@ class SCCProvider(generic.TorrentProvider):
self.categories = 'c27=27&c17=17&c11=11' self.categories = 'c27=27&c17=17&c11=11'
def isEnabled(self):
return self.enabled
def imageName(self):
return 'scc.png'
def getQuality(self, item, anime=False): def getQuality(self, item, anime=False):
quality = Quality.sceneQuality(item[0], anime) quality = Quality.sceneQuality(item[0], anime)

View file

@ -66,12 +66,6 @@ class SpeedCDProvider(generic.TorrentProvider):
self.categories = {'Season': {'c14': 1}, 'Episode': {'c2': 1, 'c49': 1}, 'RSS': {'c14': 1, 'c2': 1, 'c49': 1}} self.categories = {'Season': {'c14': 1}, 'Episode': {'c2': 1, 'c49': 1}, 'RSS': {'c14': 1, 'c2': 1, 'c49': 1}}
def isEnabled(self):
return self.enabled
def imageName(self):
return 'speedcd.png'
def getQuality(self, item, anime=False): def getQuality(self, item, anime=False):
quality = Quality.sceneQuality(item[0], anime) quality = Quality.sceneQuality(item[0], anime)

View file

@ -59,12 +59,6 @@ class ThePirateBayProvider(generic.TorrentProvider):
self.re_title_url = '/torrent/(?P<id>\d+)/(?P<title>.*?)//1".+?(?P<url>magnet.*?)//1".+?(?P<seeders>\d+)</td>.+?(?P<leechers>\d+)</td>' self.re_title_url = '/torrent/(?P<id>\d+)/(?P<title>.*?)//1".+?(?P<url>magnet.*?)//1".+?(?P<seeders>\d+)</td>.+?(?P<leechers>\d+)</td>'
def isEnabled(self):
return self.enabled
def imageName(self):
return 'thepiratebay.png'
def getQuality(self, item, anime=False): def getQuality(self, item, anime=False):
quality = Quality.sceneQuality(item[0], anime) quality = Quality.sceneQuality(item[0], anime)

View file

@ -37,7 +37,6 @@ class TokyoToshokanProvider(generic.TorrentProvider):
generic.TorrentProvider.__init__(self, "TokyoToshokan") generic.TorrentProvider.__init__(self, "TokyoToshokan")
self.supportsBacklog = True self.supportsBacklog = True
self.supportsAbsoluteNumbering = True
self.anime_only = True self.anime_only = True
self.enabled = False self.enabled = False
self.ratio = None self.ratio = None
@ -46,12 +45,6 @@ class TokyoToshokanProvider(generic.TorrentProvider):
self.url = 'http://tokyotosho.info/' self.url = 'http://tokyotosho.info/'
def isEnabled(self):
return self.enabled
def imageName(self):
return 'tokyotoshokan.png'
def _get_title_and_url(self, item): def _get_title_and_url(self, item):
title, url = item title, url = item

View file

@ -64,12 +64,6 @@ class TorrentBytesProvider(generic.TorrentProvider):
self.categories = '&c41=1&c33=1&c38=1&c32=1&c37=1' self.categories = '&c41=1&c33=1&c38=1&c32=1&c37=1'
def isEnabled(self):
return self.enabled
def imageName(self):
return 'torrentbytes.png'
def getQuality(self, item, anime=False): def getQuality(self, item, anime=False):
quality = Quality.sceneQuality(item[0], anime) quality = Quality.sceneQuality(item[0], anime)

View file

@ -66,12 +66,6 @@ class TorrentDayProvider(generic.TorrentProvider):
self.categories = {'Season': {'c14': 1}, 'Episode': {'c2': 1, 'c26': 1, 'c7': 1, 'c24': 1}, self.categories = {'Season': {'c14': 1}, 'Episode': {'c2': 1, 'c26': 1, 'c7': 1, 'c24': 1},
'RSS': {'c2': 1, 'c26': 1, 'c7': 1, 'c24': 1, 'c14': 1}} 'RSS': {'c2': 1, 'c26': 1, 'c7': 1, 'c24': 1, 'c14': 1}}
def isEnabled(self):
return self.enabled
def imageName(self):
return 'torrentday.png'
def getQuality(self, item, anime=False): def getQuality(self, item, anime=False):
quality = Quality.sceneQuality(item[0], anime) quality = Quality.sceneQuality(item[0], anime)

View file

@ -67,12 +67,6 @@ class TorrentLeechProvider(generic.TorrentProvider):
self.categories = "2,26,27,32" self.categories = "2,26,27,32"
def isEnabled(self):
return self.enabled
def imageName(self):
return 'torrentleech.png'
def getQuality(self, item, anime=False): def getQuality(self, item, anime=False):
quality = Quality.sceneQuality(item[0], anime) quality = Quality.sceneQuality(item[0], anime)

View file

@ -30,7 +30,6 @@ class ToTVProvider(generic.TorrentProvider):
generic.TorrentProvider.__init__(self, 'ToTV') generic.TorrentProvider.__init__(self, 'ToTV')
self.supportsBacklog = True self.supportsBacklog = True
self.supportsAbsoluteNumbering = True
self.enabled = False self.enabled = False
self.api_key = None self.api_key = None
@ -42,12 +41,6 @@ class ToTVProvider(generic.TorrentProvider):
self.download_url = 'http://titansof.tv/api/torrents/%s/download?apikey=%s' self.download_url = 'http://titansof.tv/api/torrents/%s/download?apikey=%s'
self.session = requests.Session() self.session = requests.Session()
def isEnabled(self):
return self.enabled
def imageName(self):
return 'totv.png'
def _checkAuth(self): def _checkAuth(self):
if not self.api_key: if not self.api_key:
raise AuthException('Your authentication credentials for ' + self.name + ' are missing, check your config.') raise AuthException('Your authentication credentials for ' + self.name + ' are missing, check your config.')

View file

@ -29,9 +29,6 @@ class WombleProvider(generic.NZBProvider):
self.cache = WombleCache(self) self.cache = WombleCache(self)
self.url = 'http://newshost.co.za/' self.url = 'http://newshost.co.za/'
def isEnabled(self):
return self.enabled
class WombleCache(tvcache.TVCache): class WombleCache(tvcache.TVCache):
def __init__(self, provider): def __init__(self, provider):