mirror of
https://github.com/sudoxnym/fin-assistant.git
synced 2026-04-14 19:46:26 +00:00
Ajust 2022.2 and ignoe folders
This commit is contained in:
parent
a79def90e3
commit
29b11bc183
1 changed files with 29 additions and 8 deletions
|
|
@ -124,8 +124,8 @@ class JellyfinSource(MediaSource):
|
||||||
"""Browse media."""
|
"""Browse media."""
|
||||||
autolog("<<<")
|
autolog("<<<")
|
||||||
|
|
||||||
media_contant_type, media_content_id = async_parse_identifier(item)
|
media_content_type, media_content_id = async_parse_identifier(item)
|
||||||
return await async_library_items(self.jelly_cm, media_contant_type, media_content_id, canPlayList=False)
|
return await async_library_items(self.jelly_cm, media_content_type, media_content_id, canPlayList=False)
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_parse_identifier(
|
def async_parse_identifier(
|
||||||
|
|
@ -156,6 +156,24 @@ def Type2Mediatype(type):
|
||||||
}
|
}
|
||||||
return switcher[type]
|
return switcher[type]
|
||||||
|
|
||||||
|
def Type2Mimetype(type):
|
||||||
|
switcher = {
|
||||||
|
"Movie": "video/unknown",
|
||||||
|
"Series": MEDIA_TYPE_TVSHOW,
|
||||||
|
"Season": MEDIA_TYPE_SEASON,
|
||||||
|
"Episode": "video/unknown",
|
||||||
|
"Music": MEDIA_TYPE_ALBUM,
|
||||||
|
"Audio": "audio/unknown",
|
||||||
|
"BoxSet": MEDIA_CLASS_DIRECTORY,
|
||||||
|
"Folder": MEDIA_CLASS_DIRECTORY,
|
||||||
|
"CollectionFolder": MEDIA_CLASS_DIRECTORY,
|
||||||
|
"Playlist": MEDIA_CLASS_DIRECTORY,
|
||||||
|
"PlaylistsFolder": MEDIA_CLASS_DIRECTORY,
|
||||||
|
"MusicArtist": MEDIA_TYPE_ARTIST,
|
||||||
|
"MusicAlbum": MEDIA_TYPE_ALBUM,
|
||||||
|
}
|
||||||
|
return switcher[type]
|
||||||
|
|
||||||
def Type2Mediaclass(type):
|
def Type2Mediaclass(type):
|
||||||
switcher = {
|
switcher = {
|
||||||
"Movie": MEDIA_CLASS_MOVIE,
|
"Movie": MEDIA_CLASS_MOVIE,
|
||||||
|
|
@ -202,7 +220,7 @@ async def async_library_items(jelly_cm: JellyfinClientManager,
|
||||||
|
|
||||||
Used by async_browse_media.
|
Used by async_browse_media.
|
||||||
"""
|
"""
|
||||||
_LOGGER.debug(f'>> async_library_items: {media_content_id_in}')
|
_LOGGER.debug(f'>> async_library_items: {media_content_id_in} / {canPlayList}')
|
||||||
|
|
||||||
library_info = None
|
library_info = None
|
||||||
query = None
|
query = None
|
||||||
|
|
@ -229,7 +247,8 @@ async def async_library_items(jelly_cm: JellyfinClientManager,
|
||||||
query = {
|
query = {
|
||||||
"ParentId": media_content_id,
|
"ParentId": media_content_id,
|
||||||
"sortBy": "SortName",
|
"sortBy": "SortName",
|
||||||
"sortOrder": "Ascending"
|
"sortOrder": "Ascending",
|
||||||
|
"filters": "IsNotFolder"
|
||||||
}
|
}
|
||||||
|
|
||||||
parent_item = await jelly_cm.get_item(media_content_id)
|
parent_item = await jelly_cm.get_item(media_content_id)
|
||||||
|
|
@ -265,11 +284,12 @@ async def async_library_items(jelly_cm: JellyfinClientManager,
|
||||||
for item in items:
|
for item in items:
|
||||||
if media_content_type in [None, "library", MEDIA_CLASS_DIRECTORY, MEDIA_TYPE_ARTIST, MEDIA_TYPE_ALBUM, MEDIA_TYPE_PLAYLIST, MEDIA_TYPE_TVSHOW, MEDIA_TYPE_SEASON]:
|
if media_content_type in [None, "library", MEDIA_CLASS_DIRECTORY, MEDIA_TYPE_ARTIST, MEDIA_TYPE_ALBUM, MEDIA_TYPE_PLAYLIST, MEDIA_TYPE_TVSHOW, MEDIA_TYPE_SEASON]:
|
||||||
if item["IsFolder"]:
|
if item["IsFolder"]:
|
||||||
|
library_info.children_media_class = MEDIA_CLASS_DIRECTORY
|
||||||
library_info.children.append(BrowseMediaSource(
|
library_info.children.append(BrowseMediaSource(
|
||||||
domain=DOMAIN,
|
domain=DOMAIN,
|
||||||
identifier=f'{Type2Mediatype(item["Type"])}{IDENTIFIER_SPLIT}{item["Id"]}',
|
identifier=f'{Type2Mediatype(item["Type"])}{IDENTIFIER_SPLIT}{item["Id"]}',
|
||||||
media_class=Type2Mediaclass(item["Type"]),
|
media_class=Type2Mediaclass(item["Type"]),
|
||||||
media_content_type=Type2Mediatype(item["Type"]),
|
media_content_type=Type2Mimetype(item["Type"]),
|
||||||
title=item["Name"],
|
title=item["Name"],
|
||||||
can_play=IsPlayable(item["Type"], canPlayList),
|
can_play=IsPlayable(item["Type"], canPlayList),
|
||||||
can_expand=True,
|
can_expand=True,
|
||||||
|
|
@ -277,11 +297,12 @@ async def async_library_items(jelly_cm: JellyfinClientManager,
|
||||||
thumbnail=jelly_cm.get_artwork_url(item["Id"])
|
thumbnail=jelly_cm.get_artwork_url(item["Id"])
|
||||||
))
|
))
|
||||||
else:
|
else:
|
||||||
|
library_info.children_media_class = Type2Mediaclass(item["Type"])
|
||||||
library_info.children.append(BrowseMediaSource(
|
library_info.children.append(BrowseMediaSource(
|
||||||
domain=DOMAIN,
|
domain=DOMAIN,
|
||||||
identifier=f'{Type2Mediatype(item["Type"])}{IDENTIFIER_SPLIT}{item["Id"]}',
|
identifier=f'{Type2Mediatype(item["Type"])}{IDENTIFIER_SPLIT}{item["Id"]}',
|
||||||
media_class=Type2Mediaclass(item["Type"]),
|
media_class=Type2Mediaclass(item["Type"]),
|
||||||
media_content_type=Type2Mediatype(item["Type"]),
|
media_content_type=Type2Mimetype(item["Type"]),
|
||||||
title=item["Name"],
|
title=item["Name"],
|
||||||
can_play=IsPlayable(item["Type"], canPlayList),
|
can_play=IsPlayable(item["Type"], canPlayList),
|
||||||
can_expand=False,
|
can_expand=False,
|
||||||
|
|
@ -292,12 +313,12 @@ async def async_library_items(jelly_cm: JellyfinClientManager,
|
||||||
library_info.domain=DOMAIN
|
library_info.domain=DOMAIN
|
||||||
library_info.identifier=f'{Type2Mediatype(item["Type"])}{IDENTIFIER_SPLIT}{item["Id"]}',
|
library_info.identifier=f'{Type2Mediatype(item["Type"])}{IDENTIFIER_SPLIT}{item["Id"]}',
|
||||||
library_info.title = item["Name"]
|
library_info.title = item["Name"]
|
||||||
library_info.media_content_type = Type2Mediatype(item["Type"])
|
library_info.media_content_type = Type2Mimetype(item["Type"])
|
||||||
library_info.media_class = Type2Mediaclass(item["Type"])
|
library_info.media_class = Type2Mediaclass(item["Type"])
|
||||||
library_info.can_expand = False
|
library_info.can_expand = False
|
||||||
library_info.can_play=IsPlayable(item["Type"], canPlayList),
|
library_info.can_play=IsPlayable(item["Type"], canPlayList),
|
||||||
break
|
break
|
||||||
|
|
||||||
_LOGGER.debug(f'<< async_library_items')
|
_LOGGER.debug(f'<< async_library_items {library_info.as_dict()}')
|
||||||
return library_info
|
return library_info
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue