Scope Jellyfin item fetches per library
This commit is contained in:
parent
8a0e4ec014
commit
224257e211
2 changed files with 16 additions and 6 deletions
|
|
@ -939,7 +939,10 @@
|
||||||
renderJellyfinStatus(payload);
|
renderJellyfinStatus(payload);
|
||||||
const action = payload.published ? "published" : payload.changed ? "updated library" : "no changes";
|
const action = payload.published ? "published" : payload.changed ? "updated library" : "no changes";
|
||||||
renderMediaChanges(payload.changes);
|
renderMediaChanges(payload.changes);
|
||||||
setJellyfinMessage(`Synced ${payload.movieCount} movies and ${payload.showCount} shows; ${action}.`);
|
const scope = Array.isArray(payload.libraryNames) && payload.libraryNames.length
|
||||||
|
? ` from ${payload.libraryNames.join(", ")}`
|
||||||
|
: "";
|
||||||
|
setJellyfinMessage(`Synced ${payload.movieCount} movies and ${payload.showCount} shows${scope}; ${action}.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderMediaChanges(changes = {}) {
|
function renderMediaChanges(changes = {}) {
|
||||||
|
|
|
||||||
|
|
@ -919,14 +919,20 @@ def fetch_jellyfin_library_ids(settings: dict[str, Any], library_names: list[str
|
||||||
|
|
||||||
|
|
||||||
def fetch_jellyfin_items(settings: dict[str, Any], item_type: str) -> list[dict[str, Any]]:
|
def fetch_jellyfin_items(settings: dict[str, Any], item_type: str) -> list[dict[str, Any]]:
|
||||||
|
parent_ids = settings.get("ParentIds")
|
||||||
|
if isinstance(parent_ids, list) and parent_ids:
|
||||||
|
all_items: list[dict[str, Any]] = []
|
||||||
|
for parent_id in parent_ids:
|
||||||
|
scoped_settings = dict(settings)
|
||||||
|
scoped_settings["ParentId"] = str(parent_id)
|
||||||
|
scoped_settings.pop("ParentIds", None)
|
||||||
|
all_items.extend(fetch_jellyfin_items(scoped_settings, item_type))
|
||||||
|
return all_items
|
||||||
|
|
||||||
|
parent_id_value = str(settings.get("ParentId", "")).strip() or None
|
||||||
items: list[dict[str, Any]] = []
|
items: list[dict[str, Any]] = []
|
||||||
start_index = 0
|
start_index = 0
|
||||||
limit = 200
|
limit = 200
|
||||||
parent_ids = settings.get("ParentIds")
|
|
||||||
if isinstance(parent_ids, list) and parent_ids:
|
|
||||||
parent_id_value = ",".join(str(parent_id) for parent_id in parent_ids)
|
|
||||||
else:
|
|
||||||
parent_id_value = None
|
|
||||||
while True:
|
while True:
|
||||||
data = jellyfin_request(
|
data = jellyfin_request(
|
||||||
settings,
|
settings,
|
||||||
|
|
@ -1108,6 +1114,7 @@ def sync_jellyfin_library(runtime: BotRuntime, force_publish: bool = False) -> d
|
||||||
"changes": changes,
|
"changes": changes,
|
||||||
"movieCount": len(movies),
|
"movieCount": len(movies),
|
||||||
"showCount": len(shows),
|
"showCount": len(shows),
|
||||||
|
"libraryNames": jellyfin_settings(runtime).get("libraryNames", []),
|
||||||
"library": media_library_to_jsonable(movies, shows),
|
"library": media_library_to_jsonable(movies, shows),
|
||||||
"publishResult": result,
|
"publishResult": result,
|
||||||
"jellyfin": jellyfin_settings(runtime),
|
"jellyfin": jellyfin_settings(runtime),
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue