diff options
author | David Vaughan <david@davidv.xyz> | 2022-03-21 21:06:36 -0700 |
---|---|---|
committer | David Vaughan <david@davidv.xyz> | 2022-03-21 21:06:36 -0700 |
commit | 065edd67fa86f150272301b6f57ccddf3a06fc6d (patch) | |
tree | 3e8e1d7636233d115f43db89a218a78670c0ace2 | |
parent | 88aa165d480859aa5e0af12c010e468875be1e86 (diff) | |
download | qutebrowser-065edd67fa86f150272301b6f57ccddf3a06fc6d.tar.gz qutebrowser-065edd67fa86f150272301b6f57ccddf3a06fc6d.zip |
Change cast configuration to use an env var
Also some other small improvements / fixes.
-rwxr-xr-x | misc/userscripts/cast | 34 |
1 files changed, 12 insertions, 22 deletions
diff --git a/misc/userscripts/cast b/misc/userscripts/cast index 2530ffbc7..ccbc78747 100755 --- a/misc/userscripts/cast +++ b/misc/userscripts/cast @@ -24,13 +24,10 @@ # yt-dlp (https://github.com/yt-dlp/yt-dlp). # # Configuration: -# This script loads the bash script ~/.config/qutebrowser/cast_rc (if -# it exists) or whatever file is specified in QUTE_CAST_CONFIG, so you can -# override the program used for downloading videos. -# -# For example: -# -# ytdl_program=yt-dlp +# This script looks at the optional QUTE_CAST_YTDL_PROGRAM environment +# variable (if it exists) to decide which program to use for downloading +# videos. If specified, this should be youtube-dl or a drop-in replacement +# for it. # # Author # Simon Désaulniers <sim.desaulniers@gmail.com> @@ -146,34 +143,27 @@ tmpdir=$(mktemp -d) file_to_cast=${tmpdir}/qutecast cast_program=$(command -v castnow) -# load optional config -QUTE_CONFIG_DIR=${QUTE_CONFIG_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/qutebrowser/} -QUTE_CAST_CONFIG=${QUTE_CAST_CONFIG:-${QUTE_CONFIG_DIR}/cast_rc} -if [ -f "$QUTE_CAST_CONFIG" ] ; then - # shellcheck source=/dev/null - source "$QUTE_CAST_CONFIG" -fi - -# if ytdl_program wasn't specified in config, use a fallback -for p in "$ytdl_program" yt-dlp youtube-dl; do - ytdl_program=$(command -v "$p") +# pick a ytdl program +for p in "$QUTE_CAST_YTDL_PROGRAM" yt-dlp youtube-dl; do + ytdl_program=$(command -v -- "$p") [ "$ytdl_program" == "" ] || break done if [[ "${cast_program}" == "" ]]; then - msg error "castnow can't be found..." + msg error "castnow can't be found" exit 1 fi if [[ "${ytdl_program}" == "" ]]; then - msg error "youtube-dl (or a drop-in replacement) can't be found..." + msg error "youtube-dl or a drop-in replacement can't be found in PATH, and no installed program "\ +"specified in QUTE_CAST_YTDL_PROGRAM (currently \\\"$QUTE_CAST_YTDL_PROGRAM\\\")" exit 1 fi # kill any running instance of castnow -pkill -f "${cast_program}" +pkill -f -- "${cast_program}" # start youtube download in stream mode (-o -) into temporary file -${ytdl_program} -qo - "$1" > "${file_to_cast}" & +"${ytdl_program}" -qo - "$1" > "${file_to_cast}" & ytdl_pid=$! msg info "Casting $1" >> "$QUTE_FIFO" |