소스 검색

提交下歌词LyricService的改动

onecold 7 달 전
부모
커밋
adf209bcb7
1개의 변경된 파일6개의 추가작업 그리고 4개의 파일을 삭제
  1. 6 4
      entry/src/main/ets/common/service/LyricService.ets

+ 6 - 4
entry/src/main/ets/common/service/LyricService.ets

@@ -38,7 +38,8 @@ class LyricService {
    */
   async fetchNavidromeLyric(
     currentSong: SongData,
-    getAccountById: AccountGetter
+    getAccountById: AccountGetter,
+    songId:string
   ): Promise<string> {
     if (!currentSong || !currentSong.webdav_account_id) {
       return '';
@@ -53,9 +54,10 @@ class LyricService {
 
       const artist = currentSong.artist || '';
       const title = currentSong.name || '';
-      const navidromeLyric = await navidromeRestApi.getLyrics(account, artist, title);
-
-      if (StrUtil.isNotEmpty(navidromeLyric)) {
+      // 对于 Navidrome,使用 id 字段而不是 webdav_id
+      // 使用 getLyricsBySongId 方法,它会自动将JSON格式转换为LRC格式
+      const navidromeLyric = await navidromeRestApi.getLyricsBySongId(account, songId);
+      if (navidromeLyric && StrUtil.isNotEmpty(navidromeLyric)) {
         ServerLogUtil.info(TAG, '成功从Navidrome服务器获取到歌词');
         return navidromeLyric;
       } else {