Skip to content

Commit

Permalink
Flip if/else in plex.watchlist
Browse files Browse the repository at this point in the history
Lessens code nesting
  • Loading branch information
glensc committed Apr 24, 2023
1 parent 96b0043 commit 54d07b4
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions plextraktsync/plex/PlexApi.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,17 +240,19 @@ def account(self):
return None

def watchlist(self, libtype=None) -> list[Movie | Show] | None:
if self.account:
params = {
'includeCollections': 0,
'includeExternalMedia': 0,
'includeUserState': 0,
}
try:
return self.account.watchlist(libtype=libtype, **params)
except BadRequest as e:
logger.error(f"Error during {self.account.username} watchlist access: {e}")
return None
if not self.account:
return None

params = {
'includeCollections': 0,
'includeExternalMedia': 0,
'includeUserState': 0,
}
try:
return self.account.watchlist(libtype=libtype, **params)
except BadRequest as e:
logger.error(f"Error during {self.account.username} watchlist access: {e}")
return None

def add_to_watchlist(self, item):
try:
Expand Down

0 comments on commit 54d07b4

Please sign in to comment.