Skip to content

Commit

Permalink
Plex: Fix guids error on mark
Browse files Browse the repository at this point in the history
  • Loading branch information
luigi311 committed Feb 26, 2023
1 parent 2180372 commit b960bcc
Showing 1 changed file with 26 additions and 20 deletions.
46 changes: 26 additions & 20 deletions src/plex.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import re, requests, os
import re, requests, os, traceback
from urllib3.poolmanager import PoolManager

from plexapi.server import PlexServer
Expand Down Expand Up @@ -52,7 +52,7 @@ def get_user_library_watched_show(show):
except:
logger(
f"Plex: Failed to get guids for {episode.title} in {show.title}, Using location only",
4,
1,
)

episode_guids_temp["locations"] = tuple(
Expand Down Expand Up @@ -223,24 +223,30 @@ def update_user_watched(user, user_plex, library, videos, dryrun):
break

if not episode_found:
for episode_guid in episode_search.guids:
episode_guid_source = (
re.search(r"(.*)://", episode_guid.id)
.group(1)
.lower()
try:
for episode_guid in episode_search.guids:
episode_guid_source = (
re.search(r"(.*)://", episode_guid.id)
.group(1)
.lower()
)
episode_guid_id = re.search(
r"://(.*)", episode_guid.id
).group(1)

# If episode provider source and episode provider id are in videos_episodes_ids exactly, then the episode is in the list
if episode_guid_source in videos_episodes_ids.keys():
if (
episode_guid_id
in videos_episodes_ids[episode_guid_source]
):
episode_found = True
break
except Exception as e:
logger(
f"Plex: Failed to get episode guid for {episode_search.title}, Error: {e}",
1,
)
episode_guid_id = re.search(
r"://(.*)", episode_guid.id
).group(1)

# If episode provider source and episode provider id are in videos_episodes_ids exactly, then the episode is in the list
if episode_guid_source in videos_episodes_ids.keys():
if (
episode_guid_id
in videos_episodes_ids[episode_guid_source]
):
episode_found = True
break

if episode_found:
msg = f"{show_search.title} {episode_search.title} as watched for {user.title} in {library} for Plex"
Expand Down Expand Up @@ -271,7 +277,7 @@ def update_user_watched(user, user_plex, library, videos, dryrun):
f"Plex: Failed to update watched for {user.title} in library {library}, Error: {e}",
2,
)
raise Exception(e)
logger(traceback.format_exc(), 2)


# class plex accept base url and token and username and password but default with none
Expand Down

0 comments on commit b960bcc

Please sign in to comment.