I've seen many similar questions, but none really works for me.
I have a simple script that downloads latest 2 video episodes from one channel, so I can watch them later on mobile in offline mode. It uses yt-dlp command with -w switch not to overwrite if video exists. I would like to colorize "Destination" so I see more clearly file name, and "has already been downloaded" if file has already been downloaded.
So my script looks like this:
cd /tmp
EPI=$(curl -s https://rumble.com/c/robbraxman | grep -m 2 "href=/\v"| awk '{print $5}' |awk -F\> '{print $1}')
for i in ${EPI//href=/http://rumble.com}; do
printf "\e[1;38;5;212m Downloading \e[1;38;5;196m $i\e[m \n"
yt-dlp -f mp4-480p -w $i
done
output of the yt-dlp is like:
[Rumble] Extracting URL: http://rumble.com/v2820uk-let-me-show-you-brax.me-privacy-focused-app.html
[Rumble] v2820uk-let-me-show-you-brax.me-privacy-focused-app.html: Downloading webpage
[RumbleEmbed] Extracting URL: https://rumble.com/embed/v25g3g0
[RumbleEmbed] v25g3g0: Downloading JSON metadata
[info] v25g3g0: Downloading 1 format(s): mp4-480p
[download] Let Me Show You Brax.Me - Privacy Focused App [v25g3g0].mp4 has already been downloaded
[download] 100% of 20.00MiB
[Rumble] Extracting URL: http://rumble.com/v2820uk-let-me-show-you-brax.me-privacy-focused-app.html
[Rumble] v2820uk-let-me-show-you-brax.me-privacy-focused-app.html: Downloading webpage
[RumbleEmbed] Extracting URL: https://rumble.com/embed/v25g3g0
[RumbleEmbed] v25g3g0: Downloading JSON metadata
[info] v25g3g0: Downloading 1 format(s): mp4-480p
[download] Destination: Let Me Show You Brax.Me - Privacy Focused App [v25g3g0].mp4
[download] 3.8% of 525.67MiB at 5.79MiB/s ETA 01:27^C
So I would probably need to pipe output somehow, and then color it. yt-dlp actually colors progress when downloading. I've tried to put grc in front of yt-dlp but didn't color it.
yt-dlpso I'm not sure if/howyt-dlp'scolorization may interact with your desired colorization so fwiw .... this answer may be of interest if the objective is to apply different colors to various strings in the output streaming from theyt-dlpcallawkscript from that linked answer) in a function and then have your feed theyt-dlpoutput to the function; ymmv ...