]> jfr.im git - yt-dlp.git/commitdiff
Do not translate newlines in `--print-to-file`
authorpukkandan <redacted>
Sun, 16 Apr 2023 03:24:48 +0000 (08:54 +0530)
committerpukkandan <redacted>
Sun, 16 Apr 2023 03:25:44 +0000 (08:55 +0530)
Fixes https://github.com/yt-dlp/yt-dlp/issues/6808#issuecomment-1509361107

yt_dlp/YoutubeDL.py

index 7b6fef2041d080f45acd34f21dbcec91bc2726d8..31f7645dca94ac2fd58a40aa021e1b266b02f5b0 100644 (file)
@@ -2890,8 +2890,8 @@ def format_tmpl(tmpl):
             tmpl = format_tmpl(tmpl)
             self.to_screen(f'[info] Writing {tmpl!r} to: {filename}')
             if self._ensure_dir_exists(filename):
-                with open(filename, 'a', encoding='utf-8') as f:
-                    f.write(self.evaluate_outtmpl(tmpl, info_copy) + '\n')
+                with open(filename, 'a', encoding='utf-8', newline='') as f:
+                    f.write(self.evaluate_outtmpl(tmpl, info_copy) + os.linesep)
 
     def __forced_printings(self, info_dict, filename, incomplete):
         def print_mandatory(field, actual_field=None):