24

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

CC BY-SA 4.0

2 Answers 2

38

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

CC BY-SA 4.0
1
  • 2
    Hey I cleared the cache and used the option "cachedir": "false", but it still doesn't work. Any other solutions?
    – Filip
    Apr 27, 2020 at 1:14
5

It seems like i have figured it out on my own. The Error went away after i cleared the cache.

            with youtube_dl.YoutubeDL(ydl_opts) as ydl:
            try:
                ydl.cache.remove()
                ydl.download([youtube_link])
            except youtube_dl.DownloadError as error:
                pass

Any info on why this works is welcome

CC BY-SA 4.0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.