From 068ae2f2e7c24ccb7718e2c3ef7c6ed0adc355fd Mon Sep 17 00:00:00 2001 From: jj Date: Thu, 6 Mar 2025 17:16:13 +0000 Subject: [PATCH 1/3] api/internal: also transplant youtube HEAD requests --- api/src/stream/internal.js | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/api/src/stream/internal.js b/api/src/stream/internal.js index f55a1b91..8c97c656 100644 --- a/api/src/stream/internal.js +++ b/api/src/stream/internal.js @@ -53,14 +53,25 @@ async function handleYoutubeStream(streamInfo, res) { const cleanup = () => (res.end(), closeRequest(streamInfo.controller)); try { - const req = await fetch(streamInfo.url, { - headers: getHeaders('youtube'), - method: 'HEAD', - dispatcher: streamInfo.dispatcher, - signal - }); + let req, attempts = 3; + while (attempts--) { + req = await fetch(streamInfo.url, { + headers: getHeaders('youtube'), + method: 'HEAD', + dispatcher: streamInfo.dispatcher, + signal + }); + + streamInfo.url = req.url; + if (req.status === 403 && streamInfo.transplant) { + try { + await streamInfo.transplant(streamInfo.dispatcher); + } catch { + break; + } + } else break; + } - streamInfo.url = req.url; const size = BigInt(req.headers.get('content-length')); if (req.status !== 200 || !size) { From 97f71df9628bfb1c2f6318abe2ebe47037e9dba0 Mon Sep 17 00:00:00 2001 From: jj Date: Thu, 6 Mar 2025 17:23:36 +0000 Subject: [PATCH 2/3] api/tests: replace broken facebook video link --- api/src/util/tests/facebook.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/util/tests/facebook.json b/api/src/util/tests/facebook.json index d0c8cc7b..70e2db68 100644 --- a/api/src/util/tests/facebook.json +++ b/api/src/util/tests/facebook.json @@ -46,7 +46,7 @@ }, { "name": "shared video link", - "url": "https://www.facebook.com/share/v/NEf87jbPTvFE8LsL/", + "url": "https://www.facebook.com/share/v/6EJK4Z8EAEAHtz8K/", "params": {}, "expected": { "code": 200, From c346d2b027ecfab0d79705225d3621d18c1010c5 Mon Sep 17 00:00:00 2001 From: wukko Date: Thu, 6 Mar 2025 23:43:13 +0600 Subject: [PATCH 3/3] api/package: bump version to 10.7.7 --- api/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/package.json b/api/package.json index 0c446d3c..fc5304ed 100644 --- a/api/package.json +++ b/api/package.json @@ -1,7 +1,7 @@ { "name": "@imput/cobalt-api", "description": "save what you love", - "version": "10.7.6", + "version": "10.7.7", "author": "imput", "exports": "./src/cobalt.js", "type": "module",