Last active
March 2, 2025 20:28
-
-
Save unixfox/970596d8a42aeb14194e08f7d97efa75 to your computer and use it in GitHub Desktop.
test 403 invidious companion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sleep(ms) { | |
return new Promise(resolve => setTimeout(resolve, ms)); | |
} | |
async function fetchVideos(videos: { videoId: any }[]) { | |
for (const video of videos) { | |
const urlVideo = await fetch( | |
`http://localhost:8282/latest_version?id=${video.videoId}&itag=140`, | |
{ redirect: "manual" }, | |
); | |
const urlVideoRedirect = urlVideo.headers.get("location"); | |
if (urlVideoRedirect) { | |
const fetchedUrl = await fetch(urlVideoRedirect, { method: "HEAD" }); | |
if (fetchedUrl.status == 403) { | |
const date = new Date(); | |
const minutes = date.getMinutes(); | |
const seconds = date.getSeconds(); | |
console.log(`${minutes}:${seconds} - ${fetchedUrl.status} ${video.videoId}`); | |
} | |
} else { | |
console.log("null url"); | |
console.log(`${video.videoId}`); | |
} | |
await new Promise(r => setTimeout(r, 2000)); | |
// if (fetchedUrl.status == 403) { | |
// console.log(video.videoId) | |
// } | |
} | |
return; | |
} | |
async function getNextContinuation(continuation: any) { | |
console.log("sup"); | |
const resp = await fetch( | |
`http://localhost:3000/api/v1/channels/UCPF-oYb2-xN5FbCXy0167Gg/videos?continuation=${continuation}`, | |
); | |
const respJson = await resp.json(); | |
await fetchVideos(respJson.videos); | |
//console.log(respJson.continuation); | |
await getNextContinuation(respJson.continuation); | |
return; | |
} | |
async function main() { | |
const resp = await fetch( | |
"http://localhost:3000/api/v1/channels/UCPF-oYb2-xN5FbCXy0167Gg/videos", | |
); | |
const respJson = await resp.json(); | |
getNextContinuation(respJson.continuation); | |
} | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment