distubejs / ytdl-core

YouTube video downloader in javascript.
MIT License
203 stars 43 forks source link

Throttling / Download url is inactive after 30 seconds. #84

Open jaysun0 opened 1 month ago

jaysun0 commented 1 month ago

Describe the bug

I use distube/ytdl deployed on ubuntu server with agent(cookies) and all works fine and fast, but I can't download pretty large files, because right after 30 seconds smth happens and stream just stops. Anything what can be downloaded before 30 seconds (even large 40 minutes or more videos, ~600mb in weight) - is being downloaded fast. After 30 secs - download progress is just 0 mbs, it stucks. Any thoughts on how to get around this? Or at least direction to go?)

Environment

gathilas commented 1 month ago

I’m getting the same thing.

Edit: more info, for me it's not exactly 30 seconds. It will stop after a short time, under a minute but it seems to always stop exactly on a multiple of 10mb, e.g. 840mb, 550mb, etc. I'm also on @distube/ytdl-core version: latest 4.14.4

phucngo2 commented 1 month ago

I'm encountering the same issue. After 30 seconds, the download progress randomly gets stuck at points that are multiples of 10mb (e.g., 240mb, 250mb).

Ali-Nazim commented 1 month ago

Same issue here, after a minute or so of streaming, it randomly stops. I'm on @distube/ytdl-core version: latest 4.14.4

gathilas commented 4 weeks ago

It seems like it stops because of a 403 error part way through the download.

jaysun0 commented 4 weeks ago

It seems like it stops because of a 403 error part way through the download.

Why do you think so?

gathilas commented 4 weeks ago

It seems like it stops because of a 403 error part way through the download.

Why do you think so?

I saw someone else mention that they were getting a 403 mid stream so I added some code to my implementation and found I was also getting a 403 error when the stream stops downloading.

jaysun0 commented 4 weeks ago

It seems like it stops because of a 403 error part way through the download.

Why do you think so?

I saw someone else mention that they were getting a 403 mid stream so I added some code to my implementation and found I was also getting a 403 error when the stream stops downloading.

Thank you for info.

So, in theory, not as implementation - but to my understanding: changing cookies on the run and making a new request will give again some download time?

jaysun0 commented 4 weeks ago

Look - I download video, pretty fast, everything is ok. After 30 seconds it starts throttling. I immediately rerun function, requesting the same video with the same cookies - and it starts download again very fast.

Why it works fast again with same ip and cookies?

gathilas commented 4 weeks ago

I have no idea how to fix the problem, just stating what I found. I'm still getting the error. Hopefully someone smarter than I can figure it out.

jaysun0 commented 4 weeks ago

More info about issue:

When I use range as option when downloading big-weight video (for example: options.range = { start: 1000gb } ), download is throttling immediately. It is not stopping but speed less than 2mbs while ussally more than 50 or even 100. Also if in the same video I set range { start: 500gb } - it will download fast till 1000 and then start throttling. Numbers are not exact, just for example.

So, it kind of allows to download fast till some point and then throttles.

plasma119 commented 3 weeks ago

I got the same problem: 403 after 30 seconds for like 80+ videos

After some digging around on internet I saw a mention of "using the option IOS fixed the problem" (forgot where I saw it)

Manually selecting other format did work, so I assume the problem is related to some specific video formats. I extracted the format details and found that there is 2 format with same itag but different url, one has "c=ANDROID" and the other has "c=IOS"

I added filter to ytdl.chooseFormat to filter out format.url containing "c=ANDROID" and it seems to be working fine again now

jaysun0 commented 3 weeks ago

I got the same problem: 403 after 30 seconds for like 80+ videos

After some digging around on internet I saw a mention of "using the option IOS fixed the problem" (forgot where I saw it)

Manually selecting other format did work, so I assume the problem is related to some specific video formats. I extracted the format details and found that there is 2 format with same itag but different url, one has "c=ANDROID" and the other has "c=IOS"

I added filter to ytdl.chooseFormat to filter out format.url containing "c=ANDROID" and it seems to be working fine again now

Thanks for info. Also using ios formats now. Works good, but sometimes I get 401 (I always use cookies). 401 also kind of strange because you can get 401, then try to download the same video again and it works.

gathilas commented 3 weeks ago

The filtering solution worked for me for a while but stopped working again.