mirror of
https://github.com/tubearchivist/jellyfin.git
synced 2024-11-16 17:00:14 +00:00
auto trigger refresh after import
This commit is contained in:
parent
656b36d291
commit
b9cbd4ed3a
@ -38,7 +38,9 @@ class Library:
|
||||
show_handler.validate_episodes()
|
||||
show_handler.delete_folders(folders)
|
||||
|
||||
self.set_collection_art()
|
||||
collection_id: str = self._get_collection()
|
||||
self.set_collection_art(collection_id)
|
||||
self.refresh_collection(collection_id)
|
||||
|
||||
def _get_all_series(self) -> dict:
|
||||
"""get all shows indexed in jf"""
|
||||
@ -47,17 +49,27 @@ class Library:
|
||||
|
||||
return all_shows
|
||||
|
||||
def set_collection_art(self) -> None:
|
||||
def _get_collection(self) -> str:
|
||||
"""get youtube collection id"""
|
||||
folders: dict = Jellyfin().get("Library/MediaFolders")
|
||||
for folder in folders["Items"]:
|
||||
if folder.get("Name").lower() == "youtube":
|
||||
return folder["Id"]
|
||||
|
||||
raise ValueError("youtube collection folder not found")
|
||||
|
||||
def set_collection_art(self, collection_id: str) -> None:
|
||||
"""set collection ta art"""
|
||||
with open(self.COLLECTION_ART, "rb") as f:
|
||||
asset: bytes = f.read()
|
||||
|
||||
folders: dict = Jellyfin().get("Library/MediaFolders")
|
||||
for folder in folders["Items"]:
|
||||
if folder.get("Name").lower() == "youtube":
|
||||
jf_id: str = folder.get("Id")
|
||||
path: str = f"Items/{jf_id}/Images/Primary"
|
||||
Jellyfin().post_img(path, base64.b64encode(asset))
|
||||
path: str = f"Items/{collection_id}/Images/Primary"
|
||||
Jellyfin().post_img(path, base64.b64encode(asset))
|
||||
|
||||
def refresh_collection(self, collection_id: str) -> None:
|
||||
"""trigger collection refresh"""
|
||||
path: str = f"Items/{collection_id}/Refresh?Recursive=true&ImageRefreshMode=Default&MetadataRefreshMode=Default" # noqa: E501
|
||||
Jellyfin().post(path, False)
|
||||
|
||||
|
||||
class Show:
|
||||
|
Loading…
Reference in New Issue
Block a user