feat: Add player layout with no-referrer metadata and enhance detail API to prioritize m3u8 video sources from multiple options.

This commit is contained in:
kuekhaoyang
2025-11-22 16:19:25 +08:00
parent 1b5f591a7a
commit c7045f8f51
2 changed files with 29 additions and 3 deletions
+13
View File
@@ -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;
}
+16 -3
View File
@@ -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);