1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-12-12 11:02:21 -05:00

Fixed issue #954 - Default EP status now hardcoded with a default of SKIPPED.

Fixed a issue that was causing show status to be set to NoneType randomly.
Fixed misc comparisons that were causing improper code executions.
Misc PEP8 coding fixes.
This commit is contained in:
echel0n 2014-12-05 18:03:20 -08:00
parent 4254916ae9
commit d536d43b6f
3 changed files with 70 additions and 85 deletions

View File

@ -294,8 +294,8 @@ class QueueItemAdd(ShowQueueItem):
self.show.paused = self.paused if self.paused != None else False self.show.paused = self.paused if self.paused != None else False
# set up default new/missing episode status # set up default new/missing episode status
self.show.default_ep_status = self.default_status
logger.log(u"Setting all episodes to the specified default status: " + str(self.show.default_ep_status)) logger.log(u"Setting all episodes to the specified default status: " + str(self.show.default_ep_status))
self.show.default_ep_status = self.default_status
# be smartish about this # be smartish about this
if self.show.genre and "talk show" in self.show.genre.lower(): if self.show.genre and "talk show" in self.show.genre.lower():

View File

@ -87,7 +87,7 @@ class TVShow(object):
self._startyear = 0 self._startyear = 0
self._paused = 0 self._paused = 0
self._air_by_date = 0 self._air_by_date = 0
self._subtitles = int(sickbeard.SUBTITLES_DEFAULT if sickbeard.SUBTITLES_DEFAULT else 0) self._subtitles = int(sickbeard.SUBTITLES_DEFAULT)
self._dvdorder = 0 self._dvdorder = 0
self._archive_firstmatch = 0 self._archive_firstmatch = 0
self._lang = lang self._lang = lang
@ -97,7 +97,7 @@ class TVShow(object):
self._scene = 0 self._scene = 0
self._rls_ignore_words = "" self._rls_ignore_words = ""
self._rls_require_words = "" self._rls_require_words = ""
self._default_ep_status = "" self._default_ep_status = SKIPPED
self.dirty = True self.dirty = True
self._location = "" self._location = ""
@ -216,19 +216,21 @@ class TVShow(object):
ep_list = [] ep_list = []
for cur_result in results: for cur_result in results:
cur_ep = self.getEpisode(int(cur_result["season"]), int(cur_result["episode"])) cur_ep = self.getEpisode(int(cur_result["season"]), int(cur_result["episode"]))
if cur_ep: if not cur_ep:
cur_ep.relatedEps = [] continue
if cur_ep.location:
# if there is a location, check if it's a multi-episode (share_location > 0) and put them in relatedEps cur_ep.relatedEps = []
if cur_result["share_location"] > 0: if cur_ep.location:
related_eps_result = myDB.select( # if there is a location, check if it's a multi-episode (share_location > 0) and put them in relatedEps
"SELECT * FROM tv_episodes WHERE showid = ? AND season = ? AND location = ? AND episode != ? ORDER BY episode ASC", if cur_result["share_location"] > 0:
[self.indexerid, cur_ep.season, cur_ep.location, cur_ep.episode]) related_eps_result = myDB.select(
for cur_related_ep in related_eps_result: "SELECT * FROM tv_episodes WHERE showid = ? AND season = ? AND location = ? AND episode != ? ORDER BY episode ASC",
related_ep = self.getEpisode(int(cur_related_ep["season"]), int(cur_related_ep["episode"])) [self.indexerid, cur_ep.season, cur_ep.location, cur_ep.episode])
if related_ep not in cur_ep.relatedEps: for cur_related_ep in related_eps_result:
cur_ep.relatedEps.append(related_ep) related_ep = self.getEpisode(int(cur_related_ep["season"]), int(cur_related_ep["episode"]))
ep_list.append(cur_ep) if related_ep and related_ep not in cur_ep.relatedEps:
cur_ep.relatedEps.append(related_ep)
ep_list.append(cur_ep)
return ep_list return ep_list
@ -279,16 +281,8 @@ class TVShow(object):
def should_update(self, update_date=datetime.date.today()): def should_update(self, update_date=datetime.date.today()):
cur_indexerid = self.indexerid # if show is not 'Ended' always update (status 'Continuing')
if not self.status or 'Ended' not in self.status:
# In some situations self.status = None.. need to figure out where that is!
#if not self.status:
# self.status = ''
# logger.log("Status missing for showid: [%s] with status: [%s]" %
# (cur_indexerid, self.status), logger.DEBUG)
# if show is not 'Ended' always update (status 'Continuing' or '')
if 'Ended' not in self.status:
return True return True
# run logic against the current show latest aired and next unaired data to see if we should bypass 'Ended' status # run logic against the current show latest aired and next unaired data to see if we should bypass 'Ended' status
@ -301,7 +295,7 @@ class TVShow(object):
myDB = db.DBConnection() myDB = db.DBConnection()
sql_result = myDB.select( sql_result = myDB.select(
"SELECT * FROM tv_episodes WHERE showid = ? AND season > '0' AND airdate > '1' AND status > '1' ORDER BY airdate DESC LIMIT 1", "SELECT * FROM tv_episodes WHERE showid = ? AND season > '0' AND airdate > '1' AND status > '1' ORDER BY airdate DESC LIMIT 1",
[cur_indexerid]) [self.indexerid])
if sql_result: if sql_result:
last_airdate = datetime.date.fromordinal(sql_result[0]['airdate']) last_airdate = datetime.date.fromordinal(sql_result[0]['airdate'])
@ -311,7 +305,7 @@ class TVShow(object):
# get next upcoming UNAIRED episode to compare against today + graceperiod # get next upcoming UNAIRED episode to compare against today + graceperiod
sql_result = myDB.select( sql_result = myDB.select(
"SELECT * FROM tv_episodes WHERE showid = ? AND season > '0' AND airdate > '1' AND status = '1' ORDER BY airdate ASC LIMIT 1", "SELECT * FROM tv_episodes WHERE showid = ? AND season > '0' AND airdate > '1' AND status = '1' ORDER BY airdate ASC LIMIT 1",
[cur_indexerid]) [self.indexerid])
if sql_result: if sql_result:
next_airdate = datetime.date.fromordinal(sql_result[0]['airdate']) next_airdate = datetime.date.fromordinal(sql_result[0]['airdate'])
@ -369,6 +363,9 @@ class TVShow(object):
logger.log(str(self.indexerid) + u": Retrieving/creating episode " + str(epResult["season"]) + "x" + str( logger.log(str(self.indexerid) + u": Retrieving/creating episode " + str(epResult["season"]) + "x" + str(
epResult["episode"]), logger.DEBUG) epResult["episode"]), logger.DEBUG)
curEp = self.getEpisode(epResult["season"], epResult["episode"]) curEp = self.getEpisode(epResult["season"], epResult["episode"])
if not curEp:
continue
curEp.createMetaFiles() curEp.createMetaFiles()
@ -502,6 +499,8 @@ class TVShow(object):
try: try:
curEp = self.getEpisode(curSeason, curEpisode) curEp = self.getEpisode(curSeason, curEpisode)
if not curEp:
raise exceptions.EpisodeNotFoundException
# if we found out that the ep is no longer on TVDB then delete it from our database too # if we found out that the ep is no longer on TVDB then delete it from our database too
if deleteEp: if deleteEp:
@ -553,6 +552,8 @@ class TVShow(object):
continue continue
try: try:
ep = self.getEpisode(season, episode) ep = self.getEpisode(season, episode)
if not ep:
raise exceptions.EpisodeNotFoundException
except exceptions.EpisodeNotFoundException: except exceptions.EpisodeNotFoundException:
logger.log( logger.log(
str(self.indexerid) + ": " + sickbeard.indexerApi(self.indexer).name + " object for " + str( str(self.indexerid) + ": " + sickbeard.indexerApi(self.indexer).name + " object for " + str(
@ -644,11 +645,13 @@ class TVShow(object):
checkQualityAgain = False checkQualityAgain = False
same_file = False same_file = False
curEp = self.getEpisode(season, episode)
if curEp == None: curEp = self.getEpisode(season, episode)
if not curEp:
try: try:
curEp = self.getEpisode(season, episode, file) curEp = self.getEpisode(season, episode, file)
if not curEp:
raise exceptions.EpisodeNotFoundException
except exceptions.EpisodeNotFoundException: except exceptions.EpisodeNotFoundException:
logger.log(str(self.indexerid) + u": Unable to figure out what this file is, skipping", logger.log(str(self.indexerid) + u": Unable to figure out what this file is, skipping",
logger.ERROR) logger.ERROR)
@ -677,11 +680,13 @@ class TVShow(object):
rootEp = curEp rootEp = curEp
else: else:
if curEp not in rootEp.relatedEps: if curEp not in rootEp.relatedEps:
rootEp.relatedEps.append(curEp) with rootEp.lock:
rootEp.relatedEps.append(curEp)
# if it's a new file then # if it's a new file then
if not same_file: if not same_file:
curEp.release_name = '' with curEp.lock:
curEp.release_name = ''
# if they replace a file on me I'll make some attempt at re-checking the quality unless I know it's the same file # if they replace a file on me I'll make some attempt at re-checking the quality unless I know it's the same file
if checkQualityAgain and not same_file: if checkQualityAgain and not same_file:
@ -689,7 +694,8 @@ class TVShow(object):
logger.log(u"Since this file has been renamed, I checked " + file + " and found quality " + logger.log(u"Since this file has been renamed, I checked " + file + " and found quality " +
Quality.qualityStrings[newQuality], logger.DEBUG) Quality.qualityStrings[newQuality], logger.DEBUG)
if newQuality != Quality.UNKNOWN: if newQuality != Quality.UNKNOWN:
curEp.status = Quality.compositeStatus(DOWNLOADED, newQuality) with curEp.lock:
curEp.status = Quality.compositeStatus(DOWNLOADED, newQuality)
# check for status/quality changes as long as it's a new file # check for status/quality changes as long as it's a new file
@ -736,7 +742,7 @@ class TVShow(object):
# creating metafiles on the root should be good enough # creating metafiles on the root should be good enough
if sickbeard.USE_FAILED_DOWNLOADS and rootEp is not None: if rootEp:
with rootEp.lock: with rootEp.lock:
rootEp.createMetaFiles() rootEp.createMetaFiles()
@ -755,64 +761,38 @@ class TVShow(object):
logger.log(str(self.indexerid) + ": Unable to find the show in the database") logger.log(str(self.indexerid) + ": Unable to find the show in the database")
return return
else: else:
if not self.indexer: self.indexer = int(sqlResults[0]["indexer"] or 0)
self.indexer = int(sqlResults[0]["indexer"])
if not self.name: if not self.name:
self.name = sqlResults[0]["show_name"] self.name = sqlResults[0]["show_name"]
if not self.network: if not self.network:
self.network = sqlResults[0]["network"] self.network = sqlResults[0]["network"]
if not self.genre: if not self.genre:
self.genre = sqlResults[0]["genre"] self.genre = sqlResults[0]["genre"]
if self.classification is None: if not self.classification:
self.classification = sqlResults[0]["classification"] self.classification = sqlResults[0]["classification"]
self.runtime = sqlResults[0]["runtime"] self.runtime = sqlResults[0]["runtime"]
self.status = sqlResults[0]["status"] self.status = sqlResults[0]["status"]
if not self.status: if self.status is None:
self.status = "" self.status = ""
self.airs = sqlResults[0]["airs"] self.airs = sqlResults[0]["airs"]
if not self.airs: if self.airs is None:
self.airs = "" self.airs = ""
self.startyear = sqlResults[0]["startyear"] self.startyear = int(sqlResults[0]["startyear"] or 0)
if not self.startyear: self.air_by_date = int(sqlResults[0]["air_by_date"] or 0)
self.startyear = 0 self.anime = int(sqlResults[0]["anime"] or 0)
self.sports = int(sqlResults[0]["sports"] or 0)
self.air_by_date = sqlResults[0]["air_by_date"] self.scene = int(sqlResults[0]["scene"] or 0)
if not self.air_by_date: self.subtitles = int(sqlResults[0]["subtitles"] or 0)
self.air_by_date = 0 self.dvdorder = int(sqlResults[0]["dvdorder"] or 0)
self.archive_firstmatch = int(sqlResults[0]["archive_firstmatch"] or 0)
self.anime = sqlResults[0]["anime"] self.quality = int(sqlResults[0]["quality"] or UNKNOWN)
if self.anime == None: self.flatten_folders = int(sqlResults[0]["flatten_folders"] or 0)
self.anime = 0 self.paused = int(sqlResults[0]["paused"] or 0)
self.sports = sqlResults[0]["sports"]
if not self.sports:
self.sports = 0
self.scene = sqlResults[0]["scene"]
if not self.scene:
self.scene = 0
self.subtitles = sqlResults[0]["subtitles"]
if self.subtitles:
self.subtitles = 1
else:
self.subtitles = 0
self.dvdorder = sqlResults[0]["dvdorder"]
if not self.dvdorder:
self.dvdorder = 0
self.archive_firstmatch = sqlResults[0]["archive_firstmatch"]
if not self.archive_firstmatch:
self.archive_firstmatch = 0
self.quality = int(sqlResults[0]["quality"])
self.flatten_folders = int(sqlResults[0]["flatten_folders"])
self.paused = int(sqlResults[0]["paused"])
try: try:
self.location = sqlResults[0]["location"] self.location = sqlResults[0]["location"]
@ -828,9 +808,7 @@ class TVShow(object):
self.rls_ignore_words = sqlResults[0]["rls_ignore_words"] self.rls_ignore_words = sqlResults[0]["rls_ignore_words"]
self.rls_require_words = sqlResults[0]["rls_require_words"] self.rls_require_words = sqlResults[0]["rls_require_words"]
self.default_ep_status = sqlResults[0]["default_ep_status"] self.default_ep_status = int(sqlResults[0]["default_ep_status"] or SKIPPED)
if not self.default_ep_status:
self.default_ep_status = ""
if not self.imdbid: if not self.imdbid:
self.imdbid = sqlResults[0]["imdb_id"] self.imdbid = sqlResults[0]["imdb_id"]
@ -889,6 +867,9 @@ class TVShow(object):
if getattr(myEp, 'airs_dayofweek', None) is not None and getattr(myEp, 'airs_time', None) is not None: if getattr(myEp, 'airs_dayofweek', None) is not None and getattr(myEp, 'airs_time', None) is not None:
self.airs = myEp["airs_dayofweek"] + " " + myEp["airs_time"] self.airs = myEp["airs_dayofweek"] + " " + myEp["airs_time"]
if self.airs is None:
self.airs = ''
if getattr(myEp, 'firstaired', None) is not None: if getattr(myEp, 'firstaired', None) is not None:
self.startyear = int(str(myEp["firstaired"]).split('-')[0]) self.startyear = int(str(myEp["firstaired"]).split('-')[0])
@ -1076,6 +1057,8 @@ class TVShow(object):
try: try:
curEp = self.getEpisode(season, episode) curEp = self.getEpisode(season, episode)
if not curEp:
raise exceptions.EpisodeDeletedException
except exceptions.EpisodeDeletedException: except exceptions.EpisodeDeletedException:
logger.log(u"The episode was deleted while we were refreshing it, moving on to the next one", logger.log(u"The episode was deleted while we were refreshing it, moving on to the next one",
logger.DEBUG) logger.DEBUG)
@ -1106,7 +1089,8 @@ class TVShow(object):
else: else:
# the file exists, set its modify file stamp # the file exists, set its modify file stamp
if sickbeard.AIRDATE_EPISODES: if sickbeard.AIRDATE_EPISODES:
curEp.airdateModifyStamp() with curEp.lock:
curEp.airdateModifyStamp()
if len(sql_l) > 0: if len(sql_l) > 0:
myDB = db.DBConnection() myDB = db.DBConnection()
@ -1747,9 +1731,12 @@ class TVEpisode(object):
# if we don't have the file and the airdate is in the past # if we don't have the file and the airdate is in the past
else: else:
if self.status == UNAIRED: if self.status == UNAIRED:
self.status = WANTED if self.season > 0:
self.status = WANTED
else:
self.status = SKIPPED
# if we somehow are still UNKNOWN then just use the shows defined default status # if we somehow are still UNKNOWN then just use the shows defined default status or SKIPPED
elif self.status == UNKNOWN: elif self.status == UNKNOWN:
self.status = self.show.default_ep_status self.status = self.show.default_ep_status

View File

@ -4160,15 +4160,13 @@ class Home(MainHandler):
try: try:
sickbeard.showQueueScheduler.action.updateShow(showObj, bool(force)) # @UndefinedVariable sickbeard.showQueueScheduler.action.updateShow(showObj, bool(force)) # @UndefinedVariable
except exceptions.CantUpdateException, e: except exceptions.CantUpdateException, e:
ui.notifications.error("Unable to update this show.", ui.notifications.error("Unable to update this show.", ex(e))
ex(e))
# just give it some time # just give it some time
time.sleep(cpu_presets[sickbeard.CPU_PRESET]) time.sleep(cpu_presets[sickbeard.CPU_PRESET])
redirect("/home/displayShow?show=" + str(showObj.indexerid)) redirect("/home/displayShow?show=" + str(showObj.indexerid))
def subtitleShow(self, show=None, force=0): def subtitleShow(self, show=None, force=0):
if show is None: if show is None: