From 5a0f01c7d8e4feb975eb2a8864392b542db92a9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20D=C3=A9saulniers?= Date: Thu, 15 May 2025 12:49:41 -0400 Subject: [PATCH] view_in_mpv: fix errors from shellcheck (ci) --- misc/userscripts/view_in_mpv | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/misc/userscripts/view_in_mpv b/misc/userscripts/view_in_mpv index 9b4e0d184..e815d4ab8 100755 --- a/misc/userscripts/view_in_mpv +++ b/misc/userscripts/view_in_mpv @@ -69,8 +69,7 @@ IFS=" " read -r -a yt_dlp_video_command <<< "$YTDLP_COMMAND $YT_DLP_FLAGS" IFS=" " read -r -a yt_dlp_audio_command <<< "$YTDLP_COMMAND $YT_DLP_AUDIO_FLAGS" program_name=$0 options='fu:' loptions='fast,url' -getopt_out=$(getopt --name $program_name --options $options --longoptions $loptions -- "$@") -if (( $? != 0 )); then exit 1; fi +if ! getopt_out=$(getopt --name "$program_name" --options "$options" --longoptions "$loptions" -- "$@"); then exit 1; fi #sets the positionnal parameters with getopt's output eval set -- "$getopt_out" @@ -187,9 +186,9 @@ fi msg info "Opening $URL with mpv" if [[ $USE_YTDLP_FOR_DOWNLOAD == "yes" ]]; then - mkdir -p $HOME/.cache/qutebrowser/view_in_mpv - tmpdir=$(mktemp -p $HOME/.cache/qutebrowser/view_in_mpv -d) - ( cd $tmpdir && "${yt_dlp_audio_command[@]}" -o - "$URL" >$tmpdir/ytdlp_audio ) & + mkdir -p "$HOME/.cache/qutebrowser/view_in_mpv" + tmpdir=$(mktemp -p "$HOME/.cache/qutebrowser/view_in_mpv" -d) + ( cd "$tmpdir" && "${yt_dlp_audio_command[@]}" -o - "$URL" >"$tmpdir/ytdlp_audio" ) & audio_ytdlp_pid=$! sleep 2 @@ -199,7 +198,7 @@ if [[ $USE_YTDLP_FOR_DOWNLOAD == "yes" ]]; then "${yt_dlp_video_command[@]}" -o - "$URL" | "${video_command[@]}" --title="$(yt-dlp --cookies-from-browser chromium:~/.local/share/qutebrowser --get-title "$URL") - mpv" "$@" - ps $audio_ytdlp_pid >/dev/null && kill $audio_ytdlp_pid - rm -rf $tmpdir + rm -rf "$tmpdir" else "${video_command[@]}" "$@" "$URL" fi