A simple Python script to download videos from Dailymotion using their metadata API and ffmpeg.
This tool fetches video metadata from Dailymotion's internal API, extracts the M3U8 stream URL, and downloads the video directly using ffmpeg. It's designed to be straightforward and reliable - no fancy UI, just gets the job done.
- Python 3.6+
- ffmpeg (must be installed and accessible in your PATH)
requestslibrary
- Clone this repository:
git clone https://github.com/yourusername/DailymotionDownloader.git
cd DailymotionDownloader- Install the required Python package:
pip install requests- Make sure ffmpeg is installed:
# On Ubuntu/Debian
sudo apt install ffmpeg
# On macOS with Homebrew
brew install ffmpeg
# On Windows, download from https://ffmpeg.org/download.htmlpython cli.py "https://www.dailymotion.com/video/your-video-id"python cli.pyThe script will ask you to enter the Dailymotion video URL.
- Extracts video ID from the Dailymotion URL
- Fetches metadata using Dailymotion's player API
- Finds the M3U8 stream from the metadata
- Downloads directly using ffmpeg (no manual segment handling)
- Fallback encoding if direct copy fails
- ✅ Direct M3U8 stream download
- ✅ Automatic fallback to re-encoding if needed
- ✅ Skip download if file already exists
- ✅ Clean error handling
- ✅ No manual segment stitching required
Videos are saved as output_video.mp4 in the current directory. The script will skip downloading if the file already exists.
"Failed to fetch M3U8 file": The video might be geo-blocked or the URL format has changed.
ffmpeg errors: Make sure ffmpeg is properly installed and accessible from your command line.
JSON decode errors: The Dailymotion API might have changed or the video might not be available.
This script uses Dailymotion's internal metadata API endpoint. While this works well currently, keep in mind that internal APIs can change without notice. The script includes error handling for common issues, but you might need to update it if Dailymotion changes their API structure.
The download process uses ffmpeg's native HLS support, which handles stream discontinuities much better than manual segment downloading and joining.
This project is for educational purposes. Please respect Dailymotion's terms of service and only download videos you have permission to download.
Feel free to submit issues or pull requests if you find bugs or want to improve the code!