A Python class for downloading Bunny CDN's "DRM" videos using yt-dlp.
You'll need to install yt-dlp
and requests
modules in your Python environment.
pip install -r requirements.txt
It is also better to have FFmpeg installed on your system and its executable added to the PATH environment variable.
To try the script for testing and demonstration, simply paste the iframe embed page URL at the bottom, where indicated between the quotes, as well as the webpage referer, and run the script.
python3 b-cdn-drm-vod-dl.py
Embed link structure:
https://iframe.mediadelivery.net/embed/{video_library_id}/{video_id}
By default:
- the highest resolution video is to be downloaded. You can change this behavior in the
main_playlist
function located under theprepare_dl
method. - The video will be downloaded in the
~/Videos/Bunny CDN/
directory. This configuration can be changed by providing thepath
argument when instantiating a newBunnyVideoDRM
object. - The video file name will be extracted from the embed page. This can be overridden by providing the
name
argument .
Please note that the video format will be always
mp4
.
The idea is all about simulating what's happening in a browser.
The program runs a sequence of requests tied to a session object (for cookie persistence and connection pooling) first of which is the embed page request, from which information are extracted such as the video name.
After that, the download link (an HLS/M3U8 URL) is ready to be fed to yt-dlp
to download the video segments, decrypt
them (as Bunny CDN's "DRM" videos are encrypted with the AES-128 algorithm), and merge them into a single playable video
file.