Search code examples
pythonloggingyoutube-dl

Is there a way to keep youtube_dl from printing its status to the console?


When I use the youtube_dl library in a Python script to download a video, it prints the following in the console:

[youtube] [video]: Downloading webpage
[youtube] Downloading just video [video] because of --no-playlist
[download] Destination: [destination]
[download] 100% of 3.00MiB in 00:00
[ffmpeg] Post-process file [destination] exists, skipping

Is there a way to stop it from doing this?

youtube_dl doesn't seem to use the standard Python logging library, so I can't do this:

youtube_logger = logging.getLogger('youtube_dl')
youtube_logger.setLevel(logging.WARNING)

Is there any way to keep youtube_dl from printing to the console?


Solution

  • Turns out there's an option called Quiet Mode that does just this! Here's how it works:

    ydl_opts = {
        'quiet': True
    }
    
    youtube_dl_manager = youtube_dl.YoutubeDL(ydl_opts)
    

    And then you can use the YoutubeDL object normally, without it printing to the console!