From c7045f8f51f83c0b3b5184c2d09ab8fc3b07142e Mon Sep 17 00:00:00 2001 From: kuekhaoyang Date: Sat, 22 Nov 2025 16:19:25 +0800 Subject: [PATCH] feat: Add player layout with no-referrer metadata and enhance detail API to prioritize m3u8 video sources from multiple options. --- app/player/layout.tsx | 13 +++++++++++++ lib/api/detail-api.ts | 19 ++++++++++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 app/player/layout.tsx diff --git a/app/player/layout.tsx b/app/player/layout.tsx new file mode 100644 index 0000000..2eee97e --- /dev/null +++ b/app/player/layout.tsx @@ -0,0 +1,13 @@ +import { Metadata } from 'next'; + +export const metadata: Metadata = { + referrer: 'no-referrer', +}; + +export default function PlayerLayout({ + children, +}: { + children: React.ReactNode; +}) { + return children; +} diff --git a/lib/api/detail-api.ts b/lib/api/detail-api.ts index 0d75616..8656105 100644 --- a/lib/api/detail-api.ts +++ b/lib/api/detail-api.ts @@ -46,8 +46,21 @@ export async function getVideoDetail( const videoData = data.list[0]; - // Parse episodes from vod_play_url - const episodes = parseEpisodes(videoData.vod_play_url || ''); + // Handle multiple sources (separated by $$$) + const playFrom = (videoData.vod_play_from || '').split('$$$'); + const playUrls = (videoData.vod_play_url || '').split('$$$'); + + // Find the best source (prioritize m3u8) + let selectedIndex = 0; + + // Try to find a source that contains 'm3u8' in its name or code + const m3u8Index = playFrom.findIndex(code => code.toLowerCase().includes('m3u8')); + if (m3u8Index !== -1 && m3u8Index < playUrls.length) { + selectedIndex = m3u8Index; + } + + // Parse episodes from the selected source + const episodes = parseEpisodes(playUrls[selectedIndex] || ''); return { vod_id: videoData.vod_id, @@ -62,7 +75,7 @@ export async function getVideoDetail( type_name: videoData.type_name, episodes, source: source.id, - source_code: videoData.vod_play_from || '', + source_code: playFrom[selectedIndex] || '', }; } catch (error) { console.error(`Detail fetch failed for source ${source.name}:`, error);