How to add youtube-dl file download progress percentage to zenity progress bar
sample code (just an example, not a working one)
#!/bin/sh
(
progress=$(youtube-dl --extract-audio --audio-quality 0 --newline --audio-format mp3 https://www.youtube.com/playlist?list=PL1C815DB73EC2678E)
per=$(awk '{print perc}' <<<$progress)
time=$(awk '{print time}' <<<$progress)
file_no=$(awk '{print file_no}' <<<$progress) #only for playlist, example=Downloading video 1 of 4
echo "$per" ; sleep 1
echo "# $file_no \n Time Left: $time" ; sleep 1
) |
zenity --progress \
--title="Download" \
--text="Downloading..." \
--percentage=0
if [ "$?" = -1 ] ; then
zenity --error \
--text="Download cancelled."
fi
i have used this code to get download progress
youtube-dl --extract-audio --audio-quality 0 --newline --audio-format mp3 https://www.youtube.com/playlist?list=PL1C815DB73EC2678E
This is the out put
[youtube:playlist] PL1C815DB73EC2678E: Downloading webpage
[download] Downloading playlist: Less than 1 minute
[youtube:playlist] playlist Less than 1 minute: Collected 4 video ids (downloading 4 of them)
[download] Downloading video 1 of 4
[youtube] KNLwsqzFfNg: Downloading webpage
[youtube] KNLwsqzFfNg: Extracting video information
[youtube] KNLwsqzFfNg: Downloading DASH manifest
download] Destination: _1 min. - Amendes pour les particules du LHC-KNLwsqzFfNg.m4a
[download] 0.4% of 231.51KiB at 6.10KiB/s ETA 00:30
[download] 1.1% of 231.51KiB at 27.07KiB/s ETA 00:10
[download] 4.0% of 231.51KiB at 19.24KiB/s ETA 00:04
[download] 6.5% of 231.51KiB at 75.06KiB/s ETA 00:03
[download] 13.4% of 231.51KiB at 98.22KiB/s ETA 00:03
[download] 28.7% of 231.51KiB at 81.40KiB/s ETA 00:02
[download] 61.7% of 231.51KiB at 91.56KiB/s ETA 00:01
[download] 86.2% of 231.51KiB at 82.96KiB/s ETA 00:00
[download] 100.0% of 231.51KiB at 73.21KiB/s ETA 00:00
[download] 100% of 231.51KiB in 00:02
[ffmpeg] Correcting container in "_1 min. - Amendes pour les particules du LHC-KNLwsqzFfNg.m4a"
WARNING: Your copy of avconv is outdated, update avconv to version 10-0 or newer if you encounter any errors.
[avconv] Destination: _1 min. - Amendes pour les particules du LHC-KNLwsqzFfNg.mp3
WARNING: Your copy of avconv is outdated, update avconv to version 10-0 or newer if you encounter any errors.
Deleting original file _1 min. - Amendes pour les particules du LHC-KNLwsqzFfNg.m4a (pass -k to keep)
[download] Downloading video 2 of 4
[youtube] wTvXkMpJflk: Downloading webpage
[youtube] wTvXkMpJflk: Extracting video information
[youtube] wTvXkMpJflk: Downloading DASH manifest
etc..
etc..
.
.
and i want only
Downloading video 1 of 4 [download] Downloading video 2 of 4
as $files_no
FIRST FILE
file_no= Downloading video 1 of 4
per time rate
0.40% 00:30:00 6.10KiB/s
1.10% 00:10:00 27.07KiB/s
4.00% 00:04:00 19.24KiB/s
6.50% 00:03:00 75.06KiB/s
13.40% 00:03:00 98.22KiB/s
28.70% 00:02:00 81.40KiB/s
61.70% 00:01:00 91.56KiB/s
86.20% 00:00:00 82.96KiB/s
100.00% 00:00:00 231.51KiB/s
SECOND, THIRD...FILES
As separate variable $file, $per, $time
i know we can use awk
but for this complicated output how should i use it. if all parameters are not possible, can at least percentage and file_no be extracted.
grep
,awk
,sed
,tail
, etc. Note there is already a existing youtube-dl GUI program, though it probably does not have this functionalityawk
commands won't return any output, you're printing undefined variables. WHat exactly do you want in each of those variables and what do you want passed tozenity
?awk
is just a dummy command in the above code..I want to show an example script other than that it has no function.