Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Improve message with no plex account #1844

Merged
merged 2 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions plextraktsync/plex/PlexApi.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,23 +186,24 @@ def account(self):
plex_owner_token = CONFIG.get("PLEX_OWNER_TOKEN")
plex_account_token = CONFIG.get("PLEX_ACCOUNT_TOKEN")
plex_username = CONFIG.get("PLEX_USERNAME")
if plex_owner_token:
try:

def try_login():
if plex_owner_token:
plex_owner_account = MyPlexAccount(token=plex_owner_token, session=factory.session)
return plex_owner_account.switchHomeUser(plex_username)
except BadRequest as e:
self.logger.error(f"Error during {plex_username} account access: {e}")
elif plex_account_token:
try:
elif plex_account_token:
return MyPlexAccount(token=plex_account_token, session=factory.session)
except BadRequest as e:
self.logger.error(f"Error during {plex_username} account access: {e}")
else:
try:
else:
return self.server.myPlexAccount()
except BadRequest as e:
self.logger.error(f"Error during {plex_username} account access: {e}")
return None

try:
return try_login()
except BadRequest as e:
self.logger.error(
f"Error during Plex {plex_username} account access: {e}. Try log in with plex-login again"
)

return None

def watchlist(self, libtype=None) -> list[Movie | Show] | None:
if not self.account:
Expand Down
2 changes: 2 additions & 0 deletions plextraktsync/plex/PlexWatchList.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

class PlexWatchList:
def __init__(self, watchlist: list[PlexMedia]):
if watchlist is None:
raise RuntimeError("Plex watchlist is None")
self.watchlist = watchlist

def __iter__(self):
Expand Down
Loading