From 6fa4cefd2d9b77b47cf62ade794f709de91661fb Mon Sep 17 00:00:00 2001 From: patrick Date: Sun, 3 May 2026 21:39:48 +0200 Subject: [PATCH] api/bilibili: fix by fetching playinfo from their api --- api/src/processing/services/bilibili.js | 43 ++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 5 deletions(-) diff --git a/api/src/processing/services/bilibili.js b/api/src/processing/services/bilibili.js index 0e9df710..3d2cf356 100644 --- a/api/src/processing/services/bilibili.js +++ b/api/src/processing/services/bilibili.js @@ -17,6 +17,40 @@ function extractBestQuality(dashData) { return [ bestVideo, bestAudio ]; } +function extractStreamDataFromHTML(html) { + const rawStreamData = html.split('')[0]; + if (!rawStreamData) return; + + const data = JSON.parse(rawStreamData); + if (data.code !== 0) return; + + return data; +} + +async function fetchStreamDataFromAPI(html) { + // initial state has required aid and cid (bvid doesn't seem to be required) + const initialStateHtml = html.split('')[0] - ); - if (streamData.data.timelength > env.durationLimit * 1000) { return { error: "content.too_long" }; }