distubejs / ytdl-core

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

Cannot download averagely videos that last more than 1 minute #54

Closed mr-flame7892 closed 1 month ago

mr-flame7892 commented 1 month ago

Describe the bug

When I'm trying to download a video that lasts more than a minute, the "readable" event isn't triggered and when I try to see if the stream is readable, it says that the stream is readable but no stream is returned (there's no error message). But when I tried to download videos that last less than a minute everything works correctly.

Environment

mr-flame7892 commented 1 month ago

It seems that some videos are playable even if its duration is over 1 minute, therefore the duration doesn't matter (for example: https://www.youtube.com/watch?v=jzi6RNVEOtA works perfectly for me). Also when the stream isn't readable, the "errored" property of the stream returns a 403 error message and the stream is destroyed:

image_2024-08-01_202148128

qubiack commented 1 month ago

Are you using agent ?

mr-flame7892 commented 1 month ago

Are you using agent ?

Yes

qubiack commented 1 month ago

Can you provide 2 links: video is working and not working for you?

mr-flame7892 commented 1 month ago

Can you provide 2 links: video is working and not working for you?

Working link: https://www.youtube.com/watch?v=jzi6RNVEOtA

Not working link: https://www.youtube.com/watch?v=uu2XSQgdQDY

qubiack commented 1 month ago

@MR-Flame-exe both work for me in the latest version of ytdl. Could you provide a part of code you are using to download that files?

mr-flame7892 commented 1 month ago

@MR-Flame-exe both work for me in the latest version of ytdl. Could you provide a part of code you are using to download that files?

        var stream = ytdl(song.download_url, {
          highWaterMark: 1 << 25,
          filter: "audioonly",
          quality: "lowestaudio",
          agent,
        }).once("readable", async function () {

          console.log(`✅ - The stream of ${song.url} has been downloaded!`)

        })
qubiack commented 1 month ago

I think that I had that issue few years ago. Some YT files don't have audioonly versions. You can check that by different API - ytdl.getInfo(url, {agent}) .

My workaround was to download always mp4 and convert it into mp3 in next step.

mr-flame7892 commented 1 month ago

I think that I had that issue few years ago. Some YT files don't have audioonly versions. You can check that by different API - ytdl.getInfo(url, {agent}) .

My workaround was to download always mp4 and convert it into mp3 in next step.

Pretty sure it's not a problem related to the audioonly's filter, I mean every videos worked with the bot since today therefore I think it's not an issue related to my code, just an issue with the YouTube API or something. Btw I also tried to use ytdl-core instead of distube but it gets worse, no video was readable.

skick1234 commented 1 month ago

On web client, which ytdl-core is using, have an A/B testing to prevent bots. I will investigate it and release an update after working hours.

skick1234 commented 1 month ago

Also this issue related to #31

jaysun0 commented 1 month ago

I had my app working from server in Finland. Most of the videos downloaded were just blank files. Sometitmes after 2,3 attemptes on each video - manaded to download normaly. Now switched app server location to another country. ~ Half an hour app is working fine. Not sure that it's 100% solution. Just for your information. Thank you all and me for concerns :)