aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpukkandan <pukkandan.ytdlp@gmail.com>2022-02-18 17:51:43 +0530
committerpukkandan <pukkandan.ytdlp@gmail.com>2022-02-18 18:03:21 +0530
commit8d93e69d67610bd0c250110cb4f10da93ecf3479 (patch)
treedd8b4f3daefcb7ea1bc79f6dda1dc983cee10f52
parent3aa915400d895a4a9c3123f1ab9508501f91ba0c (diff)
Create necessary directories for `--print-to-file`
Closes #2721
-rw-r--r--yt_dlp/YoutubeDL.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py
index d85748fc9..3a489ba96 100644
--- a/yt_dlp/YoutubeDL.py
+++ b/yt_dlp/YoutubeDL.py
@@ -2735,8 +2735,9 @@ class YoutubeDL(object):
filename = self.evaluate_outtmpl(file_tmpl, info_dict)
tmpl = format_tmpl(tmpl)
self.to_screen(f'[info] Writing {tmpl!r} to: {filename}')
- with io.open(filename, 'a', encoding='utf-8') as f:
- f.write(self.evaluate_outtmpl(tmpl, info_copy) + '\n')
+ if self._ensure_dir_exists(filename):
+ with io.open(filename, 'a', encoding='utf-8') as f:
+ f.write(self.evaluate_outtmpl(tmpl, info_copy) + '\n')
def __forced_printings(self, info_dict, filename, incomplete):
def print_mandatory(field, actual_field=None):