Reputation: 616
I'm using youtube-dl for a discord bot in python and it works fine, however it downloads the files to the root directory of the project. Since it will be downloading LOTS of videos, I would prefer for it to download to a directory inside of the root. How do I do this?
These are my current options:
ytdl_format_options = {
'format': 'bestaudio/best',
'outtmpl': '%(extractor)s-%(id)s-%(title)s.%(ext)s',
'reactrictfilenames': True,
'noplaylist': True,
'nocheckcertificate': True,
'ignoreerrors': False,
'logtostderr': False,
'quiet': True,
'no_warnings': True,
'default_search': 'auto',
'source_addreacs': '0.0.0.0', # bind to ipv4 since ipv6 addreacses cause issues sometimes
'output': r'youtube-dl'
}
ffmpeg_options = {
'before_options': '-nostdin',
'options': '-vn'
}
Upvotes: 7
Views: 12255
Reputation:
Set an output template containing slashes in the outtmpl
option:
ytdl_format_options = {
'outtmpl': 'somewhere/%(extractor_key)s/%(extractor)s-%(id)s-%(title)s.%(ext)s',
...
}
Output templates can have lots of fields (including playlist IDs, license, format name/bitrates, album name & much more, depending on what the video website you're using supports). For more information, refer to the youtube-dl documentation of output templates. All fields can be used as directory or file names.
Upvotes: 13