Search code examples
pythonyoutube-dl

I can't convert command line params to ydl_opts for youtube_dl


I want to use youtube_dl inside a python code. In the command line I use this code: "youtube-dl --external-downloader ffmpeg --external-downloader-args "-ss 00:01:00.00 -to 00:02:00.00" -f best "https://www.youtube.com/watch?v=dc7I-i7sPrg""

How I can convert this code to Python:

ydl_opts = {

}

with YoutubeDL(ydl_opts) as ydl:
    ydl.download(url)

Thnx for helping.


Solution

  • ydl_opts = {
          'external_downloader': 'ffmpeg',
          'external_downloader_args': "-ss 00:01:00.00 -to 00:02:00.00",
          'format': 'best'
    }
    
    with YoutubeDL(ydl_opts) as ydl:
        ydl.download(url)
    

    Python arguments listed here.