Cleanup
This commit is contained in:
@@ -117,7 +117,7 @@ def generate_library_guids_dict(user_list: dict):
|
|||||||
show_output_dict[provider_key.lower()].append(
|
show_output_dict[provider_key.lower()].append(
|
||||||
provider_value.lower()
|
provider_value.lower()
|
||||||
)
|
)
|
||||||
except:
|
except Exception:
|
||||||
logger("Generating show_output_dict failed, skipping", 1)
|
logger("Generating show_output_dict failed, skipping", 1)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -136,7 +136,7 @@ def generate_library_guids_dict(user_list: dict):
|
|||||||
episode_output_dict[episode_key.lower()].append(
|
episode_output_dict[episode_key.lower()].append(
|
||||||
episode_value.lower()
|
episode_value.lower()
|
||||||
)
|
)
|
||||||
except:
|
except Exception:
|
||||||
logger("Generating episode_output_dict failed, skipping", 1)
|
logger("Generating episode_output_dict failed, skipping", 1)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -149,7 +149,7 @@ def generate_library_guids_dict(user_list: dict):
|
|||||||
movies_output_dict[movie_key.lower()].append(movie_location)
|
movies_output_dict[movie_key.lower()].append(movie_location)
|
||||||
else:
|
else:
|
||||||
movies_output_dict[movie_key.lower()].append(movie_value.lower())
|
movies_output_dict[movie_key.lower()].append(movie_value.lower())
|
||||||
except:
|
except Exception:
|
||||||
logger("Generating movies_output_dict failed, skipping", 1)
|
logger("Generating movies_output_dict failed, skipping", 1)
|
||||||
|
|
||||||
return show_output_dict, episode_output_dict, movies_output_dict
|
return show_output_dict, episode_output_dict, movies_output_dict
|
||||||
|
|||||||
@@ -90,12 +90,13 @@ class Jellyfin:
|
|||||||
if library_type == "Movie":
|
if library_type == "Movie":
|
||||||
user_watched[user_name][library_title] = []
|
user_watched[user_name][library_title] = []
|
||||||
watched = await self.query(
|
watched = await self.query(
|
||||||
f"/Users/{user_id}/Items?ParentId={library_id}&Filters=IsPlayed&Fields=ItemCounts,ProviderIds,MediaSources",
|
f"/Users/{user_id}/Items"
|
||||||
|
+ f"?ParentId={library_id}&Filters=IsPlayed&Fields=ItemCounts,ProviderIds,MediaSources",
|
||||||
"get",
|
"get",
|
||||||
session,
|
session,
|
||||||
)
|
)
|
||||||
for movie in watched["Items"]:
|
for movie in watched["Items"]:
|
||||||
if movie["UserData"]["Played"] == True:
|
if movie["UserData"]["Played"] is True:
|
||||||
movie_guids = {}
|
movie_guids = {}
|
||||||
movie_guids["title"] = movie["Name"]
|
movie_guids["title"] = movie["Name"]
|
||||||
if "ProviderIds" in movie:
|
if "ProviderIds" in movie:
|
||||||
@@ -117,7 +118,8 @@ class Jellyfin:
|
|||||||
if library_type == "Series":
|
if library_type == "Series":
|
||||||
user_watched[user_name][library_title] = {}
|
user_watched[user_name][library_title] = {}
|
||||||
watched_shows = await self.query(
|
watched_shows = await self.query(
|
||||||
f"/Users/{user_id}/Items?ParentId={library_id}&isPlaceHolder=false&Fields=ProviderIds,Path,RecursiveItemCount",
|
f"/Users/{user_id}/Items"
|
||||||
|
+ f"?ParentId={library_id}&isPlaceHolder=false&Fields=ProviderIds,Path,RecursiveItemCount",
|
||||||
"get",
|
"get",
|
||||||
session,
|
session,
|
||||||
)
|
)
|
||||||
@@ -137,7 +139,8 @@ class Jellyfin:
|
|||||||
identifiers = {"show_guids": show_guids, "show_id": show["Id"]}
|
identifiers = {"show_guids": show_guids, "show_id": show["Id"]}
|
||||||
task = asyncio.ensure_future(
|
task = asyncio.ensure_future(
|
||||||
self.query(
|
self.query(
|
||||||
f"/Shows/{show['Id']}/Seasons?userId={user_id}&isPlaceHolder=false&Fields=ProviderIds,RecursiveItemCount",
|
f"/Shows/{show['Id']}/Seasons"
|
||||||
|
+ f"?userId={user_id}&isPlaceHolder=false&Fields=ProviderIds,RecursiveItemCount",
|
||||||
"get",
|
"get",
|
||||||
session,
|
session,
|
||||||
frozenset(identifiers.items()),
|
frozenset(identifiers.items()),
|
||||||
@@ -175,7 +178,8 @@ class Jellyfin:
|
|||||||
season_identifiers["season_name"] = season["Name"]
|
season_identifiers["season_name"] = season["Name"]
|
||||||
task = asyncio.ensure_future(
|
task = asyncio.ensure_future(
|
||||||
self.query(
|
self.query(
|
||||||
f"/Shows/{season_identifiers['show_id']}/Episodes?seasonId={season['Id']}&userId={user_id}&isPlaceHolder=false&isPlayed=true&Fields=ProviderIds,MediaSources",
|
f"/Shows/{season_identifiers['show_id']}/Episodes"
|
||||||
|
+ f"?seasonId={season['Id']}&userId={user_id}&isPlaceHolder=false&isPlayed=true&Fields=ProviderIds,MediaSources",
|
||||||
"get",
|
"get",
|
||||||
session,
|
session,
|
||||||
frozenset(season_identifiers.items()),
|
frozenset(season_identifiers.items()),
|
||||||
@@ -187,7 +191,7 @@ class Jellyfin:
|
|||||||
for episodes in watched_episodes:
|
for episodes in watched_episodes:
|
||||||
if len(episodes["Items"]) > 0:
|
if len(episodes["Items"]) > 0:
|
||||||
for episode in episodes["Items"]:
|
for episode in episodes["Items"]:
|
||||||
if episode["UserData"]["Played"] == True:
|
if episode["UserData"]["Played"] is True:
|
||||||
if (
|
if (
|
||||||
"ProviderIds" in episode
|
"ProviderIds" in episode
|
||||||
or "MediaSources" in episode
|
or "MediaSources" in episode
|
||||||
@@ -271,7 +275,8 @@ class Jellyfin:
|
|||||||
}
|
}
|
||||||
task = asyncio.ensure_future(
|
task = asyncio.ensure_future(
|
||||||
self.query(
|
self.query(
|
||||||
f"/Users/{user_id}/Items?ParentId={library_id}&Filters=IsPlayed&limit=1",
|
f"/Users/{user_id}/Items"
|
||||||
|
+ f"?ParentId={library_id}&Filters=IsPlayed&limit=1",
|
||||||
"get",
|
"get",
|
||||||
session,
|
session,
|
||||||
identifiers=identifiers,
|
identifiers=identifiers,
|
||||||
@@ -380,7 +385,9 @@ class Jellyfin:
|
|||||||
async with aiohttp.ClientSession() as session:
|
async with aiohttp.ClientSession() as session:
|
||||||
if videos_movies_ids:
|
if videos_movies_ids:
|
||||||
jellyfin_search = await self.query(
|
jellyfin_search = await self.query(
|
||||||
f"/Users/{user_id}/Items?SortBy=SortName&SortOrder=Ascending&Recursive=false&ParentId={library_id}&isPlayed=false&Fields=ItemCounts,ProviderIds,MediaSources",
|
f"/Users/{user_id}/Items"
|
||||||
|
+ f"?SortBy=SortName&SortOrder=Ascending&Recursive=false&ParentId={library_id}"
|
||||||
|
+ "&isPlayed=false&Fields=ItemCounts,ProviderIds,MediaSources",
|
||||||
"get",
|
"get",
|
||||||
session,
|
session,
|
||||||
)
|
)
|
||||||
@@ -432,7 +439,9 @@ class Jellyfin:
|
|||||||
# TV Shows
|
# TV Shows
|
||||||
if videos_shows_ids and videos_episodes_ids:
|
if videos_shows_ids and videos_episodes_ids:
|
||||||
jellyfin_search = await self.query(
|
jellyfin_search = await self.query(
|
||||||
f"/Users/{user_id}/Items?SortBy=SortName&SortOrder=Ascending&Recursive=false&ParentId={library_id}&isPlayed=false&Fields=ItemCounts,ProviderIds,Path",
|
f"/Users/{user_id}/Items"
|
||||||
|
+ f"?SortBy=SortName&SortOrder=Ascending&Recursive=false&ParentId={library_id}"
|
||||||
|
+ "&isPlayed=false&Fields=ItemCounts,ProviderIds,Path",
|
||||||
"get",
|
"get",
|
||||||
session,
|
session,
|
||||||
)
|
)
|
||||||
@@ -469,7 +478,8 @@ class Jellyfin:
|
|||||||
)
|
)
|
||||||
jellyfin_show_id = jellyfin_show["Id"]
|
jellyfin_show_id = jellyfin_show["Id"]
|
||||||
jellyfin_episodes = await self.query(
|
jellyfin_episodes = await self.query(
|
||||||
f"/Shows/{jellyfin_show_id}/Episodes?userId={user_id}&Fields=ItemCounts,ProviderIds,MediaSources",
|
f"/Shows/{jellyfin_show_id}/Episodes"
|
||||||
|
+ f"?userId={user_id}&Fields=ItemCounts,ProviderIds,MediaSources",
|
||||||
"get",
|
"get",
|
||||||
session,
|
session,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -644,6 +644,9 @@ def main():
|
|||||||
end = perf_counter()
|
end = perf_counter()
|
||||||
times.append(end - start)
|
times.append(end - start)
|
||||||
|
|
||||||
|
if len(times) > 0:
|
||||||
|
logger(f"Average time: {sum(times) / len(times)}", 0)
|
||||||
|
|
||||||
logger(f"Looping in {sleep_duration}")
|
logger(f"Looping in {sleep_duration}")
|
||||||
sleep(sleep_duration)
|
sleep(sleep_duration)
|
||||||
|
|
||||||
@@ -659,7 +662,5 @@ def main():
|
|||||||
sleep(sleep_duration)
|
sleep(sleep_duration)
|
||||||
|
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
if len(times) > 0:
|
|
||||||
logger(f"Average time: {sum(times) / len(times)}", 0)
|
|
||||||
logger("Exiting", log_type=0)
|
logger("Exiting", log_type=0)
|
||||||
os._exit(0)
|
os._exit(0)
|
||||||
|
|||||||
Reference in New Issue
Block a user