mirror of
https://github.com/KuekHaoYang/KVideo.git
synced 2026-08-16 09:13:42 +08:00
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:
@@ -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
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user