Skip to content

Commit

Permalink
Merge pull request #4210 from pymedusa/hotfix/fix-change-status
Browse files Browse the repository at this point in the history
Fix changing status from displayShow.
  • Loading branch information
medariox authored May 17, 2018
2 parents 4b9c599 + f887568 commit 212cd1c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions medusa/server/web/home/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
sab,
)
from medusa.common import (
ARCHIVED,
DOWNLOADED,
FAILED,
IGNORED,
Expand Down Expand Up @@ -1915,7 +1916,11 @@ def setStatus(self, indexername=None, seriesid=None, eps=None, status=None, dire
else:
return self._genericMessage('Error', error_message)

# Use .has_key() since it is overridden for statusStrings in common.py
# statusStrings is a custom type. Which does some "magic" itself. But we want to move away from this.
# FIXME: Always check status with status and quality with quality.
status_with_quality = status
status = Quality.split_composite_status(status).status

if status not in statusStrings:
error_message = 'Invalid status'
if direct:
Expand Down Expand Up @@ -1977,7 +1982,7 @@ def setStatus(self, indexername=None, seriesid=None, eps=None, status=None, dire

snatched_qualities = Quality.SNATCHED + Quality.SNATCHED_PROPER + Quality.SNATCHED_BEST

if status in Quality.DOWNLOADED and not (
if status == DOWNLOADED and not (
ep_obj.status in snatched_qualities + Quality.DOWNLOADED
and os.path.isfile(ep_obj.location)):
logger.log('Refusing to change status of {series} {episode} to DOWNLOADED'
Expand Down Expand Up @@ -2006,8 +2011,7 @@ def setStatus(self, indexername=None, seriesid=None, eps=None, status=None, dire
# Only in failed_history we set to FAILED.
# We need current snatched quality to log 'quality' column in failed action in history
if status != FAILED:
# We're only setting the status (leaving the quality as is).
ep_obj.splitted_status_status = status
ep_obj.status = status_with_quality

# mass add to database
sql_l.append(ep_obj.get_sql())
Expand All @@ -2019,7 +2023,7 @@ def setStatus(self, indexername=None, seriesid=None, eps=None, status=None, dire
if app.USE_TRAKT and app.TRAKT_SYNC_WATCHLIST:
if status in [WANTED, FAILED]:
upd = 'Add'
elif status in [IGNORED, SKIPPED] + Quality.DOWNLOADED + Quality.ARCHIVED:
elif status in [IGNORED, SKIPPED, DOWNLOADED, ARCHIVED]:
upd = 'Remove'

logger.log('{action} episodes, showid: indexerid {show.indexerid}, Title {show.name} to Watchlist'.format(
Expand Down

0 comments on commit 212cd1c

Please sign in to comment.