Repository: pymedusa/Medusa

Issue:
Cannot change episode status


Branch: masterCommit: 4b9c599a461dae200a1cdd4d53ede28619c3151fVersion: v0.2.3Database: 44.9
--
Python Version: | 2.7.9 (default, Aug 13 2016, 17:56:53) [GCC 4.9.2]
SSL Version: | OpenSSL 1.0.1t 3 May 2016
OS: | Linux-4.9.61+-armv7l-with-debian-8.10
Locale: | en_GB.UTF-8

Since the most recent update I can no longer change episode status to archived - I get "Error - invalid status". Nothing in the logs that looks relevant. 


Discussion:
jip, hotfix incoming.
tnx for reporting

Resolving patch:
diff --git a/medusa/server/web/home/handler.py b/medusa/server/web/home/handler.py
--- a/medusa/server/web/home/handler.py
+++ b/medusa/server/web/home/handler.py
@@ -32,6 +32,7 @@
     sab,
 )
 from medusa.common import (
+    ARCHIVED,
     DOWNLOADED,
     FAILED,
     IGNORED,
@@ -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:
@@ -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'
@@ -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())
@@ -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(


Test patch: