This article is about building a Reddit video downloader from scratch using python. Our downloader will be able to downloader video along with the audio.
Reddit makes it tough to download posted videos directly. This is because Reddit saves the audio and video separately on their servers. But this is not a big problem, as we will download both audio and video separately and join them using FFmpeg.
How to get the video URL?
Every Reddit post can be parsed as a JSON, simply by appending a .json to the URL. Thus,
Go to the JSON URL, and you should see something like,
From there, it is easy. Press Ctrl + F and search for .mp4.
That's what we need, the fallback URL. Now have to figure out how to reach here starting from the top.
If you are trying to experiment with this on your own, make sure you either download the JSON or try using jupyter or colab. The Reddit rate-limiting feature won't allow you to fetch the JSON data frequently.
It doesn't take more than a few seconds to merge. Once complete, enjoy the video.
Conclusion
In this post, we saw how to download a Reddit video along with its audio using python. There was nothing fancy in this approach; all we had to do was get the URL somehow.
If there's a better approach, please do tell.
I went ahead and created a python CLI named redl. Run,