1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-12-13 11:32:20 -05:00

Change API now uses Timezone setting at General Config/Interface/User Interface/ at relevant endpoints

This commit is contained in:
tehspede 2014-11-02 05:55:29 +02:00
parent 5d89270d29
commit ae94ab6d80
2 changed files with 30 additions and 21 deletions

View File

@ -49,6 +49,7 @@
* Fix and repositioned show_message on display show to use bootstrap styling * Fix and repositioned show_message on display show to use bootstrap styling
* Remove commented out html from display show accidently left in during UI changes * Remove commented out html from display show accidently left in during UI changes
* Fix display issue of season tables in displayShow view / Display Specials * Fix display issue of season tables in displayShow view / Display Specials
* Change API now uses Timezone setting at General Config/Interface/User Interface/ at relevant endpoints
### 0.2.1 (2014-10-22 06:41:00 UTC) ### 0.2.1 (2014-10-22 06:41:00 UTC)
@ -79,4 +80,4 @@
### 0.1.0 (2014-10-16 12:35:15 UTC) ### 0.1.0 (2014-10-16 12:35:15 UTC)
* Initial release * Initial release

View File

@ -34,6 +34,7 @@ from sickbeard import search_queue
from sickbeard import image_cache from sickbeard import image_cache
from sickbeard import classes from sickbeard import classes
from sickbeard import processTV from sickbeard import processTV
from sickbeard import network_timezones, sbdatetime
from sickbeard.exceptions import ex from sickbeard.exceptions import ex
from sickbeard.common import SNATCHED, SNATCHED_PROPER, DOWNLOADED, SKIPPED, UNAIRED, IGNORED, ARCHIVED, WANTED, UNKNOWN from sickbeard.common import SNATCHED, SNATCHED_PROPER, DOWNLOADED, SKIPPED, UNAIRED, IGNORED, ARCHIVED, WANTED, UNKNOWN
from common import Quality, qualityPresetStrings, statusStrings from common import Quality, qualityPresetStrings, statusStrings
@ -47,6 +48,7 @@ from lib import subliminal
dateFormat = "%Y-%m-%d" dateFormat = "%Y-%m-%d"
dateTimeFormat = "%Y-%m-%d %H:%M" dateTimeFormat = "%Y-%m-%d %H:%M"
timeFormat = '%A %I:%M %p'
RESULT_SUCCESS = 10 # only use inside the run methods RESULT_SUCCESS = 10 # only use inside the run methods
RESULT_FAILURE = 20 # only use inside the run methods RESULT_FAILURE = 20 # only use inside the run methods
@ -773,6 +775,10 @@ class CMD_ComingEpisodes(ApiCall):
if ep["paused"] and not self.paused: if ep["paused"] and not self.paused:
continue continue
ep['airs'] = str(ep['airs']).replace('am', ' AM').replace('pm', ' PM').replace(' ', ' ')
dtEpisodeAirs = network_timezones.parse_date_time(int(ep['airdate']), ep['airs'], ep['network'])
ep['airdate'] = dtEpisodeAirs.toordinal()
status = "soon" status = "soon"
if ep["airdate"] < today: if ep["airdate"] < today:
status = "missed" status = "missed"
@ -785,20 +791,20 @@ class CMD_ComingEpisodes(ApiCall):
status = "soon" status = "soon"
# skip unwanted # skip unwanted
if self.type != None and not status in self.type: if self.type is not None and not status in self.type:
continue continue
ordinalAirdate = int(ep["airdate"])
if not ep["network"]: if not ep["network"]:
ep["network"] = "" ep["network"] = ""
ep["airdate"] = _ordinal_to_dateForm(ordinalAirdate)
ep["quality"] = _get_quality_string(ep["quality"]) ep["quality"] = _get_quality_string(ep["quality"])
# clean up tvdb horrible airs field # clean up tvdb horrible airs field
ep["airs"] = str(ep["airs"]).replace('am', ' AM').replace('pm', ' PM').replace(' ', ' ') ep['airs'] = sbdatetime.sbdatetime.sbftime(dtEpisodeAirs, t_preset=timeFormat).lstrip('0').replace(' 0', ' ')
# start day of the week on 1 (monday) # start day of the week on 1 (monday)
ep["weekday"] = 1 + datetime.date.fromordinal(ordinalAirdate).weekday() ep['weekday'] = 1 + datetime.date.fromordinal(dtEpisodeAirs.toordinal()).weekday()
# Add tvdbid for backward compability # Add tvdbid for backward compability
ep["tvdbid"] = ep['indexerid'] ep["tvdbid"] = ep['indexerid']
ep['airdate'] = sbdatetime.sbdatetime.sbfdate(dtEpisodeAirs, d_preset=dateFormat)
# TODO: check if this obsolete # TODO: check if this obsolete
if not status in finalEpResults: if not status in finalEpResults:
@ -860,7 +866,7 @@ class CMD_Episode(ApiCall):
elif not showPath: # show dir is broken ... episode path will be empty elif not showPath: # show dir is broken ... episode path will be empty
episode["location"] = "" episode["location"] = ""
# convert stuff to human form # convert stuff to human form
episode["airdate"] = _ordinal_to_dateForm(episode["airdate"]) episode['airdate'] = sbdatetime.sbdatetime.sbfdate(network_timezones.parse_date_time(int(episode['airdate']), showObj.airs, showObj.network), d_preset=dateFormat)
status, quality = Quality.splitCompositeStatus(int(episode["status"])) status, quality = Quality.splitCompositeStatus(int(episode["status"]))
episode["status"] = _get_status_Strings(status) episode["status"] = _get_status_Strings(status)
episode["quality"] = _get_quality_string(quality) episode["quality"] = _get_quality_string(quality)
@ -1803,13 +1809,12 @@ class CMD_Show(ApiCall):
showDict["network"] = "" showDict["network"] = ""
showDict["status"] = showObj.status showDict["status"] = showObj.status
nextAirdate = showObj.nextaired if showObj.nextaired:
if nextAirdate: dtEpisodeAirs = network_timezones.parse_date_time(showObj.nextaired, showDict['airs'], showDict['network'])
nextAirdate = _ordinal_to_dateForm(nextAirdate) showDict['airs'] = sbdatetime.sbdatetime.sbftime(dtEpisodeAirs, t_preset=timeFormat).lstrip('0').replace(' 0', ' ')
showDict['next_ep_airdate'] = sbdatetime.sbdatetime.sbfdate(dtEpisodeAirs, d_preset=dateFormat)
else: else:
nextAirdate = '' showDict['next_ep_airdate'] = ''
showDict["next_ep_airdate"] = nextAirdate
return _responds(RESULT_SUCCESS, showDict) return _responds(RESULT_SUCCESS, showDict)
@ -2312,7 +2317,8 @@ class CMD_ShowSeasons(ApiCall):
status, quality = Quality.splitCompositeStatus(int(row["status"])) status, quality = Quality.splitCompositeStatus(int(row["status"]))
row["status"] = _get_status_Strings(status) row["status"] = _get_status_Strings(status)
row["quality"] = _get_quality_string(quality) row["quality"] = _get_quality_string(quality)
row["airdate"] = _ordinal_to_dateForm(row["airdate"]) dtEpisodeAirs = network_timezones.parse_date_time(row['airdate'],showObj.airs,showObj.network)
row['airdate'] = sbdatetime.sbdatetime.sbfdate(dtEpisodeAirs, d_preset=dateFormat)
curSeason = int(row["season"]) curSeason = int(row["season"])
curEpisode = int(row["episode"]) curEpisode = int(row["episode"])
del row["season"] del row["season"]
@ -2334,7 +2340,8 @@ class CMD_ShowSeasons(ApiCall):
status, quality = Quality.splitCompositeStatus(int(row["status"])) status, quality = Quality.splitCompositeStatus(int(row["status"]))
row["status"] = _get_status_Strings(status) row["status"] = _get_status_Strings(status)
row["quality"] = _get_quality_string(quality) row["quality"] = _get_quality_string(quality)
row["airdate"] = _ordinal_to_dateForm(row["airdate"]) dtEpisodeAirs = network_timezones.parse_date_time(row['airdate'], showObj.airs, showObj.network)
row['airdate'] = sbdatetime.sbdatetime.sbfdate(dtEpisodeAirs, d_preset=dateFormat)
if not curEpisode in seasons: if not curEpisode in seasons:
seasons[curEpisode] = {} seasons[curEpisode] = {}
seasons[curEpisode] = row seasons[curEpisode] = row
@ -2556,11 +2563,6 @@ class CMD_Shows(ApiCall):
""" display_is_int_multi( self.indexerid )shows in sickbeard """ """ display_is_int_multi( self.indexerid )shows in sickbeard """
shows = {} shows = {}
for curShow in sickbeard.showList: for curShow in sickbeard.showList:
nextAirdate = curShow.nextaired
if nextAirdate:
nextAirdate = _ordinal_to_dateForm(nextAirdate)
else:
nextAirdate = ''
if self.paused != None and bool(self.paused) != bool(curShow.paused): if self.paused != None and bool(self.paused) != bool(curShow.paused):
continue continue
@ -2580,9 +2582,14 @@ class CMD_Shows(ApiCall):
"show_name": curShow.name, "show_name": curShow.name,
"status": curShow.status, "status": curShow.status,
"subtitles": curShow.subtitles, "subtitles": curShow.subtitles,
"next_ep_airdate": nextAirdate
} }
if curShow.nextaired:
dtEpisodeAirs = network_timezones.parse_date_time(curShow.nextaired, curShow.airs, showDict['network'])
showDict['next_ep_airdate'] = sbdatetime.sbdatetime.sbfdate(dtEpisodeAirs, d_preset=dateFormat)
else:
showDict['next_ep_airdate'] = ''
showDict["cache"] = CMD_ShowCache(self.handler, (), {"indexerid": curShow.indexerid}).run()["data"] showDict["cache"] = CMD_ShowCache(self.handler, (), {"indexerid": curShow.indexerid}).run()["data"]
if not showDict["network"]: if not showDict["network"]:
showDict["network"] = "" showDict["network"] = ""
@ -2590,6 +2597,7 @@ class CMD_Shows(ApiCall):
shows[curShow.name] = showDict shows[curShow.name] = showDict
else: else:
shows[curShow.indexerid] = showDict shows[curShow.indexerid] = showDict
return _responds(RESULT_SUCCESS, shows) return _responds(RESULT_SUCCESS, shows)