]> git.rmz.io Git - dotfiles.git/commitdiff
mutt: first check if all selected videos are playable
authorSamir Benmendil <me@rmz.io>
Sun, 24 Nov 2019 14:27:43 +0000 (14:27 +0000)
committerSamir Benmendil <me@rmz.io>
Sun, 24 Nov 2019 14:27:43 +0000 (14:27 +0000)
This makes it easier to figure out which video doesn't exist anymore and
remove the mail containing it from the selection.

mutt/mutt_mpv

index e4d8edfd0303f45f82602a0399300346690841ed..3f62e56eada1f6b1bff2378168f2fe101e552ba4 100755 (executable)
@@ -2,8 +2,13 @@
 
 urls=( $(grep -Eo '^https?://www.youtube.com/watch\?v=[[:alnum:]_-]{11}' </dev/stdin) )
 
-if youtube-dl -qs "${urls[@]}"; then
-    mpv --no-terminal "${urls[@]}" &
-else
-    exit $?
-fi
+for url in ${urls[@]}; do
+    youtube-dl -qs "${url[@]}"
+    errno=$?
+    if [[ $errno -ne 0 ]]; then
+        echo "Failed at $url"
+        exit $errno
+    fi
+done
+
+mpv --no-terminal "${urls[@]}" &