1
0
mirror of https://github.com/moparisthebest/SickRage synced 2025-01-05 10:58:01 -05:00

Fixed issues with randomly returned empty show statuses, added tvrage status mapping to ensure it never gets returned incorrectly.

This commit is contained in:
echel0n 2014-12-13 11:06:33 -08:00
parent 1ff906f3ff
commit 9000dbd10a
5 changed files with 34 additions and 9 deletions

View File

@ -601,7 +601,7 @@ $myShowList.sort(lambda x, y: cmp(x.name, y.name))
</td>
<td align="center">
<img src="$sbRoot/images/#if int($curShow.paused) == 0 and $curShow.status != "Ended" then "yes16.png\" alt=\"Y\"" else "no16.png\" alt=\"N\""# width="16" height="16" />
<img src="$sbRoot/images/#if int($curShow.paused) == 0 and $curShow.status == "Continuing" then "yes16.png\" alt=\"Y\"" else "no16.png\" alt=\"N\""# width="16" height="16" />
</td>
<td align="center">

View File

@ -27,7 +27,7 @@
#set $sql_result = $myDB.select($sql_statement)
#set $shows_total = len($sickbeard.showList)
#set $shows_active = len([show for show in $sickbeard.showList if show.paused == 0 and show.status != "Ended"])
#set $shows_active = len([show for show in $sickbeard.showList if show.paused == 0 and show.status == "Continuing"])
#if $sql_result:
#set $ep_snatched = $sql_result[0]['ep_snatched']

View File

@ -439,6 +439,22 @@ class TVRage:
'seasonnum': 'episodenumber'
}
status_map = {
'returning series': 'Continuing',
'canceled/ended': 'Ended',
'tbd/on the bubble': 'Continuing',
'in development': 'Continuing',
'new series': 'Continuing',
'never aired': 'Ended',
'final season': 'Continuing',
'on hiatus': 'Continuing',
'pilot ordered': 'Continuing',
'pilot rejected': 'Ended',
'canceled': 'Ended',
'ended': 'Ended',
'': 'Unknown',
}
try:
key = name_map[key.lower()]
except (ValueError, TypeError, KeyError):
@ -447,8 +463,17 @@ class TVRage:
# clean up value and do type changes
if value:
if isinstance(value, dict):
if key == 'status':
try:
value = status_map[str(value).lower()]
if not value:
raise
except:
value = 'Unknown'
if key == 'network':
value = value['#text']
if key == 'genre':
value = value['genre']
if not value:
@ -457,6 +482,7 @@ class TVRage:
value = [value]
value = filter(None, value)
value = '|' + '|'.join(value) + '|'
try:
if key == 'firstaired' and value in "0000-00-00":
new_value = str(dt.date.fromordinal(1))

View File

@ -82,7 +82,7 @@ class TVShow(object):
self._imdb_info = {}
self._quality = int(sickbeard.QUALITY_DEFAULT)
self._flatten_folders = int(sickbeard.FLATTEN_FOLDERS_DEFAULT)
self._status = ""
self._status = "Unknown"
self._airs = ""
self._startyear = 0
self._paused = 0
@ -282,7 +282,7 @@ class TVShow(object):
def should_update(self, update_date=datetime.date.today()):
# if show is not 'Ended' always update (status 'Continuing')
if not self.status or 'Ended' not in self.status:
if 'Unknown' not in self.status and 'Ended' not in self.status:
return True
# run logic against the current show latest aired and next unaired data to see if we should bypass 'Ended' status
@ -776,7 +776,7 @@ class TVShow(object):
self.status = sqlResults[0]["status"]
if self.status is None:
self.status = ""
self.status = "Unknown"
self.airs = sqlResults[0]["airs"]
if self.airs is None:
@ -873,7 +873,7 @@ class TVShow(object):
if getattr(myEp, 'firstaired', None) is not None:
self.startyear = int(str(myEp["firstaired"]).split('-')[0])
self.status = getattr(myEp, 'status', '')
self.status = getattr(myEp, 'status', 'Unknown')
def loadIMDbInfo(self, imdbapi=None):
@ -1174,8 +1174,7 @@ class TVShow(object):
toReturn += "network: " + self.network + "\n"
if self.airs:
toReturn += "airs: " + self.airs + "\n"
if self.status:
toReturn += "status: " + self.status + "\n"
toReturn += "status: " + self.status + "\n"
toReturn += "startyear: " + str(self.startyear) + "\n"
if self.genre:
toReturn += "genre: " + self.genre + "\n"

View File

@ -2793,7 +2793,7 @@ class CMD_ShowsStats(ApiCall):
today = str(datetime.date.today().toordinal())
stats["shows_total"] = len(sickbeard.showList)
stats["shows_active"] = len(
[show for show in sickbeard.showList if show.paused == 0 and show.status != "Ended"])
[show for show in sickbeard.showList if show.paused == 0 and "Unknown" not in show.status and "Ended" not in show.status])
stats["ep_downloaded"] = myDB.select("SELECT COUNT(*) FROM tv_episodes WHERE status IN (" + ",".join(
[str(show) for show in
Quality.DOWNLOADED + [ARCHIVED]]) + ") AND season != 0 and episode != 0 AND airdate <= " + today + "")[0][