Commit 4fff22ec authored by echel0n's avatar echel0n

Refactored misc API function names.

parent 8e81cad6
# Changelog
- * b21c682 - 2018-11-18: Refactored code for API builder to display full URL.
- * b0b6ddd - 2018-11-18: Refactored misc API function names.
- * 8e81cad - 2018-11-18: Refactored code for API builder to display full URL.
- * eff3ee9 - 2018-11-17: Fixed freebsd init script, runs as sickrage user
- * 0aa52f3 - 2018-11-17: Release v9.4.38
- * ee79b9e - 2018-11-17: Release v9.4.37
......
......@@ -495,11 +495,11 @@ def _responds(result_type, data=None, msg=""):
return {"result": result_type_map[result_type], "message": msg, "data": data}
def _get_status_Strings(s):
def _get_status_strings(s):
return statusStrings[s]
def _ordinal_to_dateTimeForm(ordinal):
def _ordinal_to_datetime_form(ordinal):
# workaround for episodes with no airdate
if int(ordinal) != 1:
date = datetime.datetime.now().date().fromordinal(ordinal)
......@@ -508,7 +508,7 @@ def _ordinal_to_dateTimeForm(ordinal):
return date.strftime(dateTimeFormat)
def _ordinal_to_dateForm(ordinal):
def _ordinal_to_date_form(ordinal):
if int(ordinal) != 1:
date = datetime.datetime.now().date().fromordinal(ordinal)
else:
......@@ -517,28 +517,26 @@ def _ordinal_to_dateForm(ordinal):
return date.strftime(dateFormat)
def _historyDate_to_dateTimeForm(timeString):
def _history_date_to_datetime_form(timeString):
date = datetime.datetime.strptime(timeString, History.date_format)
return date.strftime(dateTimeFormat)
def _mapQuality(showObj):
quality_map = _getQualityMap()
def _map_quality(showObj):
quality_map = _get_quality_map()
anyQualities = []
bestQualities = []
iqualityID, aqualityID = Quality.splitQuality(int(showObj))
if iqualityID:
for quality in iqualityID:
anyQualities.append(quality_map[quality])
if aqualityID:
for quality in aqualityID:
bestQualities.append(quality_map[quality])
for quality in iqualityID:
anyQualities.append(quality_map[quality])
for quality in aqualityID:
bestQualities.append(quality_map[quality])
return anyQualities, bestQualities
def _getQualityMap():
def _get_quality_map():
return {Quality.SDTV: 'sdtv',
Quality.SDDVD: 'sddvd',
Quality.HDTV: 'hdtv',
......@@ -548,10 +546,16 @@ def _getQualityMap():
Quality.FULLHDWEBDL: 'fullhdwebdl',
Quality.HDBLURAY: 'hdbluray',
Quality.FULLHDBLURAY: 'fullhdbluray',
Quality.UHD_4K_TV: 'uhd4ktv',
Quality.UHD_4K_BLURAY: '4kbluray',
Quality.UHD_4K_WEBDL: '4kwebdl',
Quality.UHD_8K_TV: 'uhd8ktv',
Quality.UHD_8K_BLURAY: 'uhd8kbluray',
Quality.UHD_8K_WEBDL: 'udh8kwebdl',
Quality.UNKNOWN: 'unknown'}
def _getRootDirs():
def _get_root_dirs():
if sickrage.app.config.root_dirs == "":
return {}
......@@ -761,7 +765,7 @@ class CMD_Episode(ApiCall):
episode['airdate'] = 'Never'
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["file_size_human"] = pretty_filesize(episode["file_size"])
......@@ -868,7 +872,7 @@ class CMD_EpisodeSetStatus(ApiCall):
ep_list = showObj.get_all_episodes(season=self.s)
def _epResult(result_code, ep, msg=""):
return {'season': ep.season, 'episode': ep.episode, 'status': _get_status_Strings(ep.status),
return {'season': ep.season, 'episode': ep.episode, 'status': _get_status_strings(ep.status),
'result': result_type_map[result_code], 'message': msg}
ep_results = []
......@@ -1037,14 +1041,14 @@ class CMD_History(ApiCall):
for row in data:
status, quality = Quality.splitCompositeStatus(int(row["action"]))
status = _get_status_Strings(status)
status = _get_status_strings(status)
if self.type and not status.lower() == self.type:
continue
row["status"] = status
row["quality"] = get_quality_string(quality)
row["date"] = _historyDate_to_dateTimeForm(str(row["date"]))
row["date"] = _history_date_to_datetime_form(str(row["date"]))
del row["action"]
......@@ -1317,7 +1321,7 @@ class CMD_SiCKRAGEAddRootDir(ApiCall):
root_dirs_new = '|'.join(x for x in root_dirs_new)
sickrage.app.config.root_dirs = root_dirs_new
return _responds(RESULT_SUCCESS, _getRootDirs(), msg="Root directories updated")
return _responds(RESULT_SUCCESS, _get_root_dirs(), msg="Root directories updated")
class CMD_SiCKRAGECheckVersion(ApiCall):
......@@ -1360,7 +1364,7 @@ class CMD_SiCKRAGECheckScheduler(ApiCall):
sickrage.app.sys_encoding)
data = {"backlog_is_paused": int(backlogPaused), "backlog_is_running": int(backlogRunning),
"last_backlog": _ordinal_to_dateForm(last_backlog),
"last_backlog": _ordinal_to_date_form(last_backlog),
"next_backlog": nextBacklog}
return _responds(RESULT_SUCCESS, data)
......@@ -1379,7 +1383,7 @@ class CMD_SiCKRAGEDeleteRootDir(ApiCall):
def run(self):
""" Delete a root (parent) directory from SiCKRAGE """
if sickrage.app.config.root_dirs == "":
return _responds(RESULT_FAILURE, _getRootDirs(), msg="No root directories detected")
return _responds(RESULT_FAILURE, _get_root_dirs(), msg="No root directories detected")
newIndex = 0
root_dirs_new = []
......@@ -1407,7 +1411,7 @@ class CMD_SiCKRAGEDeleteRootDir(ApiCall):
sickrage.app.config.root_dirs = root_dirs_new
# what if the root dir was not found?
return _responds(RESULT_SUCCESS, _getRootDirs(), msg="Root directory deleted")
return _responds(RESULT_SUCCESS, _get_root_dirs(), msg="Root directory deleted")
class CMD_SiCKRAGEGetDefaults(ApiCall):
......@@ -1420,7 +1424,7 @@ class CMD_SiCKRAGEGetDefaults(ApiCall):
def run(self):
""" Get SiCKRAGE's user default configuration value """
anyQualities, bestQualities = _mapQuality(sickrage.app.config.quality_default)
anyQualities, bestQualities = _map_quality(sickrage.app.config.quality_default)
data = {"status": statusStrings[sickrage.app.config.status_default].lower(),
"flatten_folders": int(sickrage.app.config.flatten_folders_default), "initial": anyQualities,
......@@ -1454,7 +1458,7 @@ class CMD_SiCKRAGEGetRootDirs(ApiCall):
def run(self):
""" Get all root (parent) directories """
return _responds(RESULT_SUCCESS, _getRootDirs())
return _responds(RESULT_SUCCESS, _get_root_dirs())
class CMD_SiCKRAGEPauseDaily(ApiCall):
......@@ -1796,7 +1800,7 @@ class CMD_Show(ApiCall):
showDict["genre"] = genreList
showDict["quality"] = get_quality_string(showObj.quality)
anyQualities, bestQualities = _mapQuality(showObj.quality)
anyQualities, bestQualities = _map_quality(showObj.quality)
showDict["quality_details"] = {"initial": anyQualities, "archive": bestQualities}
showDict["location"] = showObj.location
......@@ -2208,7 +2212,7 @@ class CMD_ShowGetQuality(ApiCall):
if not showObj:
return _responds(RESULT_FAILURE, msg="Show not found")
anyQualities, bestQualities = _mapQuality(showObj.quality)
anyQualities, bestQualities = _map_quality(showObj.quality)
return _responds(RESULT_SUCCESS, {"initial": anyQualities, "archive": bestQualities})
......@@ -2434,7 +2438,7 @@ class CMD_ShowSeasons(ApiCall):
for row in sickrage.app.main_db.get_many('tv_episodes', self.indexerid):
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)
if try_int(row['airdate'], 1) > 693595: # 1900
......@@ -2468,7 +2472,7 @@ class CMD_ShowSeasons(ApiCall):
curEpisode = int(row["episode"])
del row["episode"]
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)
if try_int(row['airdate'], 1) > 693595: # 1900
dtEpisodeAirs = srdatetime.srDateTime(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment