mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 07:27:15 +08:00
feat(v3): enhance music server integration with Navidrome support
This commit is contained in:
@@ -164,6 +164,8 @@ class Emby:
|
||||
continue
|
||||
if library.get("CollectionType") == "movies":
|
||||
library_type = MediaType.MOVIE.value
|
||||
elif library.get("CollectionType") in ("music", "musicvideos", "audio"):
|
||||
library_type = MediaType.MUSIC.value
|
||||
elif library.get("CollectionType") == "tvshows":
|
||||
library_type = MediaType.TV.value
|
||||
else:
|
||||
@@ -180,7 +182,10 @@ class Emby:
|
||||
name=library.get("Name"),
|
||||
path=library.get("Path"),
|
||||
type=library_type,
|
||||
item_count=self.get_items_count(library.get("Id")),
|
||||
item_count=self.get_items_count(
|
||||
library.get("Id"),
|
||||
"MusicAlbum" if library_type == MediaType.MUSIC.value else "Movie,Series",
|
||||
),
|
||||
image=image,
|
||||
link=f'{self._playhost or self._host}web/index.html'
|
||||
f'#!/videos?{server_query}parentId={library.get("Id")}',
|
||||
@@ -326,7 +331,9 @@ class Emby:
|
||||
return schemas.Statistic(
|
||||
movie_count=result.get("MovieCount") or 0,
|
||||
tv_count=result.get("SeriesCount") or 0,
|
||||
episode_count=result.get("EpisodeCount") or 0
|
||||
episode_count=result.get("EpisodeCount") or 0,
|
||||
music_count=result.get("MusicAlbumCount") or result.get("AlbumCount")
|
||||
or result.get("SongCount") or 0,
|
||||
)
|
||||
else:
|
||||
logger.error(f"Items/Counts 未获取到返回数据")
|
||||
@@ -412,7 +419,33 @@ class Emby:
|
||||
except Exception as e:
|
||||
logger.error(f"连接Items出错:" + str(e))
|
||||
return None
|
||||
return []
|
||||
return None
|
||||
|
||||
def get_music(
|
||||
self, title: Optional[str] = None, artist: Optional[str] = None,
|
||||
album: Optional[str] = None,
|
||||
) -> List[schemas.MediaServerItem]:
|
||||
"""按歌曲、艺术家或专辑名称查询 Emby 音乐条目。"""
|
||||
if not self._host or not self._apikey or not self.user:
|
||||
return []
|
||||
query = " ".join(filter(None, [title, artist, album])).strip()
|
||||
if not query:
|
||||
return []
|
||||
url = f"{self._host}emby/Users/{self.user}/Items"
|
||||
params = {
|
||||
"IncludeItemTypes": "MusicAlbum,Audio",
|
||||
"SearchTerm": query,
|
||||
"Recursive": "true",
|
||||
"Limit": 20,
|
||||
"api_key": self._apikey,
|
||||
}
|
||||
try:
|
||||
res = RequestUtils().get_res(url, params)
|
||||
items = res.json().get("Items", []) if res and res.status_code == 200 else []
|
||||
return [item for item in (self.__format_item_info(item) for item in items) if item]
|
||||
except Exception as e:
|
||||
logger.debug(f"查询Emby音乐出错:{e}")
|
||||
return []
|
||||
|
||||
def get_tv_episodes(self,
|
||||
item_id: Optional[str] = None,
|
||||
@@ -742,7 +775,7 @@ class Emby:
|
||||
logger.error(f"连接/Users/{self.user}/Items/{itemid}出错:" + str(e))
|
||||
return None
|
||||
|
||||
def get_items_count(self, parent: Union[str, int]) -> Optional[int]:
|
||||
def get_items_count(self, parent: Union[str, int], include_item_types: str = "Movie,Series") -> Optional[int]:
|
||||
"""
|
||||
获取指定媒体库可同步的电影和剧集总数
|
||||
|
||||
@@ -755,7 +788,7 @@ class Emby:
|
||||
params = {
|
||||
"ParentId": parent,
|
||||
"Recursive": "true",
|
||||
"IncludeItemTypes": "Movie,Series",
|
||||
"IncludeItemTypes": include_item_types,
|
||||
"Limit": 0,
|
||||
"api_key": self._apikey,
|
||||
}
|
||||
@@ -804,7 +837,7 @@ class Emby:
|
||||
if "Folder" in item.get("Type"):
|
||||
for items in self.get_items(parent=item.get('Id')):
|
||||
yield items
|
||||
elif item.get("Type") in ["Movie", "Series"]:
|
||||
elif item.get("Type") in ["Movie", "Series", "MusicAlbum"]:
|
||||
yield self.__format_item_info(item)
|
||||
except Exception as e:
|
||||
logger.error(f"连接Users/Items出错:" + str(e))
|
||||
|
||||
Reference in New Issue
Block a user