Last modified: Feb 05, 2026 By Alexander Williams

Download Dailymotion Videos with Python

Do you want to save Dailymotion videos for offline viewing? Python makes it easy. This guide will show you how.

We will use a powerful library called yt-dlp. It handles many video sites, including Dailymotion.

You will learn to write a simple script. It will download videos in your chosen quality.

Why Download Dailymotion Videos?

Dailymotion is a popular video-sharing platform. Sometimes you need a video offline.

Maybe for a presentation, a slow internet area, or personal archiving. A Python script automates this.

It is a great project for beginners. You learn about web scraping and API interaction.

Prerequisites and Setup

First, you need Python installed on your computer. Version 3.6 or higher is recommended.

Next, install the required library. We will use yt-dlp. It is a fork of youtube-dl with more features.

Open your terminal or command prompt. Run the following command to install it.


pip install yt-dlp

This command fetches the library from PyPI. It installs it and its dependencies.

If you face issues, ensure pip is updated. You can also use a virtual environment for a clean setup.

Building the Basic Downloader

Let's write a simple Python script. It will download a video from a given Dailymotion URL.

Create a new Python file. Name it dailymotion_downloader.py.

We start by importing the yt_dlp module. Then we define a function.


import yt_dlp

def download_video(url):
    """
    Downloads a video from the provided Dailymotion URL.
    """
    # Options for the downloader
    ydl_opts = {}
    
    # Create a yt-dlp object with the options
    with yt_dlp.YoutubeDL(ydl_opts) as ydl:
        # Download the video
        ydl.download([url])
        print("Download completed!")

# Example usage
if __name__ == "__main__":
    video_url = "https://www.dailymotion.com/video/x8example"
    download_video(video_url)

This is the simplest form. The YoutubeDL class handles the heavy lifting. The download method starts the process.

Run the script. It will download the video to your current directory.

Adding Customization Options

The basic script works. But we can improve it. We can choose the download path and video quality.

We do this by modifying the ydl_opts dictionary. Let's look at a more advanced example.


import yt_dlp
import os

def download_video_custom(url, output_path='./downloads', quality='best'):
    """
    Downloads a video with custom output path and quality preference.
    
    Args:
        url (str): The Dailymotion video URL.
        output_path (str): Directory to save the video. Default is './downloads'.
        quality (str): Desired quality. Use 'best', 'worst', or a format ID.
    """
    
    # Create output directory if it doesn't exist
    if not os.path.exists(output_path):
        os.makedirs(output_path)
    
    # Configure download options
    ydl_opts = {
        'outtmpl': f'{output_path}/%(title)s.%(ext)s', # Save as video_title.ext
        'format': quality, # Choose video/audio quality
        'quiet': False, # Show progress and info
        'no_warnings': False, # Show warnings if any
    }
    
    try:
        with yt_dlp.YoutubeDL(ydl_opts) as ydl:
            # Extract info first (optional, for logging)
            info = ydl.extract_info(url, download=False)
            print(f"Downloading: {info.get('title', 'Unknown Title')}")
            
            # Now download the video
            ydl.download([url])
            print(f"Video saved successfully to {output_path}")
    except Exception as e:
        print(f"An error occurred: {e}")

# Example usage
if __name__ == "__main__":
    my_url = "https://www.dailymotion.com/video/x8example123"
    download_video_custom(my_url, output_path='./my_videos', quality='best')

This script is more robust. The outtmpl option sets the filename pattern. The format option selects quality.

We also added error handling with a try-except block. This is good practice for any Python script that interacts with the web.

Understanding the Output and Format Selection

How do you know which quality formats are available? yt-dlp can list them.

We can modify our function to show available formats before downloading. This helps you pick the right one.


def list_available_formats(url):
    """
    Lists all available video and audio formats for a given URL.
    """
    ydl_opts = {
        'quiet': True,
        'no_warnings': True,
        'listformats': True, # This key tells yt-dlp to list formats and exit
    }
    
    with yt_dlp.YoutubeDL(ydl_opts) as ydl:
        # This will print the list of formats and stop
        ydl.download([url])

# Example usage
if __name__ == "__main__":
    test_url = "https://www.dailymotion.com/video/x8test456"
    list_available_formats(test_url)

Run this function. It will print a table to your console. You will see format codes, extensions, and resolutions.

You can then use a specific format code in the quality parameter of the main download function.


[info] Available formats for x8test456:
format code  extension  resolution note
301          mp4        1280x720   720p video only
302          mp4        1920x1080  1080p video only
140          m4a        audio only

To download just the 1080p video, you would set quality='302'.

Best Practices and Legal Considerations

Automating downloads is powerful. You must use it responsibly.

Always respect copyright. Only download videos you have permission to save. This includes your own content or freely licensed material.

Check Dailymotion's Terms of Service. Automated downloading might be against their rules for some content.

For your code, add delays between requests. Do not overload Dailymotion's servers. This is ethical web scraping.

You can explore other Python libraries for web tasks, like requests for API calls or BeautifulSoup for parsing HTML.

Conclusion

You now know how to build a Dailymotion video downloader in Python. We used the yt-dlp library for its simplicity and power.

The basic script is just a few lines. The advanced version lets you control the output and quality.

Remember to use this knowledge ethically. Download only content you are authorized to keep offline.

This project is a great stepping stone. It introduces key concepts like using external libraries and handling web data.

Try enhancing the script. Add a GUI, a list of URLs from a file, or integrate it into a larger application. Happy coding!