From 55ca69310902cdf717e6e3c71cbbe690207db8dd Mon Sep 17 00:00:00 2001 From: JackDandy Date: Sat, 24 Sep 2016 03:29:06 +0100 Subject: [PATCH] Fix status reset of a snatched, downloaded, or archived episode when its date is set to never (no date) on the info source and there is no media file. --- CHANGES.md | 2 ++ sickbeard/tv.py | 45 ++++++++++++++++++++++++--------------------- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index ab358454..fd16d7e5 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -164,6 +164,8 @@ * Change when using "Add new show" reduce search time outs * Change always allow incomplete show data * Remove redundant config/general/"Allow incomplete show data" +* Fix status reset of a snatched, downloaded, or archived episode when its date is set to never (no date) on the info + source and there is no media file [develop changelog] * Change send nzb data to NZBGet for Anizb instead of url diff --git a/sickbeard/tv.py b/sickbeard/tv.py index 028411bb..22b2d36f 100644 --- a/sickbeard/tv.py +++ b/sickbeard/tv.py @@ -1836,30 +1836,30 @@ class TVEpisode(object): # if we don't have the file if not ek.ek(os.path.isfile, self.location): - today = datetime.date.today() - delta = datetime.timedelta(days=1) - show_time = network_timezones.parse_date_time(self.airdate.toordinal(), self.show.airs, self.show.network) - show_length = datetime.timedelta(minutes=helpers.tryInt(self.show.runtime, 60)) - tz_now = datetime.datetime.now(network_timezones.sb_timezone) - future_airtime = (self.airdate > (today + delta) or - (not self.airdate < (today - delta) and ((show_time + show_length) > tz_now))) + if self.status in [SKIPPED, UNAIRED, UNKNOWN, WANTED]: + today = datetime.date.today() + delta = datetime.timedelta(days=1) + show_time = network_timezones.parse_date_time(self.airdate.toordinal(), self.show.airs, self.show.network) + show_length = datetime.timedelta(minutes=helpers.tryInt(self.show.runtime, 60)) + tz_now = datetime.datetime.now(network_timezones.sb_timezone) + future_airtime = (self.airdate > (today + delta) or + (not self.airdate < (today - delta) and ((show_time + show_length) > tz_now))) - # if this episode hasn't aired yet set the status to UNAIRED - if future_airtime and self.status in [SKIPPED, UNAIRED, UNKNOWN, WANTED]: - msg = 'Episode airs in the future, marking it %s' - self.status = UNAIRED - - # if there's no airdate then set it to unaired (and respect ignored) - elif self.airdate == datetime.date.fromordinal(1): - if IGNORED == self.status: - msg = 'Episode has no air date and marked %s, no change' - else: - msg = 'Episode has no air date, marking it %s' + # if this episode hasn't aired yet set the status to UNAIRED + if future_airtime: + msg = 'Episode airs in the future, marking it %s' self.status = UNAIRED - # if the airdate is in the past - else: - if UNAIRED == self.status: + # if there's no airdate then set it to unaired (and respect ignored) + elif self.airdate == datetime.date.fromordinal(1): + if IGNORED == self.status: + msg = 'Episode has no air date and marked %s, no change' + else: + msg = 'Episode has no air date, marking it %s' + self.status = UNAIRED + + # if the airdate is in the past + elif UNAIRED == self.status: msg = ('Episode status %s%s, with air date in the past, marking it ' % ( statusStrings[self.status], ','.join([(' is a special', '')[0 < self.season], ('', ' is paused')[self.show.paused]])) + '%s') @@ -1876,6 +1876,9 @@ class TVEpisode(object): else: msg = 'Not touching episode status %s, with air date in the past, because there is no file' + else: + msg = 'Not touching episode status %s, because there is no file' + logger.log(msg % statusStrings[self.status], logger.DEBUG) # if we have a media file then it's downloaded