Skip to content

Commit

Permalink
Merge pull request #54 from luigi311/dev
Browse files Browse the repository at this point in the history
Fix variable overwrites, Fix errors when plex user has no access
  • Loading branch information
luigi311 authored Mar 22, 2023
2 parents fd64088 + 962b114 commit c69d598
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 11 deletions.
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ ENV PLEX_SERVERNAME ''
ENV JELLYFIN_BASEURL ''
ENV JELLYFIN_TOKEN ''

ENV SYNC_FROM_PLEX_TO_JELLYFIN 'True'
ENV SYNC_FROM_JELLYFIN_TO_PLEX 'True'
ENV SYNC_FROM_PLEX_TO_PLEX 'True'
ENV SYNC_FROM_JELLYFIN_TO_JELLYFIN 'True'

ENV BLACKLIST_LIBRARY ''
ENV WHITELIST_LIBRARY ''
ENV BLACKLIST_LIBRARY_TYPE ''
Expand Down
4 changes: 2 additions & 2 deletions src/jellyfin.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,8 @@ async def get_watched(

watched = await asyncio.gather(*watched, return_exceptions=True)
for user_watched in watched:
user_watched_temp = combine_watched_dicts(user_watched)
for user, user_watched_temp in user_watched_temp.items():
user_watched_combine = combine_watched_dicts(user_watched)
for user, user_watched_temp in user_watched_combine.items():
if user not in users_watched:
users_watched[user] = {}
users_watched[user].update(user_watched_temp)
Expand Down
35 changes: 26 additions & 9 deletions src/plex.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,19 @@ def get_watched(
if self.admin_user == user:
user_plex = self.plex
else:
user_plex = self.login(
self.plex._baseurl,
user.get_token(self.plex.machineIdentifier),
)
token = user.get_token(self.plex.machineIdentifier)
if token:
user_plex = self.login(
self.plex._baseurl,
token,
)
else:
logger(
f"Plex: Failed to get token for {user.title}, skipping",
2,
)
users_watched[user.title] = {}
continue

libraries = user_plex.library.sections()

Expand Down Expand Up @@ -380,11 +389,19 @@ def update_watched(
)
user = self.plex.myPlexAccount().user(user)

user_plex = PlexServer(
self.plex._baseurl,
user.get_token(self.plex.machineIdentifier),
session=self.session,
)
token = user.get_token(self.plex.machineIdentifier)
if token:
user_plex = PlexServer(
self.plex._baseurl,
token,
session=self.session,
)
else:
logger(
f"Plex: Failed to get token for {user.title}, skipping",
2,
)
continue

for library, videos in libraries.items():
library_other = None
Expand Down

0 comments on commit c69d598

Please sign in to comment.