best way to save what you love
Svelte collaborationdownloaderinstagramjavascriptmusicredditsocial-mediasoundcloudsveltetiktoktwittertypescriptvideovimeovkwebappyoutubeyoutube-downloader
api/internal: also transplant youtube HEAD requests
jj068ae2f2e7c2
diff --git a/api/src/stream/internal.js b/api/src/stream/internal.jsindex 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) {