mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-04-21 16:51:57 +00:00
Update youtubeExtractor.ts
This commit is contained in:
parent
5fa02d7c53
commit
a2a801d68a
1 changed files with 74 additions and 66 deletions
|
|
@ -416,9 +416,20 @@ async function collectAllFormats(
|
|||
const adaptiveAudio: StreamCandidate[] = [];
|
||||
const hlsManifests: Array<{ clientKey: string; priority: number; url: string }> = [];
|
||||
|
||||
for (const client of CLIENTS) {
|
||||
try {
|
||||
const resp = await fetchPlayerResponse(videoId, client, apiKey, visitorData);
|
||||
// Fire all client requests in parallel — same approach as Kotlin coroutines
|
||||
const results = await Promise.allSettled(
|
||||
CLIENTS.map(client => fetchPlayerResponse(videoId, client, apiKey, visitorData)
|
||||
.then(resp => ({ client, resp }))
|
||||
)
|
||||
);
|
||||
|
||||
for (const result of results) {
|
||||
if (result.status === 'rejected') {
|
||||
logger.warn('YouTubeExtractor', `Client request rejected:`, result.reason);
|
||||
continue;
|
||||
}
|
||||
|
||||
const { client, resp } = result.value;
|
||||
if (!resp) continue;
|
||||
|
||||
const status = resp.playabilityStatus?.status;
|
||||
|
|
@ -499,9 +510,6 @@ async function collectAllFormats(
|
|||
}
|
||||
|
||||
logger.info('YouTubeExtractor', `[${client.key}] progressive=${nProg} video=${nVid} audio=${nAud} hls=${sd.hlsManifestUrl ? 1 : 0}`);
|
||||
} catch (err) {
|
||||
logger.warn('YouTubeExtractor', `[${client.key}] Failed:`, err);
|
||||
}
|
||||
}
|
||||
|
||||
return { progressive, adaptiveVideo, adaptiveAudio, hlsManifests };
|
||||
|
|
|
|||
Loading…
Reference in a new issue