From ce2d04fa64e270f95cc5be7c70e789da11166c75 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Sat, 12 Jul 2025 15:04:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0Plex=E6=B7=B1=E5=BA=A6?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=E6=9E=84=E5=BB=BA=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/appDeepLink.ts | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/src/utils/appDeepLink.ts b/src/utils/appDeepLink.ts index 7751ba4a..bc1418d2 100644 --- a/src/utils/appDeepLink.ts +++ b/src/utils/appDeepLink.ts @@ -155,8 +155,8 @@ function buildDeepLinkUrl(appType: AppType, params: string | DoubanAppParams): s * - 媒体项: web/index.html#!/server/{machineIdentifier}/details?key={item_id}&X-Plex-Token={token} * * Plex官方APP URL格式: - * - 媒体库: http://[PMS_IP_Address]:32400/library/sections/29/all?X-Plex-Token=YourTokenGoesHere - * - 媒体项: http://[PMS_IP_ADDRESS]:32400/library/metadata/1668?X-Plex-Token=YourTokenGoesHere + * plex://play/?metadataKey=/library/metadata/$SOME_ID&server=$SERVER_ID + * 例如: plex://play/?metadataKey=/library/metadata/123&server=456 * * @param playUrl 播放链接 */ @@ -216,12 +216,12 @@ function buildPlexDeepLink(playUrl: string): string { } } - // 构建深度链接 - if (mediaId) { - // http://[PMS_IP_ADDRESS]:32400/library/metadata/1668?X-Plex-Token=YourTokenGoesHere - let deepLink = `plex://library/metadata/${mediaId}` + // 构建深度链接 - 使用新的官方格式 + if (mediaId && machineIdentifier) { + // plex://play/?metadataKey=/library/metadata/$SOME_ID&server=$SERVER_ID + let deepLink = `plex://play/?metadataKey=/library/metadata/${mediaId}&server=${machineIdentifier}` if (plexToken) { - deepLink += `?X-Plex-Token=${plexToken}` + deepLink += `&X-Plex-Token=${plexToken}` } console.log('Plex深度链接构建成功:', { originalUrl: playUrl, @@ -232,6 +232,22 @@ function buildPlexDeepLink(playUrl: string): string { plexToken, deepLink, }) + alert(deepLink) + return deepLink + } + + // 如果有媒体ID但没有机器标识符,尝试使用旧的格式作为降级 + if (mediaId) { + let deepLink = `plex://library/metadata/${mediaId}` + if (plexToken) { + deepLink += `?X-Plex-Token=${plexToken}` + } + console.log('Plex深度链接构建成功(降级格式):', { + originalUrl: playUrl, + mediaId, + plexToken, + deepLink, + }) return deepLink }