Commit 1cec8208 authored by echel0n's avatar echel0n
Browse files

legacy API v1 endpoint episode.setstatus will now only backlog wanted episodes...

legacy API v1 endpoint episode.setstatus will now only backlog wanted episodes after its performed unaired and downloaded status checks
parent 64a8d4e4
...@@ -847,9 +847,8 @@ class CMD_EpisodeSetStatus(ApiV1Handler): ...@@ -847,9 +847,8 @@ class CMD_EpisodeSetStatus(ApiV1Handler):
# get all episode numbers in specified season # get all episode numbers in specified season
ep_list = [x for x in show_obj.episodes if x.season == self.s] ep_list = [x for x in show_obj.episodes if x.season == self.s]
def _epResult(result_code, ep, msg=""): def _ep_result(result_code, ep, msg=""):
return {'season': ep.season, 'episode': ep.episode, 'status': ep.status.display_name, return {'season': ep.season, 'episode': ep.episode, 'status': ep.status.display_name, 'result': result_type_map[result_code], 'message': msg}
'result': result_type_map[result_code], 'message': msg}
ep_results = [] ep_results = []
failure = False failure = False
...@@ -857,31 +856,31 @@ class CMD_EpisodeSetStatus(ApiV1Handler): ...@@ -857,31 +856,31 @@ class CMD_EpisodeSetStatus(ApiV1Handler):
wanted = [] wanted = []
for epObj in ep_list: for epObj in ep_list:
if self.status == EpisodeStatus.WANTED:
# figure out what episodes are wanted so we can backlog them
wanted += [(epObj.season, epObj.episode)]
# don't let them mess up UNAIRED episodes # don't let them mess up UNAIRED episodes
if epObj.status == EpisodeStatus.UNAIRED: if epObj.status == EpisodeStatus.UNAIRED:
if self.e is not None: if self.e is not None:
ep_results.append(_epResult(RESULT_FAILURE, epObj, "Refusing to change status because it is UNAIRED")) ep_results.append(_ep_result(RESULT_FAILURE, epObj, "Refusing to change status because it is UNAIRED"))
failure = True failure = True
continue continue
# allow the user to force setting the status for an already downloaded episode # allow the user to force setting the status for an already downloaded episode
if epObj.status in flatten( if epObj.status in flatten(
[EpisodeStatus.composites(EpisodeStatus.DOWNLOADED), EpisodeStatus.composites(EpisodeStatus.ARCHIVED)]) and not self.force: [EpisodeStatus.composites(EpisodeStatus.DOWNLOADED), EpisodeStatus.composites(EpisodeStatus.ARCHIVED)]) and not self.force:
ep_results.append(_epResult(RESULT_FAILURE, epObj, "Refusing to change status because it is already marked as DOWNLOADED")) ep_results.append(_ep_result(RESULT_FAILURE, epObj, "Refusing to change status because it is already marked as DOWNLOADED"))
failure = True failure = True
continue continue
if self.status == EpisodeStatus.WANTED:
# figure out what episodes are wanted so we can backlog them
wanted += [(epObj.season, epObj.episode)]
epObj.status = self.status epObj.status = self.status
epObj.save() epObj.save()
if self.status == EpisodeStatus.WANTED: if self.status == EpisodeStatus.WANTED:
start_backlog = True start_backlog = True
ep_results.append(_epResult(RESULT_SUCCESS, epObj)) ep_results.append(_ep_result(RESULT_SUCCESS, epObj))
extra_msg = "" extra_msg = ""
if start_backlog: if start_backlog:
......
Supports Markdown
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