Download YouTube video using Python to a certain directory

前端 未结 10 2263
醉话见心
醉话见心 2020-12-07 17:08

I have tried the following code to download a video in YouTube and it is working, but I want to save the video at a particular location. Now it is saving the video in

10条回答
  •  没有蜡笔的小新
    2020-12-07 17:52

    Path = "The Path That You Want"
    Location = '%s \%(extractor)s-%(id)s-%(title)s.%(ext)s'.replace("%s ", Path)
    ytdl_format_options = {
    'outtmpl': Location
    }
    
    with youtube_dl.YoutubeDL(ytdl_format_options) as ydl:
         ydl.download(['https://www.youtube.com/watch?v=n06H7OcPd-g'])
    

    I personally don't know the library very well, but here is my knowledge the youtube_dl have ytdl_format_options it gives you the options to add some I don't know what it called but let say parameters like above outtmp1 give you the option to specify the location, id, title, or quiet to see the log or not and there is so much more. almost everything you can get it from this URL:https://github.com/ytdl-org/youtube-dl/blob/master/README.md#format-selection

提交回复
热议问题