mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-11-22 03:43:45 +08:00
Merge pull request #7396 from pcbeingused333/fix/jellyfin-library-routes-c2832
This commit is contained in:
@@ -248,6 +248,19 @@ class Jellyfin:
|
||||
elif library.get("CollectionType") in ("music", "musicvideos"):
|
||||
library_type = MediaType.MUSIC.value
|
||||
link = f"{self._playhost or self._host}web/index.html#!/music.html?topParentId={library.get('Id')}"
|
||||
elif library.get("CollectionType") in ("boxsets", "books", "playlists"):
|
||||
library_type = MediaType.UNKNOWN.value
|
||||
collection_type = library.get("CollectionType")
|
||||
link = (
|
||||
f"{self._playhost or self._host}web/index.html#!/{collection_type}"
|
||||
f"?topParentId={library.get('Id')}&collectionType={collection_type}"
|
||||
)
|
||||
elif library.get("CollectionType") in ("homevideos", "livetv"):
|
||||
library_type = MediaType.UNKNOWN.value
|
||||
link = (
|
||||
f"{self._playhost or self._host}web/index.html#!/{library.get('CollectionType')}"
|
||||
f"?topParentId={library.get('Id')}"
|
||||
)
|
||||
elif library.get("CollectionType") is None and library.get("Type") == "CollectionFolder":
|
||||
# 混合内容库:Jellyfin 前端没有 library 路由,自身对该类库使用 mixed 路由。
|
||||
library_type = MediaType.UNKNOWN.value
|
||||
|
||||
@@ -3,8 +3,11 @@
|
||||
"""
|
||||
|
||||
import sys
|
||||
from typing import Optional
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
from app.modules.jellyfin import jellyfin as jellyfin_module
|
||||
from app.modules.jellyfin.jellyfin import Jellyfin
|
||||
from app.schemas.mediaserver import MediaServerField, MediaServerQueryOptions
|
||||
@@ -249,13 +252,13 @@ def test_get_librarys_other_unknown_types_keep_library_route() -> None:
|
||||
非混合的其他未知类型库不改走 mixed 路由,保持原有链接。
|
||||
|
||||
Jellyfin 只对 CollectionType 为空且类型为 CollectionFolder 的库使用 mixed 路由;
|
||||
书籍等有专属路由的类型不在本次修复范围,仍走原有分支。
|
||||
未识别的类型仍保留原有兜底行为。
|
||||
"""
|
||||
client = _build_client()
|
||||
libraries = _get_librarys_with_mocked_views(
|
||||
client,
|
||||
[
|
||||
{"Id": "b1", "Name": "书籍", "CollectionType": "books", "Type": "CollectionFolder"},
|
||||
{"Id": "b1", "Name": "未知", "CollectionType": "unsupported", "Type": "CollectionFolder"},
|
||||
{"Id": "u1", "Name": "视图", "CollectionType": None, "Type": "UserView"},
|
||||
],
|
||||
)
|
||||
@@ -264,3 +267,34 @@ def test_get_librarys_other_unknown_types_keep_library_route() -> None:
|
||||
"http://jellyfin.local:8096/web/index.html#!/library.html?topParentId=b1",
|
||||
"http://jellyfin.local:8096/web/index.html#!/library.html?topParentId=u1",
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("play_host", [None, "https://play.example/jellyfin/"])
|
||||
@pytest.mark.parametrize(
|
||||
"collection_type,query_suffix",
|
||||
[
|
||||
("boxsets", "&collectionType=boxsets"),
|
||||
("books", "&collectionType=books"),
|
||||
("homevideos", ""),
|
||||
("playlists", "&collectionType=playlists"),
|
||||
("livetv", ""),
|
||||
],
|
||||
)
|
||||
def test_get_librarys_uses_dedicated_routes(
|
||||
play_host: Optional[str], collection_type: str, query_suffix: str,
|
||||
) -> None:
|
||||
"""
|
||||
特殊类型库使用对应前端路由,并优先使用外网播放地址。
|
||||
"""
|
||||
client = _build_client()
|
||||
client._playhost = play_host
|
||||
libraries = _get_librarys_with_mocked_views(
|
||||
client,
|
||||
[{"Id": "library-id", "Name": "媒体库", "CollectionType": collection_type}],
|
||||
)
|
||||
|
||||
host = play_host or "http://jellyfin.local:8096/"
|
||||
assert libraries[0].link == (
|
||||
f"{host}web/index.html#!/{collection_type}?topParentId=library-id{query_suffix}"
|
||||
)
|
||||
assert libraries[0].type == MediaType.UNKNOWN.value
|
||||
|
||||
Reference in New Issue
Block a user