diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2021-03-01 17:06:05 +0100 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2021-03-01 17:06:05 +0100 |
commit | 8c6760446bfd79b07966dc7a13ab5702311e6781 (patch) | |
tree | be30426207a336b80ec07be701d59bdcb75cea5e /.local/bin/linkview | |
parent | Update (diff) | |
download | dotfiles-bsd-8c6760446bfd79b07966dc7a13ab5702311e6781.tar.gz dotfiles-bsd-8c6760446bfd79b07966dc7a13ab5702311e6781.tar.bz2 dotfiles-bsd-8c6760446bfd79b07966dc7a13ab5702311e6781.tar.xz dotfiles-bsd-8c6760446bfd79b07966dc7a13ab5702311e6781.tar.zst dotfiles-bsd-8c6760446bfd79b07966dc7a13ab5702311e6781.zip |
Update
Diffstat (limited to '')
-rwxr-xr-x | .local/bin/linkview | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/.local/bin/linkview b/.local/bin/linkview index 0f4c38c..3f39ffc 100755 --- a/.local/bin/linkview +++ b/.local/bin/linkview @@ -42,6 +42,8 @@ sub open_link my $pwd; my $ret; my $tmp; + my $tmpfile; + my $val; my @wc; if ($a eq "mpv") { @@ -97,13 +99,34 @@ sub open_link '-u', 'low', '-t', '10000', 'download started', - ' <b>'. $file_name . '</b> started downloading' + ' <b>' . $file_name . '</b> started downloading' ); $ret = -1; if ($a eq "youtube-dl") { + $tmpfile = `mktemp`; + chomp $tmpfile; (undef, undef, $ret) = capture { - system(YTDL_PATH, '--add-metadata', $url); + system(YTDL_PATH . ' --newline --add-metadata ' . $url . ' >' . $tmpfile . ' &'); }; + while (1) { + $val = `tail -n 1 "$tmpfile" | awk '{print \$2}' | tr -d '%'`; + if (looks_like_number($val) != 0) { + system( + NOTIFYSEND_PATH, + '-h', + 'int:value:' . $val, + '-u', 'low', + '-t', '5000', + 'downloading', + ' downloading <b>' . $file_name . '</b>' + ); + if ($val == 100 || system('pgrep python >/dev/null 2>&1') != 0) { + last; + } + } + sleep 2; + } + unlink $tmpfile; } else { (undef, undef, $ret) = capture { |