Return early for invalid media_type
@@ -90,14 +90,14 @@ def remove_from_library(self, media: TraktMedia):
self.remove_from_collection(media)
def remove_from_collection(self, m: TraktMedia):
- if m.media_type in ["movies", "shows"]:
+ if m.media_type not in ["movies", "shows"]:
+ raise ValueError(f"Unsupported media type: {m.media_type}")
+
item = dict(
title=m.title,
year=m.year,
**m.ids,
)
- else:
- raise ValueError(f"Unsupported media type: {m.media_type}")
self.queue.remove_from_collection((m.media_type, item))
@@ -184,26 +184,26 @@ def add_to_collection(self, m, pm: PlexLibraryItem):
self.queue.add_to_collection((m.media_type, item))
def add_to_watchlist(self, m):
- if m.media_type in ["movies", "shows"]:
+ if m.media_type not in ["movies", "shows"]:
+ raise ValueError(f"Unsupported media type for watchlist: {m.media_type}")
+
item = dict(
title=m.title,
year=m.year,
**m.ids,
)
- else:
- raise ValueError(f"Unsupported media type for watchlist: {m.media_type}")
self.queue.add_to_watchlist((m.media_type, item))
def remove_from_watchlist(self, m):
- if m.media_type in ["movies", "shows"]:
+ if m.media_type not in ["movies", "shows"]:
+ raise ValueError(f"Unsupported media type for watchlist: {m.media_type}")
+
item = dict(
title=m.title,
year=m.year,
**m.ids,
)
- else:
- raise ValueError(f"Unsupported media type for watchlist: {m.media_type}")
self.queue.remove_from_watchlist((m.media_type, item))
