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):
# get all episode numbers in specified season
ep_list = [x for x in show_obj.episodes if x.season == self.s]
def _epResult(result_code, ep, msg=""):
return {'season': ep.season, 'episode': ep.episode, 'status': ep.status.display_name,
'result': result_type_map[result_code], 'message': msg}
def _ep_result(result_code, ep, msg=""):
return {'season': ep.season, 'episode': ep.episode, 'status': ep.status.display_name, 'result': result_type_map[result_code], 'message': msg}
ep_results = []
failure = False
......@@ -857,31 +856,31 @@ class CMD_EpisodeSetStatus(ApiV1Handler):
wanted = []
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
if epObj.status == EpisodeStatus.UNAIRED:
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
continue
# allow the user to force setting the status for an already downloaded episode
if epObj.status in flatten(
[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
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.save()
if self.status == EpisodeStatus.WANTED:
start_backlog = True
ep_results.append(_epResult(RESULT_SUCCESS, epObj))
ep_results.append(_ep_result(RESULT_SUCCESS, epObj))
extra_msg = ""
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