Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to automatically create a directory #79

Open
PDSCi996 opened this issue Jan 27, 2021 · 4 comments
Open

How to automatically create a directory #79

PDSCi996 opened this issue Jan 27, 2021 · 4 comments

Comments

@PDSCi996
Copy link

I changed the 21st line of the "youtube-dl-server.py" configuration file to "'YDL_OUTPUT_TEMPLATE':'/youtube-dl/%%(uploader)s/(title)s.%(ext)s', ", so that the video file will automatically create a directory named after the channel name after downloading, and copy this file into it, but if you download a playlist composed of different channels, multiple directories will be created. In youtube-dl-server.py, set parameters like "'YDL_OUTPUT_TEMPLATE_PLAYLIST':'/youtube-dl/%(playlist)s/%(playlist_index)s-%(title)s.%(ext)s', When downloading a playlist, only one directory will be created with the name of the playlist.
Thanks a lot.

@ladudu
Copy link

ladudu commented Feb 19, 2021

I made some changes but I don’t know that meets your needs?
`
app_defaults = {
"YDL_FORMAT": "bestvideo+bestaudio/best",
"YDL_EXTRACT_AUDIO_FORMAT": None,
"YDL_EXTRACT_AUDIO_QUALITY": "192",
"YDL_RECODE_VIDEO_FORMAT": None,
"YDL_OUTPUT_TEMPLATE": "/youtube-dl/%(title).200s [%(id)s].%(ext)s",
"YDL_OUTPUT_TEMPLATE_PLAYLIST": "/youtube-dl/%(playlist)s/%(playlist_index)s-%(title)s.%(ext)s",
"YDL_ARCHIVE_FILE": None,
"YDL_SERVER_HOST": "0.0.0.0",
"YDL_SERVER_PORT": 8080,
"YDL_UPDATE_TIME": "True",
}

def get_ydl_options(request_options,url):
...
outtmpl = ydl_vars["YDL_OUTPUT_TEMPLATE"]
if "list=" in url:
outtmpl = ydl_vars["YDL_OUTPUT_TEMPLATE_PLAYLIST"]

return {
"format": ydl_vars["YDL_FORMAT"],
"postprocessors": postprocessors,
"outtmpl": outtmpl,
"download_archive": ydl_vars["YDL_ARCHIVE_FILE"],
"updatetime": ydl_vars["YDL_UPDATE_TIME"] == "True",
}
def download(url, request_options):
print(url)
with YoutubeDL(get_ydl_options(request_options,url)) as ydl:
ydl.download([url])
`

@PDSCi996
Copy link
Author

I made some changes but I don’t know that meets your needs?
`
app_defaults = {
"YDL_FORMAT": "bestvideo+bestaudio/best",
"YDL_EXTRACT_AUDIO_FORMAT": None,
"YDL_EXTRACT_AUDIO_QUALITY": "192",
"YDL_RECODE_VIDEO_FORMAT": None,
"YDL_OUTPUT_TEMPLATE": "/youtube-dl/%(title).200s [%(id)s].%(ext)s",
"YDL_OUTPUT_TEMPLATE_PLAYLIST": "/youtube-dl/%(playlist)s/%(playlist_index)s-%(title)s.%(ext)s",
"YDL_ARCHIVE_FILE": None,
"YDL_SERVER_HOST": "0.0.0.0",
"YDL_SERVER_PORT": 8080,
"YDL_UPDATE_TIME": "True",
}

def get_ydl_options(request_options,url):
...
outtmpl = ydl_vars["YDL_OUTPUT_TEMPLATE"] if "list=" in url: outtmpl = ydl_vars["YDL_OUTPUT_TEMPLATE_PLAYLIST"]
return {
"format": ydl_vars["YDL_FORMAT"],
"postprocessors": postprocessors,
"outtmpl": outtmpl,
"download_archive": ydl_vars["YDL_ARCHIVE_FILE"],
"updatetime": ydl_vars["YDL_UPDATE_TIME"] == "True",
}
def download(url, request_options):
print(url)
with YoutubeDL(get_ydl_options(request_options,url)) as ydl:
ydl.download([url])
`

Thank you very much for your reply, but is the part in bold you rewritten? Also, have you tested it?

@ladudu
Copy link

ladudu commented Feb 22, 2021

Yes, I did simple test.

@twist3dimages
Copy link

Would this be saved as config.yml somewhere?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants