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
* 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)

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')
self.supportsBacklog = False
self.supportsAbsoluteNumbering = True
self.anime_only = True
self.enabled = False
@ -45,12 +44,6 @@ class animenzb(generic.NZBProvider):
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):
return [x for x in show_name_helpers.makeSceneSeasonSearchString(self.show, ep_obj)]
@ -124,7 +117,7 @@ class animenzbCache(tvcache.TVCache):
tvcache.TVCache.__init__(self, provider)
self.minTime = 20
def _getRSSData(self):

View file

@ -64,12 +64,6 @@ class BitSoupProvider(generic.TorrentProvider):
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):
quality = Quality.sceneQuality(item[0], anime)

View file

@ -39,8 +39,6 @@ class BTNProvider(generic.TorrentProvider):
generic.TorrentProvider.__init__(self, "BTN")
self.supportsBacklog = True
self.supportsAbsoluteNumbering = True
self.enabled = False
self.api_key = None
self.ratio = None
@ -49,12 +47,6 @@ class BTNProvider(generic.TorrentProvider):
self.url = "http://api.btnapps.net"
def isEnabled(self):
return self.enabled
def imageName(self):
return 'btn.png'
def _checkAuth(self):
if not self.api_key:
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/'
def isEnabled(self):
return self.enabled
def imageName(self):
return 'ezrss.png'
def getQuality(self, item, anime=False):
filename = item.filename

View file

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

View file

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

View file

@ -1,16 +1,16 @@
# This file is part of SickGear.
#
#
# SickGear 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.
#
# 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.
#
# SickGear 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
# 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 SickGear. If not, see <http://www.gnu.org/licenses/>.
import re
@ -55,9 +55,6 @@ class HDBitsProvider(generic.TorrentProvider):
self.rss_url = 'https://hdbits.org/api/torrents'
self.download_url = 'https://hdbits.org/download.php?'
def isEnabled(self):
return self.enabled
def _checkAuth(self):
if not self.username or not self.passkey:
@ -201,7 +198,7 @@ class HDBitsCache(tvcache.TVCache):
tvcache.TVCache.__init__(self, provider)
# only poll HDBits every 15 minutes max
# only poll HDBits every 15 minutes max
self.minTime = 15
def _getRSSData(self):
@ -216,5 +213,4 @@ class HDBitsCache(tvcache.TVCache):
return []
provider = HDBitsProvider()
provider = HDBitsProvider()

View file

@ -71,12 +71,6 @@ class HDTorrentsProvider(generic.TorrentProvider):
self.cookies = None
def isEnabled(self):
return self.enabled
def imageName(self):
return 'hdtorrents.png'
def getQuality(self, item, anime=False):
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'
def isEnabled(self):
return self.enabled
def imageName(self):
return 'iptorrents.png'
def getQuality(self, item, anime=False):
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.url = 'https://kat.ph/'
def isEnabled(self):
return self.enabled
def imageName(self):
return 'kat.png'
def getQuality(self, item, anime=False):
quality = Quality.sceneQuality(item[0], anime)

View file

@ -86,9 +86,6 @@ class NewznabProvider(generic.NZBProvider):
return self.getID() + '.png'
return 'newznab.png'
def isEnabled(self):
return self.enabled
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
@ -218,7 +215,7 @@ class NewznabProvider(generic.NZBProvider):
params['q'] = helpers.sanitizeSceneName(cur_exception)
paramsNoEp = params.copy()
paramsNoEp['q'] = paramsNoEp['q'] + " " + str(paramsNoEp['ep'])
paramsNoEp['q'] = '%s.%02d' % (paramsNoEp['q'], paramsNoEp['ep'])
if "ep" in paramsNoEp:
paramsNoEp.pop("ep")
to_return.append(paramsNoEp)

View file

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

View file

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

View file

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

View file

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

View file

@ -66,12 +66,6 @@ class SCCProvider(generic.TorrentProvider):
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):
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}}
def isEnabled(self):
return self.enabled
def imageName(self):
return 'speedcd.png'
def getQuality(self, item, anime=False):
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>'
def isEnabled(self):
return self.enabled
def imageName(self):
return 'thepiratebay.png'
def getQuality(self, item, anime=False):
quality = Quality.sceneQuality(item[0], anime)

View file

@ -37,7 +37,6 @@ class TokyoToshokanProvider(generic.TorrentProvider):
generic.TorrentProvider.__init__(self, "TokyoToshokan")
self.supportsBacklog = True
self.supportsAbsoluteNumbering = True
self.anime_only = True
self.enabled = False
self.ratio = None
@ -46,12 +45,6 @@ class TokyoToshokanProvider(generic.TorrentProvider):
self.url = 'http://tokyotosho.info/'
def isEnabled(self):
return self.enabled
def imageName(self):
return 'tokyotoshokan.png'
def _get_title_and_url(self, item):
title, url = item
@ -105,19 +98,19 @@ class TokyoToshokanProvider(generic.TorrentProvider):
with BS4Parser(data, features=["html5lib", "permissive"]) as soup:
torrent_table = soup.find('table', attrs={'class': 'listing'})
torrent_rows = torrent_table.find_all('tr') if torrent_table else []
if torrent_rows:
if torrent_rows:
if torrent_rows[0].find('td', attrs={'class': 'centertext'}):
a = 1
else:
a = 0
for top, bottom in zip(torrent_rows[a::2], torrent_rows[a::2]):
title = top.find('td', attrs={'class': 'desc-top'}).text
url = top.find('td', attrs={'class': 'desc-top'}).find('a')['href']
if not title or not url:
continue
item = title.lstrip(), url
results.append(item)

View file

@ -64,12 +64,6 @@ class TorrentBytesProvider(generic.TorrentProvider):
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):
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},
'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):
quality = Quality.sceneQuality(item[0], anime)

View file

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

View file

@ -30,7 +30,6 @@ class ToTVProvider(generic.TorrentProvider):
generic.TorrentProvider.__init__(self, 'ToTV')
self.supportsBacklog = True
self.supportsAbsoluteNumbering = True
self.enabled = False
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.session = requests.Session()
def isEnabled(self):
return self.enabled
def imageName(self):
return 'totv.png'
def _checkAuth(self):
if not self.api_key:
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.url = 'http://newshost.co.za/'
def isEnabled(self):
return self.enabled
class WombleCache(tvcache.TVCache):
def __init__(self, provider):