JuanBindez / pytubefix

Python3 library for downloading YouTube Videos.
https://pytubefix.readthedocs.io
MIT License
722 stars 100 forks source link

Fixed false live error #253

Closed felipeucelli closed 1 month ago

felipeucelli commented 1 month ago

Test before merging

Initially, liveStreamability was used within playabilityStatus to check whether the video was live, however some clients always return this parameter as a certificate that the video was live.

Switching from the standard client to ADROID_VR #244 caused this bug that says that the video is still live even if it has already finished #248.

Another parameter that identifies that the video is live is videoDetails.isLive, which so far only appears in videos that are live at the moment. So far this parameter works the same on all clients and seems to be more effective.

YouTube removes isLive the moment the stream ends, so we'll use it to identify live streams.

JuanBindez commented 1 month ago

It is already available in pip install pytubefix==7.1rc2

NannoSilver commented 1 month ago

I did some tests and seems it is working fine! Thank you @felipeucelli and @JuanBindez!

felipeucelli commented 1 month ago

@JuanBindez Bug fix for private videos is available #254

NannoSilver commented 1 month ago

@felipeucelli I am running Pytubefix 7.1rc1 with the patch of this pool request #253. Since then none of my requests to Youtube were detected as BOT (previously 5-10% of the requests were detected as BOT).

That may be because the changes of this patch are overcoming the Youtube detection (?) or because the exceptions.BotDetection is no longer capable to identify that was detected as BOT, or maybe something else.

felipeucelli commented 1 month ago

@NannoSilver I don't know for sure, but the ANDROID_VR client is little known among third-party apps so maybe YouTube doesn't verify it.

Currently I only know pytubefix which is using ANDROID_VR, the other third party apps have switched to WEB_CREATOR.

But it might just be a matter of time before YouTube starts verifying android_vr and turning all clients in PoToken.

BotDetection only checks the playabilitystatus of the video, so I think if it stops working it will be easy to know.

NannoSilver commented 1 month ago

@NannoSilver I don't know for sure, but the ANDROID_VR client is little known among third-party apps so maybe YouTube doesn't verify it.

Currently I only know pytubefix which is using ANDROID_VR, the other third party apps have switched to WEB_CREATOR.

But it might just be a matter of time before YouTube starts verifying android_vr and turning all clients in PoToken.

BotDetection only checks the playabilitystatus of the video, so I think if it stops working it will be easy to know.

Hi @felipeucelli

Indeed, it is a bit intriguing.

I did some tests and found the following:

Pytubefix 7.1rc2: not detected as bot after around 5000 download of audio files (itag = 140)

Pytubefix 7.1.3: is detected as bot for itag = 140

Pytubefix 7.1rc2 with pytubefix/extract.py patched as below (to become same as 7.1.3) is also detected as bot (for itag = 140): image

I had a look in the code, but could not see anything obvious to explain. I guess the bug at 7.1rc2 (and fixed at 7.1.3) was somehow preventing the correct identification that it was detected as bot.

Anyway, I am sharing that for any case.