pythonyoutube-dl

ERROR: unable to download video data: HTTP Error 403: Forbidden while using youtube_dl


I am trying to download songs from youtube using python 3.8 and youtube_dl 2020.3.24. But the weird thing is that most songs I try to download don't get downloaded. I'm talking 99% of them. The ones that do get downloaded get the following Error from youtube_dl:

ERROR: unable to download video data: HTTP Error 403: Forbidden

It is worth saying that this happened overnight and I did not change any code. before this everything worked fine. I have friends who ran the same code and they did not get this Error


Solution

  • Same problem many times .. solution: youtube-dl --rm-cache-dir

    Cause of the problem: Sometimes I download playlists of large videos and I force it to stop downloading, the next time I run the command to resume the download, the 403 problem arises

    At the moment, the cache directory is used only to store youtube players for obfuscated signatures. Since all videos in playlist use simple signatures

    Playlist caching is an obvious way to detect changed titles or changed playlists in general