Skip to content

Commit

Permalink
Tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Erotemic committed Jan 8, 2024
1 parent ffeac69 commit e4f022c
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions jellyfin_apiclient_python/media_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def __truediv__(self, node):

def setup(self):
self._init_media_folders()
self._label_graph()
self._update_graph_labels()
return self

def _init_media_folders(self):
Expand All @@ -121,7 +121,9 @@ def _init_media_folders(self):

pman = progiter.ProgressManager()
with pman:

media_folders = client.jellyfin.get_media_folders(fields=['Path'])
items = []
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 Down Expand Up @@ -153,7 +155,10 @@ def _init_media_folders(self):
assert item is not None

self._media_root_nodes.append(item['Id'])
items.append(item)
graph.add_node(item['Id'], item=item, properties=dict(expanded=False))

for item in pman.progiter(items, desc='Walk Media Folders'):
self._walk_node(item, pman, stats, max_depth=initial_depth)

def open_node(self, node, verbose=0, max_depth=1):
Expand All @@ -171,7 +176,7 @@ def open_node(self, node, verbose=0, max_depth=1):
}
with pman:
self._walk_node(item, pman, stats, max_depth=max_depth)
self._label_graph(sources=[node])
self._update_graph_labels(sources=[node])

if verbose:
self.print_graph([node])
Expand Down Expand Up @@ -278,7 +283,7 @@ class StackFrame(typing.NamedTuple):
timer.tic()
folder_prog.stop()

def _label_graph(self, sources=None):
def _update_graph_labels(self, sources=None):
"""
Update the rich text representation of select items in the graph.
"""
Expand Down Expand Up @@ -328,6 +333,9 @@ def _label_graph(self, sources=None):
elif item['Type'] == 'Video':
color = None
type_glyph = glyphs['FILM_FRAMES']
elif item['Type'] == 'Movie':
color = None
type_glyph = glyphs['MOVIE_CAMERA']
elif item['Type'] == 'Audio':
color = None
type_glyph = glyphs['BEAMED_SIXTEENTH_NOTES']
Expand Down

0 comments on commit e4f022c

Please sign in to comment.