Fix Jellyfin erroring on media items without a source (#67697)

* Fix erroring on media items with a source

* code style improvement
pull/67812/head
Jan Stienstra 2022-03-07 14:13:51 +01:00 committed by GitHub
parent a9cc2d2322
commit 2f25d52f69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

@ -324,6 +324,9 @@ class JellyfinSource(MediaSource):
def _media_mime_type(media_item: dict[str, Any]) -> str:
"""Return the mime type of a media item."""
if not media_item[ITEM_KEY_MEDIA_SOURCES]:
raise BrowseError("Unable to determine mime type for item without media source")
media_source = media_item[ITEM_KEY_MEDIA_SOURCES][0]
path = media_source[MEDIA_SOURCE_KEY_PATH]
mime_type, _ = mimetypes.guess_type(path)