1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-12-13 11:32:20 -05:00

Fixes for thread naming issues where provider names are getting stacked on top each other per loop iteration.

Fix for speedcd no json data issue.

Fix for DB upgrade syntax errors caused by previous commit.
This commit is contained in:
echel0n 2014-07-24 09:12:29 -07:00
parent 161226180f
commit b16ff81478
6 changed files with 97 additions and 119 deletions

View File

@ -20,6 +20,7 @@ from __future__ import with_statement
import datetime import datetime
import threading import threading
import traceback
import sickbeard import sickbeard
from sickbeard import logger from sickbeard import logger
@ -42,19 +43,17 @@ class DailySearcher():
providers = [x for x in sickbeard.providers.sortedProviderList() if x.isActive() and not x.backlog_only] providers = [x for x in sickbeard.providers.sortedProviderList() if x.isActive() and not x.backlog_only]
for curProviderCount, curProvider in enumerate(providers): for curProviderCount, curProvider in enumerate(providers):
logger.log(u"Updating [" + curProvider.name + "] RSS cache ...")
try: try:
logger.log(u"Updating [" + curProvider.name + "] RSS cache ...")
curProvider.cache.updateCache() curProvider.cache.updateCache()
except exceptions.AuthException, e: except exceptions.AuthException, e:
logger.log(u"Authentication error: " + ex(e), logger.ERROR) logger.log(u"Authentication error: " + ex(e), logger.ERROR)
if curProviderCount != len(providers): continue
continue
break
except Exception, e: except Exception, e:
logger.log(u"Error while updating cache for " + curProvider.name + ", skipping: " + ex(e), logger.ERROR) logger.log(u"Error while updating cache for " + curProvider.name + ", skipping: " + ex(e), logger.ERROR)
if curProviderCount != len(providers): logger.log(traceback.format_exc(), logger.DEBUG)
continue continue
break
logger.log(u"Searching for coming episodes and 1 weeks worth of previously WANTED episodes ...") logger.log(u"Searching for coming episodes and 1 weeks worth of previously WANTED episodes ...")
@ -66,21 +65,14 @@ class DailySearcher():
[common.UNAIRED, common.WANTED, fromDate.toordinal(), curDate.toordinal()]) [common.UNAIRED, common.WANTED, fromDate.toordinal(), curDate.toordinal()])
sql_l = [] sql_l = []
todaysEps = {}
for sqlEp in sqlResults: for sqlEp in sqlResults:
try: try:
show = helpers.findCertainShow(sickbeard.showList, int(sqlEp["showid"])) show = helpers.findCertainShow(sickbeard.showList, int(sqlEp["showid"]))
except exceptions.MultipleShowObjectsException: except exceptions.MultipleShowObjectsException:
logger.log(u"ERROR: expected to find a single show matching " + sqlEp["showid"]) logger.log(u"ERROR: expected to find a single show matching " + sqlEp["showid"])
break continue
if not show: ep = show.getEpisode(int(sqlEp["season"]), int(sqlEp["episode"]))
logger.log(u"Unable to find the show with ID " + str(
sqlEp["showid"]) + " in your show list! DB value was " + str(sqlEp), logger.ERROR)
break
ep = show.getEpisode(sqlEp["season"], sqlEp["episode"])
with ep.lock: with ep.lock:
if ep.show.paused: if ep.show.paused:
ep.status = common.SKIPPED ep.status = common.SKIPPED
@ -89,26 +81,16 @@ class DailySearcher():
logger.log(u"New episode " + ep.prettyName() + " airs today, setting status to WANTED") logger.log(u"New episode " + ep.prettyName() + " airs today, setting status to WANTED")
ep.status = common.WANTED ep.status = common.WANTED
if ep.status == common.WANTED:
if show not in todaysEps:
todaysEps[show] = [ep]
else:
todaysEps[show].append(ep)
sql_l.append(ep.get_sql()) sql_l.append(ep.get_sql())
if ep.status == common.WANTED:
dailysearch_queue_item = sickbeard.search_queue.DailySearchQueueItem(show, [ep])
sickbeard.searchQueueScheduler.action.add_item(dailysearch_queue_item)
else:
logger.log(u"Could not find any wanted episodes for the last 7 days to search for")
if len(sql_l) > 0: if len(sql_l) > 0:
myDB = db.DBConnection() myDB = db.DBConnection()
myDB.mass_action(sql_l) myDB.mass_action(sql_l)
if len(todaysEps):
for show in todaysEps:
segment = todaysEps[show]
dailysearch_queue_item = sickbeard.search_queue.DailySearchQueueItem(show, segment)
sickbeard.searchQueueScheduler.action.add_item(dailysearch_queue_item)
else:
logger.log(u"Could not find any needed episodes to search for ...")
self.amActive = False self.amActive = False

View File

@ -168,7 +168,7 @@ class InitialSchema(db.SchemaUpgrade):
"CREATE TABLE info (last_backlog NUMERIC, last_indexer NUMERIC, last_proper_search NUMERIC)", "CREATE TABLE info (last_backlog NUMERIC, last_indexer NUMERIC, last_proper_search NUMERIC)",
"CREATE TABLE scene_numbering(indexer TEXT, indexer_id INTEGER, season INTEGER, episode INTEGER,scene_season INTEGER, scene_episode INTEGER, PRIMARY KEY(indexer_id, season, episode))", "CREATE TABLE scene_numbering(indexer TEXT, indexer_id INTEGER, season INTEGER, episode INTEGER,scene_season INTEGER, scene_episode INTEGER, PRIMARY KEY(indexer_id, season, episode))",
"CREATE TABLE tv_shows (show_id INTEGER PRIMARY KEY, indexer_id NUMERIC, indexer TEXT, show_name TEXT, location TEXT, network TEXT, genre TEXT, classification TEXT, runtime NUMERIC, quality NUMERIC, airs TEXT, status TEXT, flatten_folders NUMERIC, paused NUMERIC, startyear NUMERIC, air_by_date NUMERIC, lang TEXT, subtitles NUMERIC, notify_list TEXT, imdb_id TEXT, last_update_indexer NUMERIC, dvdorder NUMERIC, archive_firstmatch NUMERIC, rls_require_words TEXT, rls_ignore_words TEXT, sports NUMERIC);", "CREATE TABLE tv_shows (show_id INTEGER PRIMARY KEY, indexer_id NUMERIC, indexer TEXT, show_name TEXT, location TEXT, network TEXT, genre TEXT, classification TEXT, runtime NUMERIC, quality NUMERIC, airs TEXT, status TEXT, flatten_folders NUMERIC, paused NUMERIC, startyear NUMERIC, air_by_date NUMERIC, lang TEXT, subtitles NUMERIC, notify_list TEXT, imdb_id TEXT, last_update_indexer NUMERIC, dvdorder NUMERIC, archive_firstmatch NUMERIC, rls_require_words TEXT, rls_ignore_words TEXT, sports NUMERIC);",
"CREATE TABLE tv_episodes (episode_id INTEGER PRIMARY KEY, showid/ NUMERIC, indexerid NUMERIC, indexer TEXT, name TEXT, season NUMERIC, episode NUMERIC, description TEXT, airdate NUMERIC, hasnfo NUMERIC, hastbn NUMERIC, status NUMERIC, location TEXT, file_size NUMERIC, release_name TEXT, subtitles TEXT, subtitles_searchcount NUMERIC, subtitles_lastsearch TIMESTAMP, is_proper NUMERIC, scene_season NUMERIC, scene_episode NUMERIC);", "CREATE TABLE tv_episodes (episode_id INTEGER PRIMARY KEY, showid NUMERIC, indexerid NUMERIC, indexer TEXT, name TEXT, season NUMERIC, episode NUMERIC, description TEXT, airdate NUMERIC, hasnfo NUMERIC, hastbn NUMERIC, status NUMERIC, location TEXT, file_size NUMERIC, release_name TEXT, subtitles TEXT, subtitles_searchcount NUMERIC, subtitles_lastsearch TIMESTAMP, is_proper NUMERIC, scene_season NUMERIC, scene_episode NUMERIC);",
"CREATE UNIQUE INDEX idx_indexer_id ON tv_shows (indexer_id)", "CREATE UNIQUE INDEX idx_indexer_id ON tv_shows (indexer_id)",
"CREATE INDEX idx_showid ON tv_episodes (showid);", "CREATE INDEX idx_showid ON tv_episodes (showid);",
"CREATE INDEX idx_sta_epi_air ON tv_episodes (status,episode, airdate);", "CREATE INDEX idx_sta_epi_air ON tv_episodes (status,episode, airdate);",

View File

@ -19,6 +19,7 @@
import datetime import datetime
import operator import operator
import threading import threading
import traceback
import sickbeard import sickbeard
@ -68,20 +69,27 @@ class ProperFinder():
def _getProperList(self): def _getProperList(self):
propers = {} propers = {}
search_date = datetime.datetime.today() - datetime.timedelta(days=2)
# for each provider get a list of the # for each provider get a list of the
origThreadName = threading.currentThread().name origThreadName = threading.currentThread().name
providers = [x for x in sickbeard.providers.sortedProviderList() if x.isActive()] providers = [x for x in sickbeard.providers.sortedProviderList() if x.isActive()]
for curProvider in providers: for curProvider in providers:
threading.currentThread().name = origThreadName + " :: [" + curProvider.name + "]" threading.currentThread().name = origThreadName + " :: [" + curProvider.name + "]"
search_date = datetime.datetime.today() - datetime.timedelta(days=2)
logger.log(u"Searching for any new PROPER releases from " + curProvider.name) logger.log(u"Searching for any new PROPER releases from " + curProvider.name)
try: try:
curPropers = curProvider.findPropers(search_date) curPropers = curProvider.findPropers(search_date)
except exceptions.AuthException, e: except exceptions.AuthException, e:
logger.log(u"Authentication error: " + ex(e), logger.ERROR) logger.log(u"Authentication error: " + ex(e), logger.ERROR)
continue continue
except Exception, e:
logger.log(u"Error while searching " + curProvider.name + ", skipping: " + ex(e), logger.ERROR)
logger.log(traceback.format_exc(), logger.DEBUG)
continue
finally:
threading.currentThread().name = origThreadName
# if they haven't been added by a different provider than add the proper to the list # if they haven't been added by a different provider than add the proper to the list
for x in curPropers: for x in curPropers:
@ -91,12 +99,10 @@ class ProperFinder():
x.provider = curProvider x.provider = curProvider
propers[name] = x propers[name] = x
# reset thread name back to original
threading.currentThread().name = origThreadName
# take the list of unique propers and get it sorted by # take the list of unique propers and get it sorted by
sortedPropers = sorted(propers.values(), key=operator.attrgetter('date'), reverse=True) sortedPropers = sorted(propers.values(), key=operator.attrgetter('date'), reverse=True)
finalPropers = [] finalPropers = []
for curProper in sortedPropers: for curProper in sortedPropers:
try: try:
@ -162,7 +168,9 @@ class ProperFinder():
logger.log( logger.log(
u"Looks like this is an air-by-date or sports show, attempting to convert the date to season/episode", u"Looks like this is an air-by-date or sports show, attempting to convert the date to season/episode",
logger.DEBUG) logger.DEBUG)
airdate = curProper.episode.toordinal() airdate = curProper.episode.toordinal()
myDB = db.DBConnection() myDB = db.DBConnection()
sql_result = myDB.select( sql_result = myDB.select(
"SELECT season, episode FROM tv_episodes WHERE showid = ? and indexer = ? and airdate = ?", "SELECT season, episode FROM tv_episodes WHERE showid = ? and indexer = ? and airdate = ?",

View File

@ -164,6 +164,8 @@ class SpeedCDProvider(generic.TorrentProvider):
**self.categories[mode]) **self.categories[mode])
data = self.session.post(self.urls['search'], data=post_data).json() data = self.session.post(self.urls['search'], data=post_data).json()
if not data:
continue
try: try:
torrents = data.get('Fs', [])[0].get('Cn', {}).get('torrents', []) torrents = data.get('Fs', [])[0].get('Cn', {}).get('torrents', [])

View File

@ -22,10 +22,11 @@ import os
import re import re
import threading import threading
import datetime import datetime
import traceback
import sickbeard import sickbeard
from common import SNATCHED, SNATCHED_PROPER, SNATCHED_BEST, Quality, SEASON_RESULT, MULTI_EP_RESULT, Overview from common import SNATCHED, SNATCHED_PROPER, SNATCHED_BEST, Quality, SEASON_RESULT, MULTI_EP_RESULT
from sickbeard import logger, db, show_name_helpers, exceptions, helpers from sickbeard import logger, db, show_name_helpers, exceptions, helpers
from sickbeard import sab from sickbeard import sab
@ -36,10 +37,9 @@ from sickbeard import notifiers
from sickbeard import nzbSplitter from sickbeard import nzbSplitter
from sickbeard import ui from sickbeard import ui
from sickbeard import encodingKludge as ek from sickbeard import encodingKludge as ek
from sickbeard import providers
from sickbeard import failed_history from sickbeard import failed_history
from sickbeard.exceptions import ex from sickbeard.exceptions import ex
from sickbeard.providers.generic import GenericProvider, tvcache from sickbeard.providers.generic import GenericProvider
from sickbeard.blackandwhitelist import BlackAndWhiteList from sickbeard.blackandwhitelist import BlackAndWhiteList
def _downloadResult(result): def _downloadResult(result):
@ -52,9 +52,6 @@ def _downloadResult(result):
""" """
resProvider = result.provider resProvider = result.provider
newResult = False
if resProvider == None: if resProvider == None:
logger.log(u"Invalid provider name - this is a coding error, report it please", logger.ERROR) logger.log(u"Invalid provider name - this is a coding error, report it please", logger.ERROR)
return False return False
@ -109,7 +106,8 @@ def snatchEpisode(result, endStatus=SNATCHED):
endStatus: the episode status that should be used for the episode object once it's snatched. endStatus: the episode status that should be used for the episode object once it's snatched.
""" """
if result is None: return False if result is None:
return False
result.priority = 0 # -1 = low, 0 = normal, 1 = high result.priority = 0 # -1 = low, 0 = normal, 1 = high
if sickbeard.ALLOW_HIGH_PRIORITY: if sickbeard.ALLOW_HIGH_PRIORITY:
@ -176,7 +174,6 @@ def snatchEpisode(result, endStatus=SNATCHED):
myDB = db.DBConnection() myDB = db.DBConnection()
myDB.mass_action(sql_l) myDB.mass_action(sql_l)
return True return True
@ -345,32 +342,27 @@ def searchForNeededEpisodes(show, episodes):
foundResults = {} foundResults = {}
didSearch = False didSearch = False
providers = [x for x in sickbeard.providers.sortedProviderList() if x.isActive() and not x.backlog_only]
if not len(providers):
logger.log(u"No NZB/Torrent providers found or enabled in the sickrage config. Please check your settings.",
logger.ERROR)
return
origThreadName = threading.currentThread().name origThreadName = threading.currentThread().name
providers = [x for x in sickbeard.providers.sortedProviderList() if x.isActive() and not x.backlog_only]
for curProviderCount, curProvider in enumerate(providers): for curProviderCount, curProvider in enumerate(providers):
if curProvider.anime_only and not show.is_anime: if curProvider.anime_only and not show.is_anime:
logger.log(u"" + str(show.name) + " is not an anime skiping ...") logger.log(u"" + str(show.name) + " is not an anime, skiping", logger.DEBUG)
continue continue
threading.currentThread().name = origThreadName + " :: [" + curProvider.name + "]"
try: try:
threading.currentThread().name = origThreadName + " :: [" + curProvider.name + "]"
curFoundResults = curProvider.searchRSS(episodes) curFoundResults = curProvider.searchRSS(episodes)
threading.currentThread().name = origThreadName
except exceptions.AuthException, e: except exceptions.AuthException, e:
logger.log(u"Authentication error: " + ex(e), logger.ERROR) logger.log(u"Authentication error: " + ex(e), logger.ERROR)
if curProviderCount != len(providers): continue
continue
break
except Exception, e: except Exception, e:
logger.log(u"Error while searching " + curProvider.name + ", skipping: " + ex(e), logger.ERROR) logger.log(u"Error while searching " + curProvider.name + ", skipping: " + ex(e), logger.ERROR)
if curProviderCount != len(providers): logger.log(traceback.format_exc(), logger.DEBUG)
continue continue
break finally:
threading.currentThread().name = origThreadName
didSearch = True didSearch = True
@ -408,12 +400,6 @@ def searchProviders(show, season, episodes, manualSearch=False):
foundResults = {} foundResults = {}
finalResults = [] finalResults = []
providers = [x for x in sickbeard.providers.sortedProviderList() if x.isActive()]
if not len(providers):
logger.log(u"No NZB/Torrent providers found or enabled in the sickrage config. Please check your settings.",
logger.ERROR)
return
# check if we want to search for season packs instead of just season/episode # check if we want to search for season packs instead of just season/episode
seasonSearch = False seasonSearch = False
if not manualSearch: if not manualSearch:
@ -422,17 +408,21 @@ def searchProviders(show, season, episodes, manualSearch=False):
seasonSearch = True seasonSearch = True
origThreadName = threading.currentThread().name origThreadName = threading.currentThread().name
for providerNum, provider in enumerate(providers):
if provider.anime_only and not show.is_anime: providers = [x for x in sickbeard.providers.sortedProviderList() if x.isActive()]
logger.log(u"" + str(show.name) + " is not an anime skiping ...") for providerNum, curProvider in enumerate(providers):
if curProvider.anime_only and not show.is_anime:
logger.log(u"" + str(show.name) + " is not an anime, skiping", logger.DEBUG)
continue continue
foundResults[provider.name] = {} threading.currentThread().name = origThreadName + " :: [" + curProvider.name + "]"
foundResults[curProvider.name] = {}
searchCount = 0 searchCount = 0
search_mode = 'eponly' search_mode = 'eponly'
if seasonSearch and provider.search_mode == 'sponly': if seasonSearch and curProvider.search_mode == 'sponly':
search_mode = provider.search_mode search_mode = curProvider.search_mode
while(True): while(True):
searchCount += 1 searchCount += 1
@ -443,15 +433,16 @@ def searchProviders(show, season, episodes, manualSearch=False):
logger.log(u"Searching for episodes we need from " + show.name + " Season " + str(season)) logger.log(u"Searching for episodes we need from " + show.name + " Season " + str(season))
try: try:
threading.currentThread().name = origThreadName + " :: [" + provider.name + "]" searchResults = curProvider.findSearchResults(show, season, episodes, search_mode, manualSearch)
searchResults = provider.findSearchResults(show, season, episodes, search_mode, manualSearch)
threading.currentThread().name = origThreadName
except exceptions.AuthException, e: except exceptions.AuthException, e:
logger.log(u"Authentication error: " + ex(e), logger.ERROR) logger.log(u"Authentication error: " + ex(e), logger.ERROR)
break break
except Exception, e: except Exception, e:
logger.log(u"Error while searching " + provider.name + ", skipping: " + ex(e), logger.ERROR) logger.log(u"Error while searching " + curProvider.name + ", skipping: " + ex(e), logger.ERROR)
logger.log(traceback.format_exc(), logger.DEBUG)
break break
finally:
threading.currentThread().name = origThreadName
if len(searchResults): if len(searchResults):
# make a list of all the results for this provider # make a list of all the results for this provider
@ -461,12 +452,12 @@ def searchProviders(show, season, episodes, manualSearch=False):
lambda x: show_name_helpers.filterBadReleases(x.name) and x.show == show, searchResults[curEp]) lambda x: show_name_helpers.filterBadReleases(x.name) and x.show == show, searchResults[curEp])
if curEp in foundResults: if curEp in foundResults:
foundResults[provider.name][curEp] += searchResults[curEp] foundResults[curProvider.name][curEp] += searchResults[curEp]
else: else:
foundResults[provider.name][curEp] = searchResults[curEp] foundResults[curProvider.name][curEp] = searchResults[curEp]
break break
elif not provider.search_fallback or searchCount == 2: elif not curProvider.search_fallback or searchCount == 2:
break break
if search_mode == 'sponly': if search_mode == 'sponly':
@ -477,22 +468,20 @@ def searchProviders(show, season, episodes, manualSearch=False):
search_mode = 'sponly' search_mode = 'sponly'
# skip to next provider if we have no results to process # skip to next provider if we have no results to process
if not len(foundResults[provider.name]): if not len(foundResults[curProvider.name]):
if providerNum != len(providers): continue
continue
break
anyQualities, bestQualities = Quality.splitQuality(show.quality) anyQualities, bestQualities = Quality.splitQuality(show.quality)
# pick the best season NZB # pick the best season NZB
bestSeasonNZB = None bestSeasonNZB = None
if SEASON_RESULT in foundResults[provider.name]: if SEASON_RESULT in foundResults[curProvider.name]:
bestSeasonNZB = pickBestResult(foundResults[provider.name][SEASON_RESULT], show, bestSeasonNZB = pickBestResult(foundResults[curProvider.name][SEASON_RESULT], show,
anyQualities + bestQualities) anyQualities + bestQualities)
highest_quality_overall = 0 highest_quality_overall = 0
for cur_episode in foundResults[provider.name]: for cur_episode in foundResults[curProvider.name]:
for cur_result in foundResults[provider.name][cur_episode]: for cur_result in foundResults[curProvider.name][cur_episode]:
if cur_result.quality != Quality.UNKNOWN and cur_result.quality > highest_quality_overall: if cur_result.quality != Quality.UNKNOWN and cur_result.quality > highest_quality_overall:
highest_quality_overall = cur_result.quality highest_quality_overall = cur_result.quality
logger.log(u"The highest quality of any match is " + Quality.qualityStrings[highest_quality_overall], logger.log(u"The highest quality of any match is " + Quality.qualityStrings[highest_quality_overall],
@ -502,7 +491,6 @@ def searchProviders(show, season, episodes, manualSearch=False):
if bestSeasonNZB: if bestSeasonNZB:
# get the quality of the season nzb # get the quality of the season nzb
seasonQual = Quality.sceneQuality(bestSeasonNZB.name)
seasonQual = bestSeasonNZB.quality seasonQual = bestSeasonNZB.quality
logger.log( logger.log(
u"The quality of the season " + bestSeasonNZB.provider.providerType + " is " + Quality.qualityStrings[ u"The quality of the season " + bestSeasonNZB.provider.providerType + " is " + Quality.qualityStrings[
@ -555,10 +543,10 @@ def searchProviders(show, season, episodes, manualSearch=False):
elif len(curResult.episodes) > 1: elif len(curResult.episodes) > 1:
epNum = MULTI_EP_RESULT epNum = MULTI_EP_RESULT
if epNum in foundResults[provider.name]: if epNum in foundResults[curProvider.name]:
foundResults[provider.name][epNum].append(curResult) foundResults[curProvider.name][epNum].append(curResult)
else: else:
foundResults[provider.name][epNum] = [curResult] foundResults[curProvider.name][epNum] = [curResult]
# If this is a torrent all we can do is leech the entire torrent, user will have to select which eps not do download in his torrent client # If this is a torrent all we can do is leech the entire torrent, user will have to select which eps not do download in his torrent client
else: else:
@ -572,15 +560,15 @@ def searchProviders(show, season, episodes, manualSearch=False):
bestSeasonNZB.episodes = epObjs bestSeasonNZB.episodes = epObjs
epNum = MULTI_EP_RESULT epNum = MULTI_EP_RESULT
if epNum in foundResults[provider.name]: if epNum in foundResults[curProvider.name]:
foundResults[provider.name][epNum].append(bestSeasonNZB) foundResults[curProvider.name][epNum].append(bestSeasonNZB)
else: else:
foundResults[provider.name][epNum] = [bestSeasonNZB] foundResults[curProvider.name][epNum] = [bestSeasonNZB]
# go through multi-ep results and see if we really want them or not, get rid of the rest # go through multi-ep results and see if we really want them or not, get rid of the rest
multiResults = {} multiResults = {}
if MULTI_EP_RESULT in foundResults[provider.name]: if MULTI_EP_RESULT in foundResults[curProvider.name]:
for multiResult in foundResults[provider.name][MULTI_EP_RESULT]: for multiResult in foundResults[curProvider.name][MULTI_EP_RESULT]:
logger.log(u"Seeing if we want to bother with multi-episode result " + multiResult.name, logger.DEBUG) logger.log(u"Seeing if we want to bother with multi-episode result " + multiResult.name, logger.DEBUG)
@ -595,15 +583,10 @@ def searchProviders(show, season, episodes, manualSearch=False):
for epObj in multiResult.episodes: for epObj in multiResult.episodes:
epNum = epObj.episode epNum = epObj.episode
# if we have results for the episode # if we have results for the episode
if epNum in foundResults[provider.name] and len(foundResults[provider.name][epNum]) > 0: if epNum in foundResults[curProvider.name] and len(foundResults[curProvider.name][epNum]) > 0:
# but the multi-ep is worse quality, we don't want it
# TODO: wtf is this False for
# if False and multiResult.quality <= pickBestResult(foundResults[epNum]):
# notNeededEps.append(epNum)
#else:
neededEps.append(epNum) neededEps.append(epNum)
else: else:
neededEps.append(epNum) notNeededEps.append(epNum)
logger.log( logger.log(
u"Single-ep check result is neededEps: " + str(neededEps) + ", notNeededEps: " + str(notNeededEps), u"Single-ep check result is neededEps: " + str(neededEps) + ", notNeededEps: " + str(notNeededEps),
@ -641,22 +624,22 @@ def searchProviders(show, season, episodes, manualSearch=False):
# don't bother with the single result if we're going to get it with a multi result # don't bother with the single result if we're going to get it with a multi result
for epObj in multiResult.episodes: for epObj in multiResult.episodes:
epNum = epObj.episode epNum = epObj.episode
if epNum in foundResults[provider.name]: if epNum in foundResults[curProvider.name]:
logger.log( logger.log(
u"A needed multi-episode result overlaps with a single-episode result for ep #" + str( u"A needed multi-episode result overlaps with a single-episode result for ep #" + str(
epNum) + ", removing the single-episode results from the list", logger.DEBUG) epNum) + ", removing the single-episode results from the list", logger.DEBUG)
del foundResults[provider.name][epNum] del foundResults[curProvider.name][epNum]
# of all the single ep results narrow it down to the best one for each episode # of all the single ep results narrow it down to the best one for each episode
finalResults += set(multiResults.values()) finalResults += set(multiResults.values())
for curEp in foundResults[provider.name]: for curEp in foundResults[curProvider.name]:
if curEp in (MULTI_EP_RESULT, SEASON_RESULT): if curEp in (MULTI_EP_RESULT, SEASON_RESULT):
continue continue
if len(foundResults[provider.name][curEp]) == 0: if len(foundResults[curProvider.name][curEp]) == 0:
continue continue
bestResult = pickBestResult(foundResults[provider.name][curEp], show) bestResult = pickBestResult(foundResults[curProvider.name][curEp], show)
# if all results were rejected move on to the next episode # if all results were rejected move on to the next episode
if not bestResult: if not bestResult:
@ -682,7 +665,11 @@ def searchProviders(show, season, episodes, manualSearch=False):
wantedEpCount += 1 wantedEpCount += 1
# make sure we search every provider for results unless we found everything we wanted # make sure we search every provider for results unless we found everything we wanted
if providerNum == len(providers) or wantedEpCount == len(episodes): if wantedEpCount == len(episodes):
break break
else:
logger.log(u"No NZB/Torrent providers found or enabled in the sickrage config. Please check your settings.",
logger.ERROR)
return finalResults return finalResults

View File

@ -2693,18 +2693,17 @@ class NewHomeAddShows(MainHandler):
indexer_id = show_name = indexer = None indexer_id = show_name = indexer = None
for cur_provider in sickbeard.metadata_provider_dict.values(): for cur_provider in sickbeard.metadata_provider_dict.values():
(indexer_id, show_name, indexer) = cur_provider.retrieveShowMetadata(cur_path) (indexer_id, show_name, indexer) = cur_provider.retrieveShowMetadata(cur_path)
if show_name: break
# default to TVDB if indexer was not detected # default to TVDB if indexer was not detected
if show_name and not (indexer and indexer_id): if show_name and not (indexer or indexer_id):
(sn, idx, id) = helpers.searchIndexerForShowID(show_name, indexer, indexer_id) (sn, idx, id) = helpers.searchIndexerForShowID(show_name, indexer, indexer_id)
# set indexer and indexer_id from found info # set indexer and indexer_id from found info
if indexer is None and idx: if not indexer and idx:
indexer = idx indexer = idx
if indexer_id is None and id: if not indexer_id and id:
indexer_id = id indexer_id = id
cur_dir['existing_info'] = (indexer_id, show_name, indexer) cur_dir['existing_info'] = (indexer_id, show_name, indexer)