Skip to content

Commit

Permalink
update media graph
Browse files Browse the repository at this point in the history
  • Loading branch information
Erotemic committed Dec 13, 2023
1 parent eedb2ea commit 0fe2bfc
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions jellyfin_apiclient_python/media_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def __init__(self, client):

@classmethod
def demo_client(cls):
# TODO: Ensure test environment can spin up a dummy jellyfin server.
from jellyfin_apiclient_python import JellyfinClient
client = JellyfinClient()
client.config.app(
Expand Down Expand Up @@ -117,7 +118,7 @@ def _init_media_folders(self):

pman = progiter.ProgressManager()
with pman:
media_folders = client.jellyfin.get_media_folders()
media_folders = client.jellyfin.get_media_folders(fields=['Path'])
for folder in pman.progiter(media_folders['Items'], desc='Media Folders'):
collection_type = folder.get('CollectionType', None)
if include_collection_types is not None:
Expand All @@ -127,7 +128,27 @@ def _init_media_folders(self):
if collection_type not in exclude_collection_types:
continue

item = folder
if 1:
item = folder
else:
# Weirdness is not needed if we have access to fields
# in get-media-folders
# Query API for children (todo: we want to async this)
item_id = folder['Id']
# This returns all root items, I'm not sure why
# hack around it for now.
_weird_result = client.jellyfin.user_items(params={
'Id': item_id,
'Recursive': False,
'fields': ['Path'],
})
item = None
for cand in _weird_result['Items']:
if cand['Id'] == item_id:
item = cand
break
assert item is not None

self._media_root_nodes.append(item['Id'])
graph.add_node(item['Id'], item=item, properties=dict(expanded=False))
self._walk_node(item, pman, stats, max_depth=initial_depth)
Expand Down

0 comments on commit 0fe2bfc

Please sign in to comment.