mirror of
https://github.com/SickGear/SickGear.git
synced 2024-12-01 00:43:37 +00:00
Fixed issues with searching for air by date shows and sports.
Several bugfixes applied throughout the code along with cleanup performed.
This commit is contained in:
parent
a912140ec5
commit
9384881241
24 changed files with 239 additions and 246 deletions
|
@ -2,5 +2,6 @@ from config import Config
|
||||||
config = Config.instance()
|
config = Config.instance()
|
||||||
from history import History
|
from history import History
|
||||||
history = History.instance()
|
history = History.instance()
|
||||||
|
import jsonrpc
|
||||||
from jsonrpc import Server, MultiCall, Fault
|
from jsonrpc import Server, MultiCall, Fault
|
||||||
from jsonrpc import ProtocolError, loads, dumps
|
from jsonrpc import ProtocolError, loads, dumps
|
||||||
|
|
|
@ -190,7 +190,7 @@ class BTNProvider(generic.TorrentProvider):
|
||||||
|
|
||||||
return (title, url)
|
return (title, url)
|
||||||
|
|
||||||
def _get_season_search_strings(self, season, episode):
|
def _get_season_search_strings(self, ep_obj):
|
||||||
search_params = []
|
search_params = []
|
||||||
|
|
||||||
name_exceptions = scene_exceptions.get_scene_exceptions(self.show.indexerid) + [self.show.name]
|
name_exceptions = scene_exceptions.get_scene_exceptions(self.show.indexerid) + [self.show.name]
|
||||||
|
@ -210,17 +210,17 @@ class BTNProvider(generic.TorrentProvider):
|
||||||
|
|
||||||
# Search for entire seasons: no need to do special things for air by date shows
|
# Search for entire seasons: no need to do special things for air by date shows
|
||||||
whole_season_params['category'] = 'Season'
|
whole_season_params['category'] = 'Season'
|
||||||
whole_season_params['name'] = 'Season ' + str(season)
|
whole_season_params['name'] = 'Season ' + str(ep_obj.scene_season)
|
||||||
search_params.append(whole_season_params)
|
search_params.append(whole_season_params)
|
||||||
|
|
||||||
# Search for episodes in the season
|
# Search for episodes in the season
|
||||||
search_params.append(self._get_episode_search_strings(season, episode)[0])
|
search_params.append(self._get_episode_search_strings(ep_obj)[0])
|
||||||
|
|
||||||
return search_params
|
return search_params
|
||||||
|
|
||||||
def _get_episode_search_strings(self, season, episode, add_string=''):
|
def _get_episode_search_strings(self, ep_obj, add_string=''):
|
||||||
|
|
||||||
if not episode:
|
if not ep_obj:
|
||||||
return [{}]
|
return [{}]
|
||||||
|
|
||||||
search_params = {'category': 'Episode'}
|
search_params = {'category': 'Episode'}
|
||||||
|
@ -233,20 +233,20 @@ class BTNProvider(generic.TorrentProvider):
|
||||||
search_params['series'] = sanitizeSceneName(self.show.name)
|
search_params['series'] = sanitizeSceneName(self.show.name)
|
||||||
|
|
||||||
if self.show.air_by_date:
|
if self.show.air_by_date:
|
||||||
date_str = str(episode)
|
date_str = str(ep_obj.airdate)
|
||||||
|
|
||||||
# BTN uses dots in dates, we just search for the date since that
|
# BTN uses dots in dates, we just search for the date since that
|
||||||
# combined with the series identifier should result in just one episode
|
# combined with the series identifier should result in just one episode
|
||||||
search_params['name'] = date_str.replace('-', '.')
|
search_params['name'] = date_str.replace('-', '.')
|
||||||
if self.show.sports:
|
if self.show.sports:
|
||||||
date_str = str(episode)
|
date_str = str(ep_obj.airdate)
|
||||||
|
|
||||||
# BTN uses dots in dates, we just search for the date since that
|
# BTN uses dots in dates, we just search for the date since that
|
||||||
# combined with the series identifier should result in just one episode
|
# combined with the series identifier should result in just one episode
|
||||||
search_params['name'] = date_str.replace('-', '.')
|
search_params['name'] = date_str.replace('-', '.')
|
||||||
else:
|
else:
|
||||||
# Do a general name search for the episode, formatted like SXXEYY
|
# Do a general name search for the episode, formatted like SXXEYY
|
||||||
search_params['name'] = "S%02dE%02d" % (season, episode)
|
search_params['name'] = "S%02dE%02d" % (ep_obj.scene_season, ep_obj.scene_episode)
|
||||||
|
|
||||||
to_return = [search_params]
|
to_return = [search_params]
|
||||||
|
|
||||||
|
@ -268,10 +268,10 @@ class BTNProvider(generic.TorrentProvider):
|
||||||
|
|
||||||
return to_return
|
return to_return
|
||||||
|
|
||||||
def _doGeneralSearch(self, search_string, show=None):
|
def _doGeneralSearch(self, search_string):
|
||||||
# 'search' looks as broad is it can find. Can contain episode overview and title for example,
|
# 'search' looks as broad is it can find. Can contain episode overview and title for example,
|
||||||
# use with caution!
|
# use with caution!
|
||||||
return self._doSearch({'search': search_string}, show=show)
|
return self._doSearch({'search': search_string})
|
||||||
|
|
||||||
def findPropers(self, search_date=None):
|
def findPropers(self, search_date=None):
|
||||||
results = []
|
results = []
|
||||||
|
|
|
@ -52,7 +52,7 @@ class DTTProvider(generic.TorrentProvider):
|
||||||
def _dtt_show_id(self, show_name):
|
def _dtt_show_id(self, show_name):
|
||||||
return sanitizeSceneName(show_name).replace('.', '-').lower()
|
return sanitizeSceneName(show_name).replace('.', '-').lower()
|
||||||
|
|
||||||
def _get_season_search_strings(self, season, episode):
|
def _get_season_search_strings(self, ep_obj):
|
||||||
search_string = []
|
search_string = []
|
||||||
|
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
|
@ -61,8 +61,8 @@ class DTTProvider(generic.TorrentProvider):
|
||||||
|
|
||||||
return search_string
|
return search_string
|
||||||
|
|
||||||
def _get_episode_search_strings(self, season, episode, add_string=''):
|
def _get_episode_search_strings(self, ep_obj, add_string=''):
|
||||||
return self._get_season_search_strings(season, episode)
|
return self._get_season_search_strings(ep_obj)
|
||||||
|
|
||||||
def _doSearch(self, search_params, show=None, age=None):
|
def _doSearch(self, search_params, show=None, age=None):
|
||||||
|
|
||||||
|
|
|
@ -70,34 +70,34 @@ class EZRSSProvider(generic.TorrentProvider):
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
|
||||||
def _get_season_search_strings(self, season, episode):
|
def _get_season_search_strings(self, ep_obj):
|
||||||
|
|
||||||
params = {}
|
params = {}
|
||||||
|
|
||||||
params['show_name'] = helpers.sanitizeSceneName(self.show.name, ezrss=True).replace('.', ' ').encode('utf-8')
|
params['show_name'] = helpers.sanitizeSceneName(self.show.name, ezrss=True).replace('.', ' ').encode('utf-8')
|
||||||
|
|
||||||
params['season'] = season
|
params['season'] = ep_obj.scene_season
|
||||||
|
|
||||||
params['episode'] = self._get_episode_search_strings(season, episode)[0]['episode']
|
params['episode'] = self._get_episode_search_strings(ep_obj)[0]['episode']
|
||||||
|
|
||||||
return [params]
|
return [params]
|
||||||
|
|
||||||
def _get_episode_search_strings(self, season, episode, add_string=''):
|
def _get_episode_search_strings(self, ep_obj, add_string=''):
|
||||||
|
|
||||||
params = {}
|
params = {}
|
||||||
|
|
||||||
if not episode:
|
if not ep_obj:
|
||||||
return params
|
return params
|
||||||
|
|
||||||
params['show_name'] = helpers.sanitizeSceneName(self.show.name, ezrss=True).replace('.', ' ').encode('utf-8')
|
params['show_name'] = helpers.sanitizeSceneName(self.show.name, ezrss=True).replace('.', ' ').encode('utf-8')
|
||||||
|
|
||||||
if self.show.air_by_date:
|
if self.show.air_by_date:
|
||||||
params['date'] = str(episode)
|
params['date'] = str(ep_obj.airdate)
|
||||||
if self.show.sports:
|
if self.show.sports:
|
||||||
params['date'] = str(episode)
|
params['date'] = str(ep_obj.airdate)
|
||||||
else:
|
else:
|
||||||
params['season'] = season
|
params['season'] = ep_obj.scene_season
|
||||||
params['episode'] = episode
|
params['episode'] = ep_obj.scene_episode
|
||||||
|
|
||||||
return [params]
|
return [params]
|
||||||
|
|
||||||
|
|
|
@ -149,7 +149,7 @@ class GenericProvider:
|
||||||
|
|
||||||
data = self.getURL(result.url)
|
data = self.getURL(result.url)
|
||||||
|
|
||||||
if data == None:
|
if data is None:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# use the appropriate watch folder
|
# use the appropriate watch folder
|
||||||
|
@ -220,10 +220,10 @@ class GenericProvider:
|
||||||
def _doSearch(self, search_params, show=None, age=None):
|
def _doSearch(self, search_params, show=None, age=None):
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def _get_season_search_strings(self, season, episode):
|
def _get_season_search_strings(self, episode):
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def _get_episode_search_strings(self, season, episode, add_string=''):
|
def _get_episode_search_strings(self, eb_obj, add_string=''):
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def _get_title_and_url(self, item):
|
def _get_title_and_url(self, item):
|
||||||
|
@ -260,10 +260,10 @@ class GenericProvider:
|
||||||
logger.log(u'Searching "%s" for "%s" as "%s"' % (self.name, ep_obj.prettyName(), ep_obj.scene_prettyName()))
|
logger.log(u'Searching "%s" for "%s" as "%s"' % (self.name, ep_obj.prettyName(), ep_obj.scene_prettyName()))
|
||||||
|
|
||||||
if seasonSearch:
|
if seasonSearch:
|
||||||
for curString in self._get_season_search_strings(ep_obj.scene_season, ep_obj.airdate if show.air_by_date else ep_obj.scene_episode):
|
for curString in self._get_season_search_strings(ep_obj):
|
||||||
itemList += self._doSearch(curString)
|
itemList += self._doSearch(curString)
|
||||||
else:
|
else:
|
||||||
for curString in self._get_episode_search_strings(ep_obj.scene_season, ep_obj.airdate if show.air_by_date else ep_obj.scene_episode):
|
for curString in self._get_episode_search_strings(ep_obj):
|
||||||
itemList += self._doSearch(curString)
|
itemList += self._doSearch(curString)
|
||||||
|
|
||||||
for item in itemList:
|
for item in itemList:
|
||||||
|
@ -282,8 +282,8 @@ class GenericProvider:
|
||||||
|
|
||||||
if not show.air_by_date:
|
if not show.air_by_date:
|
||||||
# this check is meaningless for non-season searches
|
# this check is meaningless for non-season searches
|
||||||
if (parse_result.season_number != None and parse_result.season_number != season) or (
|
if (parse_result.season_number is not None and parse_result.season_number != season) or (
|
||||||
parse_result.season_number == None and season != 1):
|
parse_result.season_number is None and season != 1):
|
||||||
logger.log(u"The result " + title + " doesn't seem to be a valid episode for season " + str(
|
logger.log(u"The result " + title + " doesn't seem to be a valid episode for season " + str(
|
||||||
season) + ", ignoring", logger.DEBUG)
|
season) + ", ignoring", logger.DEBUG)
|
||||||
continue
|
continue
|
||||||
|
@ -334,8 +334,7 @@ class GenericProvider:
|
||||||
logger.log(u"Found result " + title + " at " + url, logger.DEBUG)
|
logger.log(u"Found result " + title + " at " + url, logger.DEBUG)
|
||||||
|
|
||||||
# make a result object
|
# make a result object
|
||||||
epObjs = []
|
epObjs = [epObj]
|
||||||
epObjs.append(epObj)
|
|
||||||
|
|
||||||
result = self.getResult(epObjs)
|
result = self.getResult(epObjs)
|
||||||
result.url = url
|
result.url = url
|
||||||
|
|
|
@ -110,40 +110,40 @@ class HDTorrentsProvider(generic.TorrentProvider):
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _get_season_search_strings(self, season, episode):
|
def _get_season_search_strings(self, ep_obj):
|
||||||
|
|
||||||
search_string = {'Season': [], 'Episode': []}
|
search_string = {'Season': [], 'Episode': []}
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = show_name + ' S%02d' % int(season) #1) showName SXX
|
ep_string = show_name + ' S%02d' % int(ep_obj.scene_season) #1) showName SXX
|
||||||
search_string['Season'].append(ep_string)
|
search_string['Season'].append(ep_string)
|
||||||
|
|
||||||
search_string['Episode'] = self._get_episode_search_strings(season, episode)[0]['Episode']
|
search_string['Episode'] = self._get_episode_search_strings(ep_obj)[0]['Episode']
|
||||||
|
|
||||||
return [search_string]
|
return [search_string]
|
||||||
|
|
||||||
def _get_episode_search_strings(self, season, episode, add_string=''):
|
def _get_episode_search_strings(self, ep_obj, add_string=''):
|
||||||
search_string = {'Episode': []}
|
search_string = {'Episode': []}
|
||||||
|
|
||||||
if not episode:
|
if not ep_obj:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
if self.show.air_by_date:
|
if self.show.air_by_date:
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
||||||
str(episode).replace('-', '|') + '|' + \
|
str(ep_obj.airdate).replace('-', '|') + '|' + \
|
||||||
episode.strftime('%b')
|
ep_obj.airdate.strftime('%b')
|
||||||
search_string['Episode'].append(ep_string)
|
search_string['Episode'].append(ep_string)
|
||||||
elif self.show.sports:
|
elif self.show.sports:
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
||||||
str(episode).replace('-', '|') + '|' + \
|
str(ep_obj.airdate).replace('-', '|') + '|' + \
|
||||||
episode.strftime('%b')
|
ep_obj.airdate.strftime('%b')
|
||||||
search_string['Episode'].append(ep_string)
|
search_string['Episode'].append(ep_string)
|
||||||
else:
|
else:
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = show_name_helpers.sanitizeSceneName(show_name) + ' ' + \
|
ep_string = show_name_helpers.sanitizeSceneName(show_name) + ' ' + \
|
||||||
sickbeard.config.naming_ep_type[2] % {'seasonnumber': season,
|
sickbeard.config.naming_ep_type[2] % {'seasonnumber': ep_obj.scene_season,
|
||||||
'episodenumber': episode}
|
'episodenumber': ep_obj.scene_episode}
|
||||||
|
|
||||||
search_string['Episode'].append(re.sub('\s+', ' ', ep_string))
|
search_string['Episode'].append(re.sub('\s+', ' ', ep_string))
|
||||||
|
|
||||||
|
@ -268,7 +268,7 @@ class HDTorrentsProvider(generic.TorrentProvider):
|
||||||
|
|
||||||
return (title, url)
|
return (title, url)
|
||||||
|
|
||||||
def getURL(self, url, post_data=None, headers=None):
|
def getURL(self, url, post_data=None, headers=None, json=False):
|
||||||
|
|
||||||
if not self.session:
|
if not self.session:
|
||||||
self._doLogin()
|
self._doLogin()
|
||||||
|
@ -306,12 +306,12 @@ class HDTorrentsProvider(generic.TorrentProvider):
|
||||||
return []
|
return []
|
||||||
|
|
||||||
for sqlshow in sqlResults:
|
for sqlshow in sqlResults:
|
||||||
self.show = self.show = curshow = helpers.findCertainShow(sickbeard.showList, int(sqlshow["showid"]))
|
self.show = curshow = helpers.findCertainShow(sickbeard.showList, int(sqlshow["showid"]))
|
||||||
curEp = curshow.getEpisode(int(sqlshow["season"]), int(sqlshow["episode"]))
|
curEp = curshow.getEpisode(int(sqlshow["season"]), int(sqlshow["episode"]))
|
||||||
|
|
||||||
searchString = self._get_episode_search_strings(curEp.scene_season, curEp.airdate if curshow.air_by_date else curEp.scene_episode, add_string='PROPER|REPACK')
|
searchString = self._get_episode_search_strings(curEp, add_string='PROPER|REPACK')
|
||||||
|
|
||||||
for item in self._doSearch(searchString[0], show=curshow):
|
for item in self._doSearch(searchString[0]):
|
||||||
title, url = self._get_title_and_url(item)
|
title, url = self._get_title_and_url(item)
|
||||||
results.append(classes.Proper(title, url, datetime.datetime.today()))
|
results.append(classes.Proper(title, url, datetime.datetime.today()))
|
||||||
|
|
||||||
|
|
|
@ -92,41 +92,41 @@ class IPTorrentsProvider(generic.TorrentProvider):
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _get_season_search_strings(self, season, episode):
|
def _get_season_search_strings(self, ep_obj):
|
||||||
|
|
||||||
search_string = {'Season': [], 'Episode': []}
|
search_string = {'Season': [], 'Episode': []}
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = show_name + ' S%02d' % int(season) #1) showName SXX
|
ep_string = show_name + ' S%02d' % int(ep_obj.scene_season) #1) showName SXX
|
||||||
search_string['Season'].append(ep_string)
|
search_string['Season'].append(ep_string)
|
||||||
|
|
||||||
search_string['Episode'] = self._get_episode_search_strings(season, episode)[0]['Episode']
|
search_string['Episode'] = self._get_episode_search_strings(ep_obj)[0]['Episode']
|
||||||
|
|
||||||
return [search_string]
|
return [search_string]
|
||||||
|
|
||||||
def _get_episode_search_strings(self, season, episode, add_string=''):
|
def _get_episode_search_strings(self, ep_obj, add_string=''):
|
||||||
|
|
||||||
search_string = {'Episode': []}
|
search_string = {'Episode': []}
|
||||||
|
|
||||||
if not episode:
|
if not ep_obj:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
if self.show.air_by_date:
|
if self.show.air_by_date:
|
||||||
for show_name in set(allPossibleShowNames(self.show)):
|
for show_name in set(allPossibleShowNames(self.show)):
|
||||||
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
||||||
str(episode).replace('-', '|') + '|' + \
|
str(ep_obj.airdate).replace('-', '|') + '|' + \
|
||||||
episode.strftime('%b')
|
ep_obj.airdate.strftime('%b')
|
||||||
search_string['Episode'].append(ep_string)
|
search_string['Episode'].append(ep_string)
|
||||||
if self.show.sports:
|
elif self.show.sports:
|
||||||
for show_name in set(allPossibleShowNames(self.show)):
|
for show_name in set(allPossibleShowNames(self.show)):
|
||||||
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
||||||
str(episode).replace('-', '|') + '|' + \
|
str(ep_obj.airdate).replace('-', '|') + '|' + \
|
||||||
episode.strftime('%b')
|
ep_obj.airdate.strftime('%b')
|
||||||
search_string['Episode'].append(ep_string)
|
search_string['Episode'].append(ep_string)
|
||||||
else:
|
else:
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = show_name_helpers.sanitizeSceneName(show_name) + ' ' + \
|
ep_string = show_name_helpers.sanitizeSceneName(show_name) + ' ' + \
|
||||||
sickbeard.config.naming_ep_type[2] % {'seasonnumber': season,
|
sickbeard.config.naming_ep_type[2] % {'seasonnumber': ep_obj.scene_season,
|
||||||
'episodenumber': episode} + ' %s' % add_string
|
'episodenumber': ep_obj.scene_episode} + ' %s' % add_string
|
||||||
|
|
||||||
search_string['Episode'].append(re.sub('\s+', ' ', ep_string))
|
search_string['Episode'].append(re.sub('\s+', ' ', ep_string))
|
||||||
|
|
||||||
|
@ -216,7 +216,7 @@ class IPTorrentsProvider(generic.TorrentProvider):
|
||||||
|
|
||||||
return (title, url)
|
return (title, url)
|
||||||
|
|
||||||
def getURL(self, url, post_data=None, headers=None):
|
def getURL(self, url, post_data=None, headers=None, json=False):
|
||||||
|
|
||||||
if not self.session:
|
if not self.session:
|
||||||
self._doLogin()
|
self._doLogin()
|
||||||
|
@ -257,11 +257,9 @@ class IPTorrentsProvider(generic.TorrentProvider):
|
||||||
for sqlshow in sqlResults:
|
for sqlshow in sqlResults:
|
||||||
self.show = curshow = helpers.findCertainShow(sickbeard.showList, int(sqlshow["showid"]))
|
self.show = curshow = helpers.findCertainShow(sickbeard.showList, int(sqlshow["showid"]))
|
||||||
curEp = curshow.getEpisode(int(sqlshow["season"]), int(sqlshow["episode"]))
|
curEp = curshow.getEpisode(int(sqlshow["season"]), int(sqlshow["episode"]))
|
||||||
searchString = self._get_episode_search_strings(curEp.scene_season,
|
searchString = self._get_episode_search_strings(curEp, add_string='PROPER|REPACK')
|
||||||
curEp.airdate if curshow.air_by_date else curEp.scene_episode,
|
|
||||||
add_string='PROPER|REPACK')
|
|
||||||
|
|
||||||
for item in self._doSearch(searchString[0], show=curshow):
|
for item in self._doSearch(searchString[0]):
|
||||||
title, url = self._get_title_and_url(item)
|
title, url = self._get_title_and_url(item)
|
||||||
results.append(classes.Proper(title, url, datetime.datetime.today()))
|
results.append(classes.Proper(title, url, datetime.datetime.today()))
|
||||||
|
|
||||||
|
|
|
@ -139,7 +139,7 @@ class KATProvider(generic.TorrentProvider):
|
||||||
quality = Quality.sceneQuality(os.path.basename(fileName))
|
quality = Quality.sceneQuality(os.path.basename(fileName))
|
||||||
if quality != Quality.UNKNOWN: break
|
if quality != Quality.UNKNOWN: break
|
||||||
|
|
||||||
if fileName != None and quality == Quality.UNKNOWN:
|
if fileName is not None and quality == Quality.UNKNOWN:
|
||||||
quality = Quality.assumeQuality(os.path.basename(fileName))
|
quality = Quality.assumeQuality(os.path.basename(fileName))
|
||||||
|
|
||||||
if quality == Quality.UNKNOWN:
|
if quality == Quality.UNKNOWN:
|
||||||
|
@ -164,43 +164,42 @@ class KATProvider(generic.TorrentProvider):
|
||||||
logger.log(u"Failed parsing " + self.name + " Traceback: " + traceback.format_exc(), logger.ERROR)
|
logger.log(u"Failed parsing " + self.name + " Traceback: " + traceback.format_exc(), logger.ERROR)
|
||||||
|
|
||||||
|
|
||||||
def _get_season_search_strings(self, season, episode):
|
def _get_season_search_strings(self, ep_obj):
|
||||||
search_string = {'Season': [], 'Episode': []}
|
search_string = {'Season': [], 'Episode': []}
|
||||||
|
|
||||||
for show_name in set(allPossibleShowNames(self.show)):
|
for show_name in set(allPossibleShowNames(self.show)):
|
||||||
ep_string = show_name + ' S%02d' % int(season) + ' -S%02d' % int(season) + 'E' + ' category:tv' #1) showName SXX -SXXE
|
ep_string = show_name + ' S%02d' % int(ep_obj.scene_season) + ' -S%02d' % int(ep_obj.scene_season) + 'E' + ' category:tv' #1) showName SXX -SXXE
|
||||||
search_string['Season'].append(ep_string)
|
search_string['Season'].append(ep_string)
|
||||||
|
|
||||||
ep_string = show_name + ' Season ' + str(season) + ' -Ep*' + ' category:tv' #2) showName Season X
|
ep_string = show_name + ' Season ' + str(ep_obj.scene_season) + ' -Ep*' + ' category:tv' #2) showName Season X
|
||||||
search_string['Season'].append(ep_string)
|
search_string['Season'].append(ep_string)
|
||||||
|
|
||||||
search_string['Episode'] = self._get_episode_search_strings(season, episode)[0]['Episode']
|
search_string['Episode'] = self._get_episode_search_strings(ep_obj)[0]['Episode']
|
||||||
|
|
||||||
def _get_episode_search_strings(self, season, episode, add_string=''):
|
def _get_episode_search_strings(self, ep_obj, add_string=''):
|
||||||
search_string = {'Episode': []}
|
search_string = {'Episode': []}
|
||||||
|
|
||||||
if self.show.air_by_date:
|
if self.show.air_by_date:
|
||||||
for show_name in set(allPossibleShowNames(self.show)):
|
for show_name in set(allPossibleShowNames(self.show)):
|
||||||
|
|
||||||
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
||||||
str(episode).replace('-','|') + '|' + \
|
str(ep_obj.airdate).replace('-','|') + '|' + \
|
||||||
episode.strftime('%b')
|
ep_obj.airdate.strftime('%b')
|
||||||
search_string['Episode'].append(ep_string)
|
search_string['Episode'].append(ep_string)
|
||||||
elif self.show.sports:
|
elif self.show.sports:
|
||||||
for show_name in set(allPossibleShowNames(self.show)):
|
for show_name in set(allPossibleShowNames(self.show)):
|
||||||
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
||||||
str(episode).replace('-', '|') + '|' + \
|
str(ep_obj.airdate).replace('-', '|') + '|' + \
|
||||||
episode.strftime('%b')
|
ep_obj.airdate.strftime('%b')
|
||||||
search_string['Episode'].append(ep_string)
|
search_string['Episode'].append(ep_string)
|
||||||
else:
|
else:
|
||||||
for show_name in set(allPossibleShowNames(self.show)):
|
for show_name in set(allPossibleShowNames(self.show)):
|
||||||
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
||||||
sickbeard.config.naming_ep_type[2] % {'seasonnumber': season,
|
sickbeard.config.naming_ep_type[2] % {'seasonnumber': ep_obj.scene_season,
|
||||||
'episodenumber': episode} + '|' + \
|
'episodenumber': ep_obj.scene_episode} + '|' + \
|
||||||
sickbeard.config.naming_ep_type[0] % {'seasonnumber': season,
|
sickbeard.config.naming_ep_type[0] % {'seasonnumber': ep_obj.scene_season,
|
||||||
'episodenumber': episode} + '|' + \
|
'episodenumber': ep_obj.scene_episode} + '|' + \
|
||||||
sickbeard.config.naming_ep_type[3] % {'seasonnumber': season,
|
sickbeard.config.naming_ep_type[3] % {'seasonnumber': ep_obj.scene_season,
|
||||||
'episodenumber': episode} + ' %s category:tv' % add_string
|
'episodenumber': ep_obj.scene_episode} + ' %s category:tv' % add_string
|
||||||
search_string['Episode'].append(re.sub('\s+', ' ', ep_string))
|
search_string['Episode'].append(re.sub('\s+', ' ', ep_string))
|
||||||
|
|
||||||
return [search_string]
|
return [search_string]
|
||||||
|
@ -293,7 +292,7 @@ class KATProvider(generic.TorrentProvider):
|
||||||
|
|
||||||
return (title, url)
|
return (title, url)
|
||||||
|
|
||||||
def getURL(self, url, post_data=None, headers=None):
|
def getURL(self, url, post_data=None, headers=None, json=False):
|
||||||
|
|
||||||
if not self.session:
|
if not self.session:
|
||||||
self.session = requests.Session()
|
self.session = requests.Session()
|
||||||
|
@ -383,9 +382,9 @@ class KATProvider(generic.TorrentProvider):
|
||||||
self.show = curshow = helpers.findCertainShow(sickbeard.showList, int(sqlshow["showid"]))
|
self.show = curshow = helpers.findCertainShow(sickbeard.showList, int(sqlshow["showid"]))
|
||||||
curEp = curshow.getEpisode(int(sqlshow["season"]), int(sqlshow["episode"]))
|
curEp = curshow.getEpisode(int(sqlshow["season"]), int(sqlshow["episode"]))
|
||||||
|
|
||||||
searchString = self._get_episode_search_strings(curEp.scene_season, curEp.airdate if curshow.air_by_date else curEp.scene_episode, add_string='PROPER|REPACK')
|
searchString = self._get_episode_search_strings(curEp, add_string='PROPER|REPACK')
|
||||||
|
|
||||||
for item in self._doSearch(searchString[0], show=curshow):
|
for item in self._doSearch(searchString[0]):
|
||||||
title, url = self._get_title_and_url(item)
|
title, url = self._get_title_and_url(item)
|
||||||
results.append(classes.Proper(title, url, datetime.datetime.today()))
|
results.append(classes.Proper(title, url, datetime.datetime.today()))
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,9 @@ class NewzbinDownloader(urllib.FancyURLopener):
|
||||||
if newzbinErrCode == 450:
|
if newzbinErrCode == 450:
|
||||||
rtext = str(headers.getheader('X-DNZB-RText'))
|
rtext = str(headers.getheader('X-DNZB-RText'))
|
||||||
result = re.search("wait (\d+) seconds", rtext)
|
result = re.search("wait (\d+) seconds", rtext)
|
||||||
|
logger.log("Newzbin throttled our NZB downloading, pausing for " + result.group(1) + "seconds")
|
||||||
|
time.sleep(int(result.group(1)))
|
||||||
|
raise exceptions.NewzbinAPIThrottled()
|
||||||
|
|
||||||
elif newzbinErrCode == 401:
|
elif newzbinErrCode == 401:
|
||||||
raise exceptions.AuthException("Newzbin username or password incorrect")
|
raise exceptions.AuthException("Newzbin username or password incorrect")
|
||||||
|
@ -57,13 +60,6 @@ class NewzbinDownloader(urllib.FancyURLopener):
|
||||||
elif newzbinErrCode == 402:
|
elif newzbinErrCode == 402:
|
||||||
raise exceptions.AuthException("Newzbin account not premium status, can't download NZBs")
|
raise exceptions.AuthException("Newzbin account not premium status, can't download NZBs")
|
||||||
|
|
||||||
logger.log("Newzbin throttled our NZB downloading, pausing for " + result.group(1) + "seconds")
|
|
||||||
|
|
||||||
time.sleep(int(result.group(1)))
|
|
||||||
|
|
||||||
raise exceptions.NewzbinAPIThrottled()
|
|
||||||
|
|
||||||
|
|
||||||
class NewzbinProvider(generic.NZBProvider):
|
class NewzbinProvider(generic.NZBProvider):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
||||||
|
@ -232,7 +228,7 @@ class NewzbinProvider(generic.NZBProvider):
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def getURL(self, url):
|
def getURL(self, url, post_data=None, headers=None, json=False):
|
||||||
|
|
||||||
myOpener = classes.AuthURLOpener(sickbeard.NEWZBIN_USERNAME, sickbeard.NEWZBIN_PASSWORD)
|
myOpener = classes.AuthURLOpener(sickbeard.NEWZBIN_USERNAME, sickbeard.NEWZBIN_PASSWORD)
|
||||||
try:
|
try:
|
||||||
|
@ -251,11 +247,11 @@ class NewzbinProvider(generic.NZBProvider):
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def _get_season_search_strings(self, season, episode):
|
def _get_season_search_strings(self, ep_obj):
|
||||||
return ['^' + x for x in show_name_helpers.makeSceneSeasonSearchString(self.show, season, episode)]
|
return ['^' + x for x in show_name_helpers.makeSceneSeasonSearchString(self.show, ep_obj)]
|
||||||
|
|
||||||
def _get_episode_search_strings(self, season, episode, add_string=''):
|
def _get_episode_search_strings(self, ep_obj, add_string=''):
|
||||||
return ['^' + x for x in show_name_helpers.makeSceneSearchString(self.show, season, episode)]
|
return ['^' + x for x in show_name_helpers.makeSceneSearchString(self.show, ep_obj)]
|
||||||
|
|
||||||
def _doSearch(self, searchStr, show=None, age=None):
|
def _doSearch(self, searchStr, show=None, age=None):
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,7 @@ class NewznabProvider(generic.NZBProvider):
|
||||||
def isEnabled(self):
|
def isEnabled(self):
|
||||||
return self.enabled
|
return self.enabled
|
||||||
|
|
||||||
def _get_season_search_strings(self, season, episode):
|
def _get_season_search_strings(self, ep_obj):
|
||||||
|
|
||||||
to_return = []
|
to_return = []
|
||||||
|
|
||||||
|
@ -94,36 +94,35 @@ class NewznabProvider(generic.NZBProvider):
|
||||||
cur_params['q'] = helpers.sanitizeSceneName(cur_exception)
|
cur_params['q'] = helpers.sanitizeSceneName(cur_exception)
|
||||||
|
|
||||||
# season
|
# season
|
||||||
cur_params['season'] = str(season)
|
cur_params['season'] = str(ep_obj.scene_season)
|
||||||
|
|
||||||
# episode
|
# episode
|
||||||
cur_params['episode'] = self._get_episode_search_strings(season, episode)[0]['ep']
|
cur_params['episode'] = self._get_episode_search_strings(ep_obj)[0]['ep']
|
||||||
|
|
||||||
to_return.append(cur_params)
|
to_return.append(cur_params)
|
||||||
|
|
||||||
return to_return
|
return to_return
|
||||||
|
|
||||||
def _get_episode_search_strings(self, season, episode, add_string=''):
|
def _get_episode_search_strings(self, ep_obj, add_string=''):
|
||||||
|
|
||||||
params = {}
|
params = {}
|
||||||
|
|
||||||
if not episode:
|
if not ep_obj:
|
||||||
return [params]
|
return [params]
|
||||||
|
|
||||||
# search
|
# search
|
||||||
params['q'] = helpers.sanitizeSceneName(self.show.name)
|
params['q'] = helpers.sanitizeSceneName(self.show.name)
|
||||||
|
|
||||||
|
date_str = str(ep_obj.airdate)
|
||||||
if self.show.air_by_date:
|
if self.show.air_by_date:
|
||||||
date_str = str(episode)
|
|
||||||
|
|
||||||
params['season'] = date_str.partition('-')[0]
|
params['season'] = date_str.partition('-')[0]
|
||||||
params['ep'] = date_str.partition('-')[2].replace('-', '/')
|
params['ep'] = date_str.partition('-')[2].replace('-', '/')
|
||||||
# elif self.show.sports:
|
elif self.show.sports:
|
||||||
# params['season']
|
params['season'] = date_str.partition('-')[0]
|
||||||
# params['ep']
|
params['ep'] = date_str.partition('-')[0]
|
||||||
else:
|
else:
|
||||||
params['season'] = season
|
params['season'] = ep_obj.scene_season
|
||||||
params['ep'] = episode
|
params['ep'] = ep_obj.scene_episode
|
||||||
|
|
||||||
to_return = [params]
|
to_return = [params]
|
||||||
|
|
||||||
|
@ -144,8 +143,8 @@ class NewznabProvider(generic.NZBProvider):
|
||||||
|
|
||||||
return to_return
|
return to_return
|
||||||
|
|
||||||
def _doGeneralSearch(self, search_string, show=None):
|
def _doGeneralSearch(self, search_string):
|
||||||
return self._doSearch({'q': search_string}, show=show)
|
return self._doSearch({'q': search_string})
|
||||||
|
|
||||||
def _checkAuth(self):
|
def _checkAuth(self):
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,7 @@ class NextGenProvider(generic.TorrentProvider):
|
||||||
if self.login_opener and self.last_login_check < (now - 3600):
|
if self.login_opener and self.last_login_check < (now - 3600):
|
||||||
try:
|
try:
|
||||||
output = self.login_opener.open(self.urls['test'])
|
output = self.login_opener.open(self.urls['test'])
|
||||||
if self.loginCheckSuccess(output):
|
if self.loginSuccess(output):
|
||||||
self.last_login_check = now
|
self.last_login_check = now
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
|
@ -131,41 +131,41 @@ class NextGenProvider(generic.TorrentProvider):
|
||||||
logger.log(u'Failed to login:' + str(error), logger.ERROR)
|
logger.log(u'Failed to login:' + str(error), logger.ERROR)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def _get_season_search_strings(self, season, episode):
|
def _get_season_search_strings(self, ep_obj):
|
||||||
|
|
||||||
search_string = {'Season': [], 'Episode': []}
|
search_string = {'Season': [], 'Episode': []}
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = show_name + ' S%02d' % int(season) #1) showName SXX
|
ep_string = show_name + ' S%02d' % int(ep_obj.scene_season) #1) showName SXX
|
||||||
search_string['Season'].append(ep_string)
|
search_string['Season'].append(ep_string)
|
||||||
|
|
||||||
search_string['Episode'] = self._get_episode_search_strings(season, episode)[0]['Episode']
|
search_string['Episode'] = self._get_episode_search_strings(ep_obj)[0]['Episode']
|
||||||
|
|
||||||
return [search_string]
|
return [search_string]
|
||||||
|
|
||||||
def _get_episode_search_strings(self, season, episode, add_string=''):
|
def _get_episode_search_strings(self, ep_obj, add_string=''):
|
||||||
|
|
||||||
search_string = {'Episode': []}
|
search_string = {'Episode': []}
|
||||||
|
|
||||||
if not episode:
|
if not ep_obj:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
if self.show.air_by_date:
|
if self.show.air_by_date:
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
||||||
str(episode).replace('-', '|') + '|' + \
|
str(ep_obj.airdate).replace('-', '|') + '|' + \
|
||||||
episode.strftime('%b')
|
ep_obj.airdate.strftime('%b')
|
||||||
search_string['Episode'].append(ep_string)
|
search_string['Episode'].append(ep_string)
|
||||||
elif self.show.sports:
|
elif self.show.sports:
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
||||||
str(episode).replace('-', '|') + '|' + \
|
str(ep_obj.airdate).replace('-', '|') + '|' + \
|
||||||
episode.strftime('%b')
|
ep_obj.airdate.strftime('%b')
|
||||||
search_string['Episode'].append(ep_string)
|
search_string['Episode'].append(ep_string)
|
||||||
else:
|
else:
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = show_name_helpers.sanitizeSceneName(show_name) + ' ' + \
|
ep_string = show_name_helpers.sanitizeSceneName(show_name) + ' ' + \
|
||||||
sickbeard.config.naming_ep_type[2] % {'seasonnumber': season,
|
sickbeard.config.naming_ep_type[2] % {'seasonnumber': ep_obj.scene_season,
|
||||||
'episodenumber': episode}
|
'episodenumber': ep_obj.scene_episode}
|
||||||
|
|
||||||
search_string['Episode'].append(re.sub('\s+', ' ', ep_string))
|
search_string['Episode'].append(re.sub('\s+', ' ', ep_string))
|
||||||
|
|
||||||
|
@ -262,7 +262,7 @@ class NextGenProvider(generic.TorrentProvider):
|
||||||
|
|
||||||
return title, url
|
return title, url
|
||||||
|
|
||||||
def getURL(self, url, post_data=None, headers=None):
|
def getURL(self, url, post_data=None, headers=None, json=False):
|
||||||
|
|
||||||
if not self.session:
|
if not self.session:
|
||||||
self._doLogin()
|
self._doLogin()
|
||||||
|
@ -305,9 +305,9 @@ class NextGenProvider(generic.TorrentProvider):
|
||||||
for sqlshow in sqlResults:
|
for sqlshow in sqlResults:
|
||||||
self.show = curshow = helpers.findCertainShow(sickbeard.showList, int(sqlshow["showid"]))
|
self.show = curshow = helpers.findCertainShow(sickbeard.showList, int(sqlshow["showid"]))
|
||||||
curEp = curshow.getEpisode(int(sqlshow["season"]), int(sqlshow["episode"]))
|
curEp = curshow.getEpisode(int(sqlshow["season"]), int(sqlshow["episode"]))
|
||||||
searchString = self._get_episode_search_strings(curEp.scene_season, curEp.airdate if curshow.air_by_date else curEp.scene_episode, add_string='PROPER|REPACK')
|
searchString = self._get_episode_search_strings(curEp, add_string='PROPER|REPACK')
|
||||||
|
|
||||||
for item in self._doSearch(searchString[0], show=curshow):
|
for item in self._doSearch(searchString[0]):
|
||||||
title, url = self._get_title_and_url(item)
|
title, url = self._get_title_and_url(item)
|
||||||
results.append(classes.Proper(title, url, datetime.datetime.today()))
|
results.append(classes.Proper(title, url, datetime.datetime.today()))
|
||||||
|
|
||||||
|
|
|
@ -58,13 +58,13 @@ class NyaaProvider(generic.TorrentProvider):
|
||||||
results = generic.TorrentProvider.getSearchResults(self, show, season, ep_objs, seasonSearch, manualSearch)
|
results = generic.TorrentProvider.getSearchResults(self, show, season, ep_objs, seasonSearch, manualSearch)
|
||||||
return results
|
return results
|
||||||
|
|
||||||
def _get_season_search_strings(self, season, episode):
|
def _get_season_search_strings(self, ep_obj):
|
||||||
names = []
|
names = []
|
||||||
names.extend(show_name_helpers.makeSceneshowSearchStrings(self.show))
|
names.extend(show_name_helpers.makeSceneshowSearchStrings(self.show))
|
||||||
return names
|
return names
|
||||||
|
|
||||||
def _get_episode_search_strings(self, season, episode, add_string=''):
|
def _get_episode_search_strings(self, ep_obj, add_string=''):
|
||||||
return self._get_season_search_strings(season, episode)
|
return self._get_season_search_strings(ep_obj)
|
||||||
|
|
||||||
def _doSearch(self, search_string, show=None, age=None):
|
def _doSearch(self, search_string, show=None, age=None):
|
||||||
|
|
||||||
|
|
|
@ -53,11 +53,11 @@ class NZBsProvider(generic.NZBProvider):
|
||||||
if sickbeard.NZBS_UID in (None, "") or sickbeard.NZBS_HASH in (None, ""):
|
if sickbeard.NZBS_UID in (None, "") or sickbeard.NZBS_HASH in (None, ""):
|
||||||
raise exceptions.AuthException("NZBs.org authentication details are empty, check your config")
|
raise exceptions.AuthException("NZBs.org authentication details are empty, check your config")
|
||||||
|
|
||||||
def _get_season_search_strings(self, season, episode):
|
def _get_season_search_strings(self, ep_obj):
|
||||||
return ['^' + x for x in show_name_helpers.makeSceneSeasonSearchString(self.show, season, episode)]
|
return ['^' + x for x in show_name_helpers.makeSceneSeasonSearchString(self.show, ep_obj)]
|
||||||
|
|
||||||
def _get_episode_search_strings(self, season, episode, add_string=''):
|
def _get_episode_search_strings(self, ep_obj, add_string=''):
|
||||||
return ['^' + x for x in show_name_helpers.makeSceneSearchString(self.show, season, episode)]
|
return ['^' + x for x in show_name_helpers.makeSceneSearchString(self.show, ep_obj)]
|
||||||
|
|
||||||
def _doSearch(self, curString, show=None, age=None):
|
def _doSearch(self, curString, show=None, age=None):
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ class NZBsProvider(generic.NZBProvider):
|
||||||
# Pause to avoid 503's
|
# Pause to avoid 503's
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
|
|
||||||
if data == None:
|
if data is None:
|
||||||
logger.log(u"Error trying to load NZBs.org RSS feed: " + searchURL, logger.ERROR)
|
logger.log(u"Error trying to load NZBs.org RSS feed: " + searchURL, logger.ERROR)
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ class NZBsProvider(generic.NZBProvider):
|
||||||
|
|
||||||
resultDate = datetime.datetime.strptime(match.group(1), "%a, %d %b %Y %H:%M:%S")
|
resultDate = datetime.datetime.strptime(match.group(1), "%a, %d %b %Y %H:%M:%S")
|
||||||
|
|
||||||
if date == None or resultDate > date:
|
if date is None or resultDate > date:
|
||||||
results.append(classes.Proper(title, url, resultDate))
|
results.append(classes.Proper(title, url, resultDate))
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
|
|
@ -42,11 +42,11 @@ class NZBsRUSProvider(generic.NZBProvider):
|
||||||
if sickbeard.NZBSRUS_UID in (None, "") or sickbeard.NZBSRUS_HASH in (None, ""):
|
if sickbeard.NZBSRUS_UID in (None, "") or sickbeard.NZBSRUS_HASH in (None, ""):
|
||||||
raise exceptions.AuthException("NZBs'R'US authentication details are empty, check your config")
|
raise exceptions.AuthException("NZBs'R'US authentication details are empty, check your config")
|
||||||
|
|
||||||
def _get_season_search_strings(self, season, episode):
|
def _get_season_search_strings(self, ep_obj):
|
||||||
return ['^' + x for x in show_name_helpers.makeSceneSeasonSearchString(self.show, season, episode)]
|
return ['^' + x for x in show_name_helpers.makeSceneSeasonSearchString(self.show, ep_obj)]
|
||||||
|
|
||||||
def _get_episode_search_strings(self, season, episode, add_string=''):
|
def _get_episode_search_strings(self, ep_obj, add_string=''):
|
||||||
return ['^' + x for x in show_name_helpers.makeSceneSearchString(self.show, season, episode)]
|
return ['^' + x for x in show_name_helpers.makeSceneSearchString(self.show, ep_obj)]
|
||||||
|
|
||||||
def _doSearch(self, search, show=None, age=None):
|
def _doSearch(self, search, show=None, age=None):
|
||||||
params = {'uid': sickbeard.NZBSRUS_UID,
|
params = {'uid': sickbeard.NZBSRUS_UID,
|
||||||
|
|
|
@ -85,11 +85,11 @@ class OmgwtfnzbsProvider(generic.NZBProvider):
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _get_season_search_strings(self, season, episode):
|
def _get_season_search_strings(self, ep_obj):
|
||||||
return [x for x in show_name_helpers.makeSceneSeasonSearchString(self.show, season, episode)]
|
return [x for x in show_name_helpers.makeSceneSeasonSearchString(self.show, ep_obj)]
|
||||||
|
|
||||||
def _get_episode_search_strings(self, season, episode, add_string=''):
|
def _get_episode_search_strings(self, ep_obj, add_string=''):
|
||||||
return [x for x in show_name_helpers.makeSceneSearchString(self.show, season, episode)]
|
return [x for x in show_name_helpers.makeSceneSearchString(self.show, ep_obj)]
|
||||||
|
|
||||||
def _get_title_and_url(self, item):
|
def _get_title_and_url(self, item):
|
||||||
return (item['release'], item['getnzb'])
|
return (item['release'], item['getnzb'])
|
||||||
|
|
|
@ -72,44 +72,44 @@ class PublicHDProvider(generic.TorrentProvider):
|
||||||
quality = Quality.sceneQuality(item[0])
|
quality = Quality.sceneQuality(item[0])
|
||||||
return quality
|
return quality
|
||||||
|
|
||||||
def _get_season_search_strings(self, season, episode):
|
def _get_season_search_strings(self, ep_obj):
|
||||||
|
|
||||||
search_string = {'Season': [], 'Episode': []}
|
search_string = {'Season': [], 'Episode': []}
|
||||||
for show_name in set(allPossibleShowNames(self.show)):
|
for show_name in set(allPossibleShowNames(self.show)):
|
||||||
ep_string = show_name + ' S%02d' % int(season) #1) showName SXX -SXXE
|
ep_string = show_name + ' S%02d' % int(ep_obj.scene_season) #1) showName SXX -SXXE
|
||||||
search_string['Season'].append(ep_string)
|
search_string['Season'].append(ep_string)
|
||||||
|
|
||||||
ep_string = show_name + ' Season ' + str(season) #2) showName Season X
|
ep_string = show_name + ' Season ' + str(ep_obj.scene_season) #2) showName Season X
|
||||||
search_string['Season'].append(ep_string)
|
search_string['Season'].append(ep_string)
|
||||||
|
|
||||||
search_string['Episode'] = self._get_episode_search_strings(season, episode)[0]['Episode']
|
search_string['Episode'] = self._get_episode_search_strings(ep_obj)[0]['Episode']
|
||||||
|
|
||||||
return [search_string]
|
return [search_string]
|
||||||
|
|
||||||
def _get_episode_search_strings(self, season, episode, add_string=''):
|
def _get_episode_search_strings(self, ep_obj, add_string=''):
|
||||||
|
|
||||||
search_string = {'Episode': []}
|
search_string = {'Episode': []}
|
||||||
|
|
||||||
if not episode:
|
if not ep_obj:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
if self.show.air_by_date:
|
if self.show.air_by_date:
|
||||||
for show_name in set(allPossibleShowNames(self.show)):
|
for show_name in set(allPossibleShowNames(self.show)):
|
||||||
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
||||||
str(episode).replace('-', '|') + '|' + \
|
str(ep_obj.airdate).replace('-', '|') + '|' + \
|
||||||
episode.strftime('%b')
|
ep_obj.airdate.strftime('%b')
|
||||||
search_string['Episode'].append(ep_string)
|
search_string['Episode'].append(ep_string)
|
||||||
elif self.show.sports:
|
elif self.show.sports:
|
||||||
for show_name in set(allPossibleShowNames(self.show)):
|
for show_name in set(allPossibleShowNames(self.show)):
|
||||||
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
||||||
str(episode).replace('-', '|') + '|' + \
|
str(ep_obj.airdate).replace('-', '|') + '|' + \
|
||||||
episode.strftime('%b')
|
ep_obj.airdate.strftime('%b')
|
||||||
search_string['Episode'].append(ep_string)
|
search_string['Episode'].append(ep_string)
|
||||||
else:
|
else:
|
||||||
for show_name in set(allPossibleShowNames(self.show)):
|
for show_name in set(allPossibleShowNames(self.show)):
|
||||||
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
||||||
sickbeard.config.naming_ep_type[2] % {'seasonnumber': season,
|
sickbeard.config.naming_ep_type[2] % {'seasonnumber': ep_obj.scene_season,
|
||||||
'episodenumber': episode}
|
'episodenumber': ep_obj.scene_episode}
|
||||||
|
|
||||||
for x in add_string.split('|'):
|
for x in add_string.split('|'):
|
||||||
to_search = re.sub('\s+', ' ', ep_string + ' %s' % x)
|
to_search = re.sub('\s+', ' ', ep_string + ' %s' % x)
|
||||||
|
@ -197,7 +197,7 @@ class PublicHDProvider(generic.TorrentProvider):
|
||||||
|
|
||||||
return (title, url)
|
return (title, url)
|
||||||
|
|
||||||
def getURL(self, url, post_data=None, headers=None):
|
def getURL(self, url, post_data=None, headers=None, json=False):
|
||||||
|
|
||||||
if not self.session:
|
if not self.session:
|
||||||
self.session = requests.Session()
|
self.session = requests.Session()
|
||||||
|
@ -278,9 +278,9 @@ class PublicHDProvider(generic.TorrentProvider):
|
||||||
self.show = curshow = helpers.findCertainShow(sickbeard.showList, int(sqlshow["showid"]))
|
self.show = curshow = helpers.findCertainShow(sickbeard.showList, int(sqlshow["showid"]))
|
||||||
curEp = curshow.getEpisode(int(sqlshow["season"]), int(sqlshow["episode"]))
|
curEp = curshow.getEpisode(int(sqlshow["season"]), int(sqlshow["episode"]))
|
||||||
|
|
||||||
searchString = self._get_episode_search_strings(curEp.scene_season, curEp.airdate if curshow.air_by_date else curEp.scene_episode, add_string='PROPER|REPACK')
|
searchString = self._get_episode_search_strings(curEp, add_string='PROPER|REPACK')
|
||||||
|
|
||||||
for item in self._doSearch(searchString[0], show=curshow):
|
for item in self._doSearch(searchString[0]):
|
||||||
title, url = self._get_title_and_url(item)
|
title, url = self._get_title_and_url(item)
|
||||||
results.append(classes.Proper(title, url, datetime.datetime.today()))
|
results.append(classes.Proper(title, url, datetime.datetime.today()))
|
||||||
|
|
||||||
|
|
|
@ -112,7 +112,7 @@ class TorrentRssProvider(generic.TorrentProvider):
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
return (False, 'Error when trying to load RSS: ' + ex(e))
|
return (False, 'Error when trying to load RSS: ' + ex(e))
|
||||||
|
|
||||||
def getURL(self, url, post_data=None, headers=None):
|
def getURL(self, url, post_data=None, headers=None, json=False):
|
||||||
|
|
||||||
if not self.session:
|
if not self.session:
|
||||||
self.session = requests.Session()
|
self.session = requests.Session()
|
||||||
|
|
|
@ -99,41 +99,41 @@ class SCCProvider(generic.TorrentProvider):
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _get_season_search_strings(self, season, episode):
|
def _get_season_search_strings(self, ep_obj):
|
||||||
|
|
||||||
search_string = {'Season': [], 'Episode': []}
|
search_string = {'Season': [], 'Episode': []}
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = show_name + ' S%02d' % int(season) #1) showName SXX
|
ep_string = show_name + ' S%02d' % int(ep_obj.scene_season) #1) showName SXX
|
||||||
search_string['Season'].append(ep_string)
|
search_string['Season'].append(ep_string)
|
||||||
|
|
||||||
search_string['Episode'] = self._get_episode_search_strings(season, episode)[0]['Episode']
|
search_string['Episode'] = self._get_episode_search_strings(ep_obj)[0]['Episode']
|
||||||
|
|
||||||
return [search_string]
|
return [search_string]
|
||||||
|
|
||||||
def _get_episode_search_strings(self, season, episode, add_string=''):
|
def _get_episode_search_strings(self, ep_obj, add_string=''):
|
||||||
|
|
||||||
search_string = {'Episode': []}
|
search_string = {'Episode': []}
|
||||||
|
|
||||||
if not episode:
|
if not ep_obj:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
if self.show.air_by_date:
|
if self.show.air_by_date:
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
||||||
str(episode).replace('-', '|') + '|' + \
|
str(ep_obj.airdate).replace('-', '|') + '|' + \
|
||||||
episode.strftime('%b')
|
ep_obj.airdate.strftime('%b')
|
||||||
search_string['Episode'].append(ep_string)
|
search_string['Episode'].append(ep_string)
|
||||||
elif self.show.sports:
|
elif self.show.sports:
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
||||||
str(episode).replace('-', '|') + '|' + \
|
str(ep_obj.airdate).replace('-', '|') + '|' + \
|
||||||
episode.strftime('%b')
|
ep_obj.airdate.strftime('%b')
|
||||||
search_string['Episode'].append(ep_string)
|
search_string['Episode'].append(ep_string)
|
||||||
else:
|
else:
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = show_name_helpers.sanitizeSceneName(show_name) + ' ' + \
|
ep_string = show_name_helpers.sanitizeSceneName(show_name) + ' ' + \
|
||||||
sickbeard.config.naming_ep_type[2] % {'seasonnumber': season,
|
sickbeard.config.naming_ep_type[2] % {'seasonnumber': ep_obj.scene_season,
|
||||||
'episodenumber': episode}
|
'episodenumber': ep_obj.scene_episode}
|
||||||
|
|
||||||
search_string['Episode'].append(re.sub('\s+', ' ', ep_string))
|
search_string['Episode'].append(re.sub('\s+', ' ', ep_string))
|
||||||
|
|
||||||
|
@ -239,7 +239,7 @@ class SCCProvider(generic.TorrentProvider):
|
||||||
|
|
||||||
return (title, url)
|
return (title, url)
|
||||||
|
|
||||||
def getURL(self, url, post_data=None, headers=None):
|
def getURL(self, url, post_data=None, headers=None, json=False):
|
||||||
|
|
||||||
if not self.session:
|
if not self.session:
|
||||||
self._doLogin()
|
self._doLogin()
|
||||||
|
@ -283,9 +283,9 @@ class SCCProvider(generic.TorrentProvider):
|
||||||
self.show = curshow = helpers.findCertainShow(sickbeard.showList, int(sqlshow["showid"]))
|
self.show = curshow = helpers.findCertainShow(sickbeard.showList, int(sqlshow["showid"]))
|
||||||
curEp = curshow.getEpisode(int(sqlshow["season"]), int(sqlshow["episode"]))
|
curEp = curshow.getEpisode(int(sqlshow["season"]), int(sqlshow["episode"]))
|
||||||
|
|
||||||
searchString = self._get_episode_search_strings(curEp.scene_season, curEp.airdate if curshow.air_by_date else curEp.scene_episode, add_string='PROPER|REPACK')
|
searchString = self._get_episode_search_strings(curEp, add_string='PROPER|REPACK')
|
||||||
|
|
||||||
for item in self._doSearch(searchString[0], show=curshow):
|
for item in self._doSearch(searchString[0]):
|
||||||
title, url = self._get_title_and_url(item)
|
title, url = self._get_title_and_url(item)
|
||||||
results.append(classes.Proper(title, url, datetime.datetime.today()))
|
results.append(classes.Proper(title, url, datetime.datetime.today()))
|
||||||
|
|
||||||
|
|
|
@ -90,42 +90,42 @@ class SpeedCDProvider(generic.TorrentProvider):
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _get_season_search_strings(self, season, episode):
|
def _get_season_search_strings(self, ep_obj):
|
||||||
|
|
||||||
#If Every episode in Season is a wanted Episode then search for Season first
|
#If Every episode in Season is a wanted Episode then search for Season first
|
||||||
search_string = {'Season': [], 'Episode': []}
|
search_string = {'Season': [], 'Episode': []}
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = show_name +' S%02d' % int(season) #1) showName SXX
|
ep_string = show_name +' S%02d' % int(ep_obj.scene_season) #1) showName SXX
|
||||||
search_string['Season'].append(ep_string)
|
search_string['Season'].append(ep_string)
|
||||||
|
|
||||||
#Building the search string with the episodes we need
|
#Building the search string with the episodes we need
|
||||||
search_string['Episode'] = self._get_episode_search_strings(season, episode)[0]['Episode']
|
search_string['Episode'] = self._get_episode_search_strings(ep_obj)[0]['Episode']
|
||||||
|
|
||||||
return [search_string]
|
return [search_string]
|
||||||
|
|
||||||
def _get_episode_search_strings(self, season, episode, add_string=''):
|
def _get_episode_search_strings(self, ep_obj, add_string=''):
|
||||||
|
|
||||||
search_string = {'Episode': []}
|
search_string = {'Episode': []}
|
||||||
|
|
||||||
if not episode:
|
if not ep_obj:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
if self.show.air_by_date:
|
if self.show.air_by_date:
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
||||||
str(episode).replace('-', '|') + '|' + \
|
str(ep_obj.airdate).replace('-', '|') + '|' + \
|
||||||
episode.strftime('%b')
|
ep_obj.airdate.strftime('%b')
|
||||||
search_string['Episode'].append(ep_string)
|
search_string['Episode'].append(ep_string)
|
||||||
elif self.show.sports:
|
elif self.show.sports:
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
||||||
str(episode).replace('-', '|') + '|' + \
|
str(ep_obj.airdate).replace('-', '|') + '|' + \
|
||||||
episode.strftime('%b')
|
ep_obj.airdate.strftime('%b')
|
||||||
search_string['Episode'].append(ep_string)
|
search_string['Episode'].append(ep_string)
|
||||||
else:
|
else:
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = show_name_helpers.sanitizeSceneName(show_name) +' '+ \
|
ep_string = show_name_helpers.sanitizeSceneName(show_name) +' '+ \
|
||||||
sickbeard.config.naming_ep_type[2] % {'seasonnumber': season, 'episodenumber': episode}
|
sickbeard.config.naming_ep_type[2] % {'seasonnumber': ep_obj.scene_season, 'episodenumber': ep_obj.scene_episode}
|
||||||
|
|
||||||
search_string['Episode'].append(re.sub('\s+', ' ', ep_string))
|
search_string['Episode'].append(re.sub('\s+', ' ', ep_string))
|
||||||
|
|
||||||
|
@ -190,7 +190,7 @@ class SpeedCDProvider(generic.TorrentProvider):
|
||||||
|
|
||||||
return (title, url)
|
return (title, url)
|
||||||
|
|
||||||
def getURL(self, url, post_data=None, headers=None):
|
def getURL(self, url, post_data=None, headers=None, json=False):
|
||||||
if not self.session:
|
if not self.session:
|
||||||
self._doLogin()
|
self._doLogin()
|
||||||
|
|
||||||
|
@ -236,9 +236,9 @@ class SpeedCDProvider(generic.TorrentProvider):
|
||||||
self.show = curshow = helpers.findCertainShow(sickbeard.showList, int(sqlshow["showid"]))
|
self.show = curshow = helpers.findCertainShow(sickbeard.showList, int(sqlshow["showid"]))
|
||||||
curEp = curshow.getEpisode(int(sqlshow["season"]), int(sqlshow["episode"]))
|
curEp = curshow.getEpisode(int(sqlshow["season"]), int(sqlshow["episode"]))
|
||||||
|
|
||||||
searchString = self._get_episode_search_strings(curEp.scene_season, curEp.airdate if curshow.air_by_date else curEp.scene_episode, add_string='PROPER|REPACK')
|
searchString = self._get_episode_search_strings(curEp, add_string='PROPER|REPACK')
|
||||||
|
|
||||||
for item in self._doSearch(searchString[0], show=curshow):
|
for item in self._doSearch(searchString[0]):
|
||||||
title, url = self._get_title_and_url(item)
|
title, url = self._get_title_and_url(item)
|
||||||
results.append(classes.Proper(title, url, datetime.datetime.today()))
|
results.append(classes.Proper(title, url, datetime.datetime.today()))
|
||||||
|
|
||||||
|
|
|
@ -148,7 +148,7 @@ class ThePirateBayProvider(generic.TorrentProvider):
|
||||||
quality = Quality.sceneQuality(os.path.basename(fileName))
|
quality = Quality.sceneQuality(os.path.basename(fileName))
|
||||||
if quality != Quality.UNKNOWN: break
|
if quality != Quality.UNKNOWN: break
|
||||||
|
|
||||||
if fileName != None and quality == Quality.UNKNOWN:
|
if fileName is not None and quality == Quality.UNKNOWN:
|
||||||
quality = Quality.assumeQuality(os.path.basename(fileName))
|
quality = Quality.assumeQuality(os.path.basename(fileName))
|
||||||
|
|
||||||
if quality == Quality.UNKNOWN:
|
if quality == Quality.UNKNOWN:
|
||||||
|
@ -169,45 +169,45 @@ class ThePirateBayProvider(generic.TorrentProvider):
|
||||||
|
|
||||||
return title
|
return title
|
||||||
|
|
||||||
def _get_season_search_strings(self, season, episode):
|
def _get_season_search_strings(self, ep_obj):
|
||||||
|
|
||||||
search_string = {'Season': [], 'Episode': []}
|
search_string = {'Season': [], 'Episode': []}
|
||||||
for show_name in set(allPossibleShowNames(self.show)):
|
for show_name in set(allPossibleShowNames(self.show)):
|
||||||
ep_string = show_name + ' S%02d' % int(season) #1) showName SXX
|
ep_string = show_name + ' S%02d' % int(ep_obj.scene_season) #1) showName SXX
|
||||||
search_string['Season'].append(ep_string)
|
search_string['Season'].append(ep_string)
|
||||||
|
|
||||||
ep_string = show_name + ' Season ' + str(season) + ' -Ep*' #2) showName Season X
|
ep_string = show_name + ' Season ' + str(ep_obj.scene_season) + ' -Ep*' #2) showName Season X
|
||||||
search_string['Season'].append(ep_string)
|
search_string['Season'].append(ep_string)
|
||||||
|
|
||||||
search_string['Episode'] = self._get_episode_search_strings(season, episode)[0]['Episode']
|
search_string['Episode'] = self._get_episode_search_strings(ep_obj)[0]['Episode']
|
||||||
|
|
||||||
return [search_string]
|
return [search_string]
|
||||||
|
|
||||||
def _get_episode_search_strings(self, season, episode, add_string=''):
|
def _get_episode_search_strings(self, ep_obj, add_string=''):
|
||||||
|
|
||||||
search_string = {'Episode': []}
|
search_string = {'Episode': []}
|
||||||
|
|
||||||
if self.show.air_by_date:
|
if self.show.air_by_date:
|
||||||
for show_name in set(allPossibleShowNames(self.show)):
|
for show_name in set(allPossibleShowNames(self.show)):
|
||||||
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
||||||
str(episode).replace('-', '|') + '|' + \
|
str(ep_obj.airdate).replace('-', '|') + '|' + \
|
||||||
episode.strftime('%b')
|
ep_obj.airdate.strftime('%b')
|
||||||
search_string['Episode'].append(ep_string)
|
search_string['Episode'].append(ep_string)
|
||||||
elif self.show.sports:
|
elif self.show.sports:
|
||||||
for show_name in set(allPossibleShowNames(self.show)):
|
for show_name in set(allPossibleShowNames(self.show)):
|
||||||
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
||||||
str(episode).replace('-', '|') + '|' + \
|
str(ep_obj.airdate).replace('-', '|') + '|' + \
|
||||||
episode.strftime('%b')
|
ep_obj.airdate.strftime('%b')
|
||||||
search_string['Episode'].append(ep_string)
|
search_string['Episode'].append(ep_string)
|
||||||
else:
|
else:
|
||||||
for show_name in set(allPossibleShowNames(self.show)):
|
for show_name in set(allPossibleShowNames(self.show)):
|
||||||
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
||||||
sickbeard.config.naming_ep_type[2] % {'seasonnumber': season,
|
sickbeard.config.naming_ep_type[2] % {'seasonnumber': ep_obj.scene_season,
|
||||||
'episodenumber': episode} + '|' + \
|
'episodenumber': ep_obj.scene_episode} + '|' + \
|
||||||
sickbeard.config.naming_ep_type[0] % {'seasonnumber': season,
|
sickbeard.config.naming_ep_type[0] % {'seasonnumber': ep_obj.scene_season,
|
||||||
'episodenumber': episode} + '|' + \
|
'episodenumber': ep_obj.scene_episode} + '|' + \
|
||||||
sickbeard.config.naming_ep_type[3] % {'seasonnumber': season,
|
sickbeard.config.naming_ep_type[3] % {'seasonnumber': ep_obj.scene_season,
|
||||||
'episodenumber': episode}
|
'episodenumber': ep_obj.scene_episode}
|
||||||
|
|
||||||
ep_string += ' %s' % add_string
|
ep_string += ' %s' % add_string
|
||||||
|
|
||||||
|
@ -252,7 +252,7 @@ class ThePirateBayProvider(generic.TorrentProvider):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
#Accept Torrent only from Good People for every Episode Search
|
#Accept Torrent only from Good People for every Episode Search
|
||||||
if sickbeard.THEPIRATEBAY_TRUSTED and re.search('(VIP|Trusted|Helper)', torrent.group(0)) == None:
|
if sickbeard.THEPIRATEBAY_TRUSTED and re.search('(VIP|Trusted|Helper)', torrent.group(0)) is None:
|
||||||
logger.log(u"ThePirateBay Provider found result " + torrent.group(
|
logger.log(u"ThePirateBay Provider found result " + torrent.group(
|
||||||
'title') + " but that doesn't seem like a trusted result so I'm ignoring it", logger.DEBUG)
|
'title') + " but that doesn't seem like a trusted result so I'm ignoring it", logger.DEBUG)
|
||||||
continue
|
continue
|
||||||
|
@ -285,7 +285,7 @@ class ThePirateBayProvider(generic.TorrentProvider):
|
||||||
|
|
||||||
return (title, url)
|
return (title, url)
|
||||||
|
|
||||||
def getURL(self, url, post_data=None, headers=None):
|
def getURL(self, url, post_data=None, headers=None, json=False):
|
||||||
|
|
||||||
if not headers:
|
if not headers:
|
||||||
headers = {}
|
headers = {}
|
||||||
|
@ -376,9 +376,9 @@ class ThePirateBayProvider(generic.TorrentProvider):
|
||||||
self.show = curshow = helpers.findCertainShow(sickbeard.showList, int(sqlshow["showid"]))
|
self.show = curshow = helpers.findCertainShow(sickbeard.showList, int(sqlshow["showid"]))
|
||||||
curEp = curshow.getEpisode(int(sqlshow["season"]), int(sqlshow["episode"]))
|
curEp = curshow.getEpisode(int(sqlshow["season"]), int(sqlshow["episode"]))
|
||||||
|
|
||||||
searchString = self._get_episode_search_strings(curEp.scene_season, curEp.airdate if curshow.air_by_date else curEp.scene_episode, add_string='PROPER|REPACK')
|
searchString = self._get_episode_search_strings(curEp, add_string='PROPER|REPACK')
|
||||||
|
|
||||||
for item in self._doSearch(searchString[0], show=curshow):
|
for item in self._doSearch(searchString[0]):
|
||||||
title, url = self._get_title_and_url(item)
|
title, url = self._get_title_and_url(item)
|
||||||
results.append(classes.Proper(title, url, datetime.datetime.today()))
|
results.append(classes.Proper(title, url, datetime.datetime.today()))
|
||||||
|
|
||||||
|
|
|
@ -112,41 +112,41 @@ class TorrentDayProvider(generic.TorrentProvider):
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _get_season_search_strings(self, season, episode):
|
def _get_season_search_strings(self, ep_obj):
|
||||||
|
|
||||||
search_string = {'Season': [], 'Episode': []}
|
search_string = {'Season': [], 'Episode': []}
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = show_name + ' S%02d' % int(season) #1) showName SXX
|
ep_string = show_name + ' S%02d' % int(ep_obj.scene_season) #1) showName SXX
|
||||||
search_string['Season'].append(ep_string)
|
search_string['Season'].append(ep_string)
|
||||||
|
|
||||||
search_string['Episode'] = self._get_episode_search_strings(season, episode)[0]['Episode']
|
search_string['Episode'] = self._get_episode_search_strings(ep_obj)[0]['Episode']
|
||||||
|
|
||||||
return [search_string]
|
return [search_string]
|
||||||
|
|
||||||
def _get_episode_search_strings(self, season, episode, add_string=''):
|
def _get_episode_search_strings(self, ep_obj, add_string=''):
|
||||||
|
|
||||||
search_string = {'Episode': []}
|
search_string = {'Episode': []}
|
||||||
|
|
||||||
if not episode:
|
if not ep_obj:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
if self.show.air_by_date:
|
if self.show.air_by_date:
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
||||||
str(episode).replace('-', '|') + '|' + \
|
str(ep_obj.airdate).replace('-', '|') + '|' + \
|
||||||
episode.strftime('%b')
|
ep_obj.airdate.strftime('%b')
|
||||||
search_string['Episode'].append(ep_string)
|
search_string['Episode'].append(ep_string)
|
||||||
elif self.show.sports:
|
elif self.show.sports:
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
||||||
str(episode).replace('-', '|') + '|' + \
|
str(ep_obj.airdate).replace('-', '|') + '|' + \
|
||||||
episode.strftime('%b')
|
ep_obj.airdate.strftime('%b')
|
||||||
search_string['Episode'].append(ep_string)
|
search_string['Episode'].append(ep_string)
|
||||||
else:
|
else:
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = show_name_helpers.sanitizeSceneName(show_name) + ' ' + \
|
ep_string = show_name_helpers.sanitizeSceneName(show_name) + ' ' + \
|
||||||
sickbeard.config.naming_ep_type[2] % {'seasonnumber': season,
|
sickbeard.config.naming_ep_type[2] % {'seasonnumber': ep_obj.scene_season,
|
||||||
'episodenumber': episode}
|
'episodenumber': ep_obj.scene_episode}
|
||||||
|
|
||||||
search_string['Episode'].append(re.sub('\s+', ' ', ep_string))
|
search_string['Episode'].append(re.sub('\s+', ' ', ep_string))
|
||||||
|
|
||||||
|
@ -214,7 +214,7 @@ class TorrentDayProvider(generic.TorrentProvider):
|
||||||
|
|
||||||
return (title, url)
|
return (title, url)
|
||||||
|
|
||||||
def getURL(self, url, post_data=None, headers=None):
|
def getURL(self, url, post_data=None, headers=None, json=False):
|
||||||
|
|
||||||
if not self.session:
|
if not self.session:
|
||||||
self._doLogin()
|
self._doLogin()
|
||||||
|
@ -255,9 +255,9 @@ class TorrentDayProvider(generic.TorrentProvider):
|
||||||
self.show = curshow = helpers.findCertainShow(sickbeard.showList, int(sqlshow["showid"]))
|
self.show = curshow = helpers.findCertainShow(sickbeard.showList, int(sqlshow["showid"]))
|
||||||
curEp = curshow.getEpisode(int(sqlshow["season"]), int(sqlshow["episode"]))
|
curEp = curshow.getEpisode(int(sqlshow["season"]), int(sqlshow["episode"]))
|
||||||
|
|
||||||
searchString = self._get_episode_search_strings(curEp.scene_season, curEp.airdate if curshow.air_by_date else curEp.scene_episode, add_string='PROPER|REPACK')
|
searchString = self._get_episode_search_strings(curEp, add_string='PROPER|REPACK')
|
||||||
|
|
||||||
for item in self._doSearch(searchString[0], show=curshow):
|
for item in self._doSearch(searchString[0]):
|
||||||
title, url = self._get_title_and_url(item)
|
title, url = self._get_title_and_url(item)
|
||||||
results.append(classes.Proper(title, url, datetime.datetime.today()))
|
results.append(classes.Proper(title, url, datetime.datetime.today()))
|
||||||
|
|
||||||
|
|
|
@ -94,41 +94,41 @@ class TorrentLeechProvider(generic.TorrentProvider):
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _get_season_search_strings(self, season, episode):
|
def _get_season_search_strings(self, ep_obj):
|
||||||
|
|
||||||
search_string = {'Season': [], 'Episode': []}
|
search_string = {'Season': [], 'Episode': []}
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = show_name + ' S%02d' % int(season) #1) showName SXX
|
ep_string = show_name + ' S%02d' % int(ep_obj.scene_season) #1) showName SXX
|
||||||
search_string['Season'].append(ep_string)
|
search_string['Season'].append(ep_string)
|
||||||
|
|
||||||
search_string['Episode'] = self._get_episode_search_strings(season, episode)[0]['Episode']
|
search_string['Episode'] = self._get_episode_search_strings(ep_obj)[0]['Episode']
|
||||||
|
|
||||||
return [search_string]
|
return [search_string]
|
||||||
|
|
||||||
def _get_episode_search_strings(self, season, episode, add_string=''):
|
def _get_episode_search_strings(self, ep_obj, add_string=''):
|
||||||
|
|
||||||
search_string = {'Episode': []}
|
search_string = {'Episode': []}
|
||||||
|
|
||||||
if not episode:
|
if not ep_obj:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
if self.show.air_by_date:
|
if self.show.air_by_date:
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
||||||
str(episode).replace('-', '|') + '|' + \
|
str(ep_obj.airdate).replace('-', '|') + '|' + \
|
||||||
episode.strftime('%b')
|
ep_obj.airdate.strftime('%b')
|
||||||
search_string['Episode'].append(ep_string)
|
search_string['Episode'].append(ep_string)
|
||||||
elif self.show.sports:
|
elif self.show.sports:
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
||||||
str(episode).replace('-', '|') + '|' + \
|
str(ep_obj.airdate).replace('-', '|') + '|' + \
|
||||||
episode.strftime('%b')
|
ep_obj.airdate.strftime('%b')
|
||||||
search_string['Episode'].append(ep_string)
|
search_string['Episode'].append(ep_string)
|
||||||
else:
|
else:
|
||||||
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
|
||||||
ep_string = show_name_helpers.sanitizeSceneName(show_name) + ' ' + \
|
ep_string = show_name_helpers.sanitizeSceneName(show_name) + ' ' + \
|
||||||
sickbeard.config.naming_ep_type[2] % {'seasonnumber': season,
|
sickbeard.config.naming_ep_type[2] % {'seasonnumber': ep_obj.scene_season,
|
||||||
'episodenumber': episode}
|
'episodenumber': ep_obj.scene_episode}
|
||||||
|
|
||||||
search_string['Episode'].append(re.sub('\s+', ' ', ep_string))
|
search_string['Episode'].append(re.sub('\s+', ' ', ep_string))
|
||||||
|
|
||||||
|
@ -212,7 +212,7 @@ class TorrentLeechProvider(generic.TorrentProvider):
|
||||||
|
|
||||||
return (title, url)
|
return (title, url)
|
||||||
|
|
||||||
def getURL(self, url, post_data=None, headers=None):
|
def getURL(self, url, post_data=None, headers=None, json=False):
|
||||||
|
|
||||||
if not self.session:
|
if not self.session:
|
||||||
self._doLogin()
|
self._doLogin()
|
||||||
|
@ -256,9 +256,9 @@ class TorrentLeechProvider(generic.TorrentProvider):
|
||||||
self.show = curshow = helpers.findCertainShow(sickbeard.showList, int(sqlshow["showid"]))
|
self.show = curshow = helpers.findCertainShow(sickbeard.showList, int(sqlshow["showid"]))
|
||||||
curEp = curshow.getEpisode(int(sqlshow["season"]), int(sqlshow["episode"]))
|
curEp = curshow.getEpisode(int(sqlshow["season"]), int(sqlshow["episode"]))
|
||||||
|
|
||||||
searchString = self._get_episode_search_strings(curEp.scene_season, curEp.airdate if curshow.air_by_date else curEp.scene_episode, add_string='PROPER|REPACK')
|
searchString = self._get_episode_search_strings(curEp, add_string='PROPER|REPACK')
|
||||||
|
|
||||||
for item in self._doSearch(searchString[0], show=curshow):
|
for item in self._doSearch(searchString[0]):
|
||||||
title, url = self._get_title_and_url(item)
|
title, url = self._get_title_and_url(item)
|
||||||
results.append(classes.Proper(title, url, datetime.datetime.today()))
|
results.append(classes.Proper(title, url, datetime.datetime.today()))
|
||||||
|
|
||||||
|
|
|
@ -105,26 +105,26 @@ def makeSceneShowSearchStrings(show):
|
||||||
return map(sanitizeSceneName, showNames)
|
return map(sanitizeSceneName, showNames)
|
||||||
|
|
||||||
|
|
||||||
def makeSceneSeasonSearchString(show, season, episode, extraSearchType=None):
|
def makeSceneSeasonSearchString(show, ep_obj, extraSearchType=None):
|
||||||
myDB = db.DBConnection()
|
myDB = db.DBConnection()
|
||||||
|
|
||||||
if show.air_by_date:
|
if show.air_by_date:
|
||||||
numseasons = 0
|
numseasons = 0
|
||||||
|
|
||||||
# the search string for air by date shows is just
|
# the search string for air by date shows is just
|
||||||
seasonStrings = [season]
|
seasonStrings = [ep_obj.scene_season]
|
||||||
elif show.sports:
|
elif show.sports:
|
||||||
numseasons = 0
|
numseasons = 0
|
||||||
|
|
||||||
# the search string for air by date shows is just
|
# the search string for air by date shows is just
|
||||||
seasonStrings = [season]
|
seasonStrings = [ep_obj.scene_season]
|
||||||
else:
|
else:
|
||||||
numseasonsSQlResult = myDB.select(
|
numseasonsSQlResult = myDB.select(
|
||||||
"SELECT COUNT(DISTINCT season) as numseasons FROM tv_episodes WHERE showid = ? and season != 0",
|
"SELECT COUNT(DISTINCT season) as numseasons FROM tv_episodes WHERE showid = ? and season != 0",
|
||||||
[show.indexerid])
|
[show.indexerid])
|
||||||
numseasons = int(numseasonsSQlResult[0][0])
|
numseasons = int(numseasonsSQlResult[0][0])
|
||||||
|
|
||||||
seasonStrings = ["S%02d" % int(season)]
|
seasonStrings = ["S%02d" % int(ep_obj.scene_season)]
|
||||||
|
|
||||||
showNames = set(makeSceneShowSearchStrings(show))
|
showNames = set(makeSceneShowSearchStrings(show))
|
||||||
|
|
||||||
|
@ -143,12 +143,12 @@ def makeSceneSeasonSearchString(show, season, episode, extraSearchType=None):
|
||||||
toReturn.append(curShow + "." + cur_season)
|
toReturn.append(curShow + "." + cur_season)
|
||||||
|
|
||||||
# episode
|
# episode
|
||||||
toReturn.extend(makeSceneSearchString(show, season, episode))
|
toReturn.extend(makeSceneSearchString(show, ep_obj))
|
||||||
|
|
||||||
return toReturn
|
return toReturn
|
||||||
|
|
||||||
|
|
||||||
def makeSceneSearchString(show, season, episode):
|
def makeSceneSearchString(show, ep_obj):
|
||||||
myDB = db.DBConnection()
|
myDB = db.DBConnection()
|
||||||
numseasonsSQlResult = myDB.select(
|
numseasonsSQlResult = myDB.select(
|
||||||
"SELECT COUNT(DISTINCT season) as numseasons FROM tv_episodes WHERE showid = ? and season != 0",
|
"SELECT COUNT(DISTINCT season) as numseasons FROM tv_episodes WHERE showid = ? and season != 0",
|
||||||
|
@ -160,13 +160,13 @@ def makeSceneSearchString(show, season, episode):
|
||||||
numepisodes = int(numepisodesSQlResult[0][0])
|
numepisodes = int(numepisodesSQlResult[0][0])
|
||||||
|
|
||||||
# see if we should use dates instead of episodes
|
# see if we should use dates instead of episodes
|
||||||
if show.air_by_date and episode != datetime.date.fromordinal(1):
|
if show.air_by_date and ep_obj.airdate != datetime.date.fromordinal(1):
|
||||||
epStrings = [str(episode)]
|
epStrings = [str(ep_obj.airdate)]
|
||||||
if show.sports and episode != datetime.date.fromordinal(1):
|
elif show.sports and ep_obj.airdate != datetime.date.fromordinal(1):
|
||||||
epStrings = [str(episode)]
|
epStrings = [str(ep_obj.scene_episode)]
|
||||||
else:
|
else:
|
||||||
epStrings = ["S%02iE%02i" % (int(season), int(episode)),
|
epStrings = ["S%02iE%02i" % (int(ep_obj.scene_season), int(ep_obj.scene_episode)),
|
||||||
"%ix%02i" % (int(season), int(episode))]
|
"%ix%02i" % (int(ep_obj.scene_season), int(ep_obj.scene_episode))]
|
||||||
|
|
||||||
# for single-season shows just search for the show name -- if total ep count (exclude s0) is less than 11
|
# for single-season shows just search for the show name -- if total ep count (exclude s0) is less than 11
|
||||||
# due to the amount of qualities and releases, it is easy to go over the 50 result limit on rss feeds otherwise
|
# due to the amount of qualities and releases, it is easy to go over the 50 result limit on rss feeds otherwise
|
||||||
|
|
|
@ -190,7 +190,7 @@ class TVCache():
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _addCacheEntry(self, name, url):
|
def _addCacheEntry(self, name, url, quality=None):
|
||||||
|
|
||||||
cacheDB = self._getDB()
|
cacheDB = self._getDB()
|
||||||
parse_result = None
|
parse_result = None
|
||||||
|
@ -264,6 +264,7 @@ class TVCache():
|
||||||
curTimestamp = int(time.mktime(datetime.datetime.today().timetuple()))
|
curTimestamp = int(time.mktime(datetime.datetime.today().timetuple()))
|
||||||
|
|
||||||
# get quality of release
|
# get quality of release
|
||||||
|
if quality is None:
|
||||||
quality = Quality.sceneQuality(name)
|
quality = Quality.sceneQuality(name)
|
||||||
|
|
||||||
if not isinstance(name, unicode):
|
if not isinstance(name, unicode):
|
||||||
|
|
Loading…
Reference in a new issue