J'ai besoin d'intimité. Non pas parce que mes actions sont douteuses, mais parce que votre jugement et vos intentions le sont.
youtube-dl
is running in the background, but it is still sending output to your terminal, and producing quite a lot of it to inform you of its progress. There are a number of ways to change this, but you'll probably either want to make youtube-dl produce less output, or cause its output to be sent to a file (or discarded altogether) instead of appearing in your terminal.
Way 1: Run youtube-dl -q
to suppress status messages.
If you don't want to see the progress messages, you can pass the -q
flag (or --quiet
, which does the same thing) to the youtube-dl command:
youtube-dl -q https ://www.youtube.com/watch?v=NZ-ElsvYKyo &
You'd have to replace that URL with whatever you're trying to download, of course. Some messages may still be printed, including errors and warnings. But it's likely you want to see those.
If you don't want youtube-dl to produce any warnings, you can run youtube-dl with the --no-warnings
flag. I don't suggest doing that, though, unless you're sure that's what you want.
youtube-dl -q --no-warnings https ://www.youtube.com/watch?v=NZ-ElsvYKyo &
To learn more about the command-line options accepted by youtube-dl, you can run man youtube-dl or read its manual page online.
Way 2: Redirect standard output of youtube-dl to a file.
To append the output to dl.log in the current directory (you can name this what you want, and it will be created if it doesn't already exist), run:
youtube-dl https ://www.youtube.com/watch?v=NZ-ElsvYKyo >> dl.log&
If you want to overwrite dl.log instead of appending text to the end, use >
instead of >>
:
youtube-dl https ://www.youtube.com/watch?v=NZ-ElsvYKyo > dl.log &
Normal output will then be redirected to dl.log (or whatever file you tell it to use). Error output, however, will still be shown on your terminal. For example, when I ran that command, I got one warning printed to my terminal:
ek@Io:~$ youtube-dl https ://www.youtube.com/watch?v=NZ-ElsvYKyo >> dl.log &
[1] 14456
ek@Io:~$ WARNING: Requested formats are incompatible for merge and will be merged into mkv
Everything else went into the log file:
ek@Io:~$ cat dl.log
[youtube] NZ-ElsvYKyo: Downloading webpage
[youtube] NZ-ElsvYKyo: Downloading video info webpage
[youtube] NZ-ElsvYKyo: Extracting video information
[youtube] NZ-ElsvYKyo: Downloading MPD manifest
[download] Destination: Lecture 1 _ Topics in String Theory-NZ-ElsvYKyo.f244.webm
[download] 23.2% of 359.52MiB at 204.49KiB/s ETA 23:02ek@Io:~$
You can view the output with cat (as I've done above) at any time, to check the progress.
When you run youtube-dl without -q
, it produces output that is primarily meant for a terminal. This output includes control characters that tell a terminal to erase the previous progress message, so that it may be visually replaced with the new progress message. Some ways of viewing the file, like cat dl.log, will not show the "erased" messages or the control characters. They're still part of the file, though, and you can view them with some other utilities; for example, view dl.log works.
Way 2a: Redirect the output to /dev/null
to get rid of it.
If you want the output to just be discarded rather than saved in an actual file, then you can redirect it to /dev/null
:
youtube-dl https ://www.youtube.com/watch?v=NZ-ElsvYKyo > /dev/null &
With /dev/null
, it doesn't matter if you "overwrite" (>
) or "append" (>>
).
This is a handy technique in general, though probably unnecessary with youtube-dl. If you want to suppress progress, you can just run youtube-dl -q
instead.
Way 3: Redirect standard error, too.
Regular output and error output are separate. It's common for youtube-dl to produce both. The above method redirected only standard output. You can also redirect standard error. There's a lot you can do with redirection, including redirecting the two output streams to separate files. For our purposes here, I'll just show how to send both standard output and standard error to the same file:
youtube-dl https ://www.youtube.com/watch?v=NZ-ElsvYKyo &>> dl.log &
When I ran that, my shell showed only
[2] 15009
...and both regular output and error output appeared in dl.log:
ek@Io:~$ cat dl.log
[youtube] NZ-ElsvYKyo: Downloading webpage
[youtube] NZ-ElsvYKyo: Downloading video info webpage
[youtube] NZ-ElsvYKyo: Extracting video information
[youtube] NZ-ElsvYKyo: Downloading MPD manifest
WARNING: Requested formats are incompatible for merge and will be merged into mkv.
[download] Destination: Lecture 1 _ Topics in String Theory-NZ-ElsvYKyo.f244.webm
[download] 0.0% of 359.52MiB at 107.65KiB/s ETA 56:59ek@Io:~$
The above example used &>>
, which appends to dl.log. To overwrite the file instead, use &>
(or >&
, which also works) instead of &>>
:
youtube-dl https ://www.youtube.com/watch?v=NZ-ElsvYKyo &> dl.log &
Way 3a: Redirect both normal and error output to /dev/null
.
If you really want to, you can redirect both standard output and standard error to /dev/null
so it is all simply discarded:
youtube-dl https ://www.youtube.com/watch?v=NZ-ElsvYKyo &> /dev/null &
You probably want to see actual error messages, though. If it's just status messages and warnings you don't want, then you don't need any redirection. In that case you can use youtube-dl -q --no-warnings
as described above. (See Way 1.)