Search code examples
pythonlinuxpathvirtualenvyoutube-dl

Unable to change Youtube-dl Download Folder


I am invoking youtube-dl from a python program on Debian. I am using virtual environments for the modules. I have setup my options and I am unable to change the path that the file is downloaded to using 'outmp1'. I have tried to change it to a folder that was within the same folder as the source file and virtual environment with no luck, and I have tried just putting the whole path into the 'outmp1' option instead of the path_folder + '%(title)s.%(ext)s' Again with no luck. The file just keeps getting downloaded to the same directory that the python file is in. Here is the code snippet where I am defining the options:

path_folder = '/home/user/Desktop/Music/2021Playlist/'
    yd1_opts = {
        'format': 'bestaudio/best',
        'outmp1': path_folder + '%(title)s.%(ext)s',
        'postprocessors': [{
            'key': 'FFmpegExtractAudio',
            'preferredcodec': 'mp3',
            'preferredquality': '192',
            }]}

Any help will be appreciated.


Solution

  • It's outtmpl not outmp1

    Example:

    ytdl_options = {
            'format': 'bestaudio/best',
            'outtmpl': 'Sounds/%(title)s.%(ext)s',
            'postprocessors': [{
                'key': 'FFmpegExtractAudio',
                'preferredcodec': 'vorbis',
                'preferredquality': '192',
            }],
        }
    

    You can find the list of all available options here: https://github.com/ytdl-org/youtube-dl/blob/master/youtube_dl/YoutubeDL.py#L128-L278