校验免费源这条路我也折腾过,免费的无论怎么检测,都不如意,因为意外总是发生, 记得 2024 年 9 月凤凰卫视的频道突然就都不能访问了,找了好多,都不行, 最后我是从官方网站抓取的,但是速度还是不稳定,经常卡顿
我最后是抓取了电信 itv 的组播频道转单播,港台的中文节目都是使用本地缓存 5 分钟的方式,这样才真正实现几乎告别卡顿
``` js 2024-09-22 04:05 cloudflare worker 直接代理凤凰卫视中文台
https://fhws.818000.xyz/fhwszxt 资讯台
https://fhws.818000.xyz/fhwszwt 中文台
async function handleRequest(request) {
const url = new URL(request.url);
let apiUrl = "
https://api.fengshows.cn/hub/live/auth-url?live_qa=hd&live_id=7c96b084-60e1-40a9-89c5-682b994fb680";
//凤凰卫视中文台
https://api.fengshows.cn/hub/live/auth-url?live_qa=hd&live_id=f7f48462-9b13-485b-8101-7b54716411ec //凤凰卫视资讯台
https://api.fengshows.cn/hub/live/auth-url?live_qa=hd&live_id=7c96b084-60e1-40a9-89c5-682b994fb680 if (url.pathname === '/fhwszwt') {
apiUrl = "
https://api.fengshows.cn/hub/live/auth-url?live_qa=hd&live_id=f7f48462-9b13-485b-8101-7b54716411ec";
}
const response = await fetch(apiUrl);
const data = await response.json();
const liveUrl = data.data.live_url;
if (liveUrl.startsWith('http')) {
const flvResponse = await fetch(liveUrl, {
headers: {
'User-Agent': 'VLC/3.0.18 LibVLC/3.0.18'
}
});
// 检查 FLV 响应状态
if (flvResponse.ok) {
return new Response(flvResponse.body, {
headers: {
'Content-Type': 'video/x-flv',
'Content-liveUrl': liveUrl,
'Content-liveUrl2': flvResponse.status,
// 其他必要的头部,比如 Cache-Control
},
status: flvResponse.status,
});
} else {
return new Response('Failed to fetch live stream', { status: flvResponse.status });
}
} else {
return new Response('Error: Key not found', { status: 404 });
}
}
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request));
});
```