youtube-dl specify output from python script?

3.4k views Asked by At

I'm following the documentation on using youtube-dl from a python script.

But I can't seem to get the output option, specifying the folder I want the download to go into to work:

ydl_opts = {'output':'video'}                                                                                                                           
with youtube_dl.YoutubeDL(ydl_opts) as ydl:                                                                                                         
  ydl.download([url])

I've also tried replacing output with o and -o.

1

There are 1 answers

0
AudioBubble On BEST ANSWER

outtmpl (not output) is a template for the video file name, not a directory. An output template value of 'video' instructs youtube-dl to write the video a file literally called video. Try something like

ydl_opts = {
    'outtmpl': '/home/philip/my/videos/%(title)s-%(id)s.%(ext)s',
}

If you want to know the name of further options, have a look at the list of options. For more information on the output template, refer to the documentation.