Jellyfin/Plex: Log when guid items are missing
This commit is contained in:
@@ -25,23 +25,34 @@ generate_locations = str_to_bool(os.getenv("GENERATE_LOCATIONS", "True"))
|
|||||||
|
|
||||||
|
|
||||||
def get_guids(item):
|
def get_guids(item):
|
||||||
guids = {"title": item["Name"]}
|
if item.get("Name"):
|
||||||
|
guids = {"title": item.get("Name")}
|
||||||
|
else:
|
||||||
|
logger(f"Jellyfin: Name not found in {item.get('Id')}", 1)
|
||||||
|
guids = {"title": None}
|
||||||
|
|
||||||
if "ProviderIds" in item:
|
if "ProviderIds" in item:
|
||||||
guids.update({k.lower(): v for k, v in item["ProviderIds"].items()})
|
guids.update({k.lower(): v for k, v in item["ProviderIds"].items()})
|
||||||
|
else:
|
||||||
|
logger(f"Jellyfin: ProviderIds not found in {item.get('Name')}", 1)
|
||||||
|
|
||||||
if "MediaSources" in item:
|
if "MediaSources" in item:
|
||||||
guids["locations"] = tuple(
|
guids["locations"] = tuple(
|
||||||
[x["Path"].split("/")[-1] for x in item["MediaSources"] if "Path" in x]
|
[x["Path"].split("/")[-1] for x in item["MediaSources"] if "Path" in x]
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
logger(f"Jellyfin: MediaSources not found in {item.get('Name')}", 1)
|
||||||
guids["locations"] = tuple()
|
guids["locations"] = tuple()
|
||||||
|
|
||||||
guids["status"] = {
|
if "UserData" in item:
|
||||||
"completed": item["UserData"]["Played"],
|
guids["status"] = {
|
||||||
# Convert ticks to milliseconds to match Plex
|
"completed": item["UserData"]["Played"],
|
||||||
"time": floor(item["UserData"]["PlaybackPositionTicks"] / 10000),
|
# Convert ticks to milliseconds to match Plex
|
||||||
}
|
"time": floor(item["UserData"]["PlaybackPositionTicks"] / 10000),
|
||||||
|
}
|
||||||
|
else:
|
||||||
|
logger(f"Jellyfin: UserData not found in {item.get('Name')}", 1)
|
||||||
|
guids["status"] = {}
|
||||||
|
|
||||||
return guids
|
return guids
|
||||||
|
|
||||||
|
|||||||
13
src/plex.py
13
src/plex.py
@@ -64,6 +64,19 @@ def extract_guids_from_item(item: Union[Movie, Show, Episode]) -> Dict[str, str]
|
|||||||
|
|
||||||
|
|
||||||
def get_guids(item: Union[Movie, Episode], completed=True):
|
def get_guids(item: Union[Movie, Episode], completed=True):
|
||||||
|
if not item.locations:
|
||||||
|
logger(
|
||||||
|
f"Plex: {item.title} has no locations",
|
||||||
|
1,
|
||||||
|
)
|
||||||
|
|
||||||
|
if not item.guids:
|
||||||
|
logger(
|
||||||
|
f"Plex: {item.title} has no guids",
|
||||||
|
1,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"title": item.title,
|
"title": item.title,
|
||||||
"locations": (
|
"locations": (
|
||||||
|
|||||||
Reference in New Issue
Block a user