This makes it easier to figure out which video doesn't exist anymore and
remove the mail containing it from the selection.
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[@]}" &