output redirected to file contains terminal sequences
See original GitHub issueChecklist
- I’m reporting a bug unrelated to a specific site
- I’ve verified that I’m running yt-dlp version 2022.03.08.1. (update instructions)
- I’ve checked that all provided URLs are alive and playable in a browser
- I’ve checked that all URLs and arguments with special characters are properly quoted or escaped
- I’ve searched the bugtracker for similar issues including closed ones. DO NOT post duplicates
- I’ve read the guidelines for opening an issue
Description
When redirecting yt-dlp’s output to a file terminal sequences are not suppressed. Either at the beginning or the end you will find strings like ]0;yt-dlp Concat started]0;yt-dlp Concat finished
.
Prerequisites to reproduce:
- run yt-dlp in POSIX shell (
$TERM=xterm-256color
) - use yt-dlp version >= 2022.1.21
- the url must refer to a playlist
- parameter
--console-title
is set - parameter
--concat-playlist
is set to always or multi_video
Verbose log
$ yt-dlp --no-config --verbose --console-title --dump-single-json https://www.youtube.com/channel/UCUBl5r0qPEY7130xVVWv6Zw > dump.json
[debug] Command-line config: ['--no-config', '--verbose', '--console-title', '--dump-single-json', 'https://www.youtube.com/channel/UCUBl5r0qPEY7130xVVWv6Zw']
[debug] Encodings: locale UTF-8, fs utf-8, out utf-8 (No ANSI), err utf-8, pref UTF-8
[debug] yt-dlp version 2022.03.08.2 [e491d06d3]
[debug] Python version 3.10.2 (CPython 64bit) - Linux-4.19.104-microsoft-standard-x86_64-with-glibc2.31
[debug] exe versions: ffmpeg 4.2.4, ffprobe 4.2.4
[debug] Optional libraries: brotli, Cryptodome, mutagen, sqlite, websockets
[debug] Proxy map: {}
[debug] [youtube:tab] Extracting URL: https://www.youtube.com/channel/UCUBl5r0qPEY7130xVVWv6Zw
[youtube:tab] UCUBl5r0qPEY7130xVVWv6Zw: Downloading webpage
[youtube:tab] A channel/user page was given. All the channel's videos will be downloaded. To download only the videos in the home page, add a "/featured" to the URL
[debug] [youtube:tab] Final URL: https://www.youtube.com/channel/UCUBl5r0qPEY7130xVVWv6Zw/videos
[download] Downloading playlist: Martin Schulz - Videos
[youtube:tab] playlist Martin Schulz - Videos: Downloading 0 videos
[download] Finished downloading playlist: Martin Schulz - Videos
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (8 by maintainers)
Top Results From Across the Web
Terminal Output Redirected to a File - Ask Ubuntu
The command you're executing ( minicom ) is using "VT100 Escape Sequences" to do cursor positioning. To remove the characters listed above, ...
Read more >Redirection – Introduction to the Command Line for Genomics
This command returns a lot of output to the terminal. Every single line in the SRR098026 file that contains at least 10 consecutive...
Read more >Prevent tput escape sequences when redirecting script output ...
I am facing a problem with this technique. I have 2 .sh scripts, both using the technique, and both echoing colored output. The...
Read more >Command output redirect to file and terminal - Stack Overflow
I am doing following and it appending to file but not printing ls output on terminal. $ls 2>&1 > /tmp/ls.txt. linux · bash...
Read more >The Shell: Searching and Redirection - GitHub Pages
The redirection command for writing something to file is > . Let's try it out and put all the sequences that contain 'NNNNNNNNNN'...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
In UNIX, console title is set by sending a code to stdout. I can’t figure out how to change the title when stdout is being piped to a file. So for now, I’ll just forcefully disable
--console-title
in such casesPerfect. We can catch and check the error number. Due to https://github.com/yt-dlp/yt-dlp/commit/cf4f42cb9776eaa3166d2d234c3ec7651f05d7a9, this is the only thing that’d need to be changed: https://github.com/yt-dlp/yt-dlp/blob/592b748582f67309ac79670ba6a4bb7a62c4506f/yt_dlp/YoutubeDL.py#L548-L549