Commit 33e95870 authored by echel0n's avatar echel0n

Fix for sickragetv/sickrage-issues#246 - Moved rls required/ignored words to...

Fix for sickragetv/sickrage-issues#246 - Moved rls required/ignored words to pickBestResults function to occure before we filter the rls name for bad characters plus we now use this function when searching for propers/repacks.
parent 11269dae
......@@ -20,13 +20,14 @@ import datetime
import operator
import threading
import traceback
from search import pickBestResult
import sickbeard
from sickbeard import db
from sickbeard import exceptions
from sickbeard.exceptions import ex
from sickbeard import helpers, logger, show_name_helpers
from sickbeard import helpers, logger
from sickbeard import search
from sickbeard import history
......@@ -143,6 +144,11 @@ class ProperFinder():
curProper.version = parse_result.version
curProper.quality = Quality.nameQuality(curProper.name, parse_result.is_anime)
# filter release
if not pickBestResult(curProper):
logger.log(u"Proper " + curProper.name + " were rejected by our release filters.", logger.DEBUG)
continue
# only get anime proper if it has release group and version
if parse_result.is_anime:
if not curProper.release_group and curProper.version == -1:
......@@ -150,25 +156,6 @@ class ProperFinder():
logger.DEBUG)
continue
if not show_name_helpers.filterBadReleases(curProper.name, parse=False):
logger.log(u"Proper " + curProper.name + " isn't a valid scene release that we want, ignoring it",
logger.DEBUG)
continue
if parse_result.show.rls_ignore_words and search.filter_release_name(curProper.name,
parse_result.show.rls_ignore_words):
logger.log(
u"Ignoring " + curProper.name + " based on ignored words filter: " + parse_result.show.rls_ignore_words,
logger.INFO)
continue
if parse_result.show.rls_require_words and not search.filter_release_name(curProper.name,
parse_result.show.rls_require_words):
logger.log(
u"Ignoring " + curProper.name + " based on required words filter: " + parse_result.show.rls_require_words,
logger.INFO)
continue
# check if we actually want this proper (if it's the right quality)
myDB = db.DBConnection()
sqlResults = myDB.select("SELECT status FROM tv_episodes WHERE showid = ? AND season = ? AND episode = ?",
......@@ -217,8 +204,8 @@ class ProperFinder():
# make sure the episode has been downloaded before
myDB = db.DBConnection()
historyResults = myDB.select(
"SELECT resource FROM history "
"WHERE showid = ? AND season = ? AND episode = ? AND quality = ? AND date >= ? "
"SELECT resource FROM history " +
"WHERE showid = ? AND season = ? AND episode = ? AND quality = ? AND date >= ? " +
"AND action IN (" + ",".join([str(x) for x in Quality.SNATCHED]) + ")",
[curProper.indexerid, curProper.season, curProper.episode, curProper.quality,
historyLimit.strftime(history.dateFormat)])
......
......@@ -195,42 +195,47 @@ def filter_release_name(name, filter_words):
return False
def pickBestResult(results, show, quality_list=None):
def pickBestResult(results, show=None, quality_list=None):
results = results if isinstance(results, list) else [results]
logger.log(u"Picking the best result out of " + str([x.name for x in results]), logger.DEBUG)
# build the black And white list
bwl = None
if show:
if show.is_anime:
bwl = BlackAndWhiteList(show.indexerid)
else:
logger.log("Could not create black and white list no show was given", logger.DEBUG)
bestResult = None
# find the best result for the current episode
bestResult = None
for cur_result in results:
logger.log("Quality of " + cur_result.name + " is " + Quality.qualityStrings[cur_result.quality])
if show and cur_result.show is not show:
continue
if bwl:
# build the black And white list
if not bwl and cur_result.show.is_anime:
bwl = BlackAndWhiteList(cur_result.show.indexerid)
if not bwl.is_valid(cur_result):
logger.log(cur_result.name+" does not match the blacklist or the whitelist, rejecting it. Result: " + bwl.get_last_result_msg(), logger.INFO)
continue
logger.log("Quality of " + cur_result.name + " is " + Quality.qualityStrings[cur_result.quality])
if quality_list and cur_result.quality not in quality_list:
logger.log(cur_result.name + " is a quality we know we don't want, rejecting it", logger.DEBUG)
continue
if show.rls_ignore_words and filter_release_name(cur_result.name, show.rls_ignore_words):
if show.rls_ignore_words and filter_release_name(cur_result.name, cur_result.show.rls_ignore_words):
logger.log(u"Ignoring " + cur_result.name + " based on ignored words filter: " + show.rls_ignore_words,
logger.INFO)
continue
if show.rls_require_words and not filter_release_name(cur_result.name, show.rls_require_words):
if show.rls_require_words and not filter_release_name(cur_result.name, cur_result.show.rls_require_words):
logger.log(u"Ignoring " + cur_result.name + " based on required words filter: " + show.rls_require_words,
logger.INFO)
continue
if not show_name_helpers.filterBadReleases(cur_result.name, parse=False):
logger.log(u"Ignoring " + cur_result.name + " because its not a valid scene release that we want, ignoring it",
logger.INFO)
continue
if sickbeard.USE_FAILED_DOWNLOADS and failed_history.hasFailed(cur_result.name, cur_result.size,
cur_result.provider.name):
logger.log(cur_result.name + u" has previously failed, rejecting it")
......@@ -491,10 +496,6 @@ def searchProviders(show, episodes, manualSearch=False):
if len(searchResults):
# make a list of all the results for this provider
for curEp in searchResults:
# skip non-tv crap
searchResults[curEp] = filter(
lambda x: show_name_helpers.filterBadReleases(x.name, parse=False) and x.show == show, searchResults[curEp])
if curEp in foundResults:
foundResults[curProvider.name][curEp] += searchResults[curEp]
else:
......@@ -581,10 +582,6 @@ def searchProviders(show, episodes, manualSearch=False):
# if not, break it apart and add them as the lowest priority results
individualResults = nzbSplitter.splitResult(bestSeasonResult)
individualResults = filter(
lambda x: show_name_helpers.filterBadReleases(x.name, parse=False) and x.show == show, individualResults)
for curResult in individualResults:
if len(curResult.episodes) == 1:
epNum = curResult.episodes[0].episode
......@@ -604,7 +601,8 @@ def searchProviders(show, episodes, manualSearch=False):
u"Adding multi-ep result for full-season torrent. Set the episodes you don't want to 'don't download' in your torrent client if desired!")
epObjs = []
for curEpNum in allEps:
epObjs.append(show.getEpisode(season, curEpNum))
for season in set([x.season for x in episodes]):
epObjs.append(show.getEpisode(season, curEpNum))
bestSeasonResult.episodes = epObjs
epNum = MULTI_EP_RESULT
......
......@@ -317,11 +317,6 @@ class TVCache():
# for each cache entry
for curResult in sqlResults:
# skip non-tv crap
if not show_name_helpers.filterBadReleases(curResult["name"], parse=False):
continue
# get the show object, or if it's not one of our shows then ignore it
showObj = helpers.findCertainShow(sickbeard.showList, int(curResult["indexerid"]))
if not showObj:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment