Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to download videos that require age verification with pytube?

I download and clip some youtube videos with pytube but some videos are not downloading and asking for age verification. How can I solve this? Thanks for your advice

like image 469
byhite Avatar asked Nov 19 '25 03:11

byhite


2 Answers

For pytube 15.0.0 I had the AgeRestrictedError in streams contents even using the use_oauth option.

I fixed the problem only replacing ANDROID_MUSIC with ANDROID as "client" at line 223 of innertube.py:

def __init__(self, client='ANDROID_MUSIC', use_oauth=False, allow_cache=True): 

def __init__(self, client='ANDROID', use_oauth=False, allow_cache=True):
like image 199
GTS Avatar answered Nov 20 '25 18:11

GTS


I fixed the problem by overwriting ANDROID_MUSIC with ANDROID_CREATOR

from pytube import YouTube
from pytube.innertube import _default_clients

_default_clients["ANDROID_MUSIC"] = _default_clients["ANDROID_CREATOR"]
like image 41
Amarildo Golloshi Avatar answered Nov 20 '25 18:11

Amarildo Golloshi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!