Private GIT

Skip to content
Snippets Groups Projects
Commit 56a58b60 authored by miigotu's avatar miigotu
Browse files

Merge pull request #356 from SickRage/sql-changes

parents d28ba01f 53a797ee
No related branches found
No related tags found
No related merge requests found
......@@ -342,7 +342,7 @@ def validateDir(path, dirName, nzbNameOriginal, failed, result):
# make sure the dir isn't inside a show dir
myDB = db.DBConnection()
sqlResults = myDB.select("SELECT * FROM tv_shows")
sqlResults = myDB.select("SELECT location FROM tv_shows")
for sqlShow in sqlResults:
if dirName.lower().startswith(ek(os.path.realpath, sqlShow["location"]).lower() + os.sep) or \
......@@ -488,17 +488,11 @@ def already_postprocessed(dirName, videofile, force, result):
# Avoid processing the same dir again if we use a process method <> move
myDB = db.DBConnection()
sqlResult = myDB.select("SELECT * FROM tv_episodes WHERE release_name = ?", [dirName])
sqlResult = myDB.select("SELECT release_name FROM tv_episodes WHERE release_name in (?, ?) LIMIT 1", [dirName, videofile.rpartition('.')[0]])
if sqlResult:
# result.output += logHelper(u"You're trying to post process a dir that's already been processed, skipping", logger.DEBUG)
return True
else:
sqlResult = myDB.select("SELECT * FROM tv_episodes WHERE release_name = ?", [videofile.rpartition('.')[0]])
if sqlResult:
# result.output += logHelper(u"You're trying to post process a video that's already been processed, skipping", logger.DEBUG)
return True
# Needed if we have downloaded the same episode @ different quality
# But we need to make sure we check the history of the episode we're going to PP, and not others
np = NameParser(dirName, tryIndexers=True)
......@@ -507,7 +501,6 @@ def already_postprocessed(dirName, videofile, force, result):
except Exception: # ignore the exception, because we kind of expected it, but create parse_result anyway so we can perform a check on it.
parse_result = False
search_sql = "SELECT tv_episodes.indexerid, history.resource FROM tv_episodes INNER JOIN history ON history.showid=tv_episodes.showid" # This part is always the same
search_sql += " WHERE history.season=tv_episodes.season and history.episode=tv_episodes.episode"
# If we find a showid, a season number, and one or more episode numbers then we need to use those in the query
......@@ -515,7 +508,7 @@ def already_postprocessed(dirName, videofile, force, result):
search_sql += " and tv_episodes.showid = '" + str(parse_result.show.indexerid) + "' and tv_episodes.season = '" + str(parse_result.season_number) + "' and tv_episodes.episode = '" + str(parse_result.episode_numbers[0]) + "'"
search_sql += " and tv_episodes.status IN (" + ",".join([str(x) for x in common.Quality.DOWNLOADED]) + ")"
search_sql += " and history.resource LIKE ?"
search_sql += " and history.resource LIKE ? LIMIT 1"
sqlResult = myDB.select(search_sql, ['%' + videofile])
if sqlResult:
# result.output += logHelper(u"You're trying to post process a video that's already been processed, skipping", logger.DEBUG)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment