From c116b8f58904e4849611c063d4ceac267dfb1fe1 Mon Sep 17 00:00:00 2001 From: Riyyi Date: Mon, 21 Mar 2022 14:11:52 +0100 Subject: [PATCH] Scripts: Fix quality flag for Twitch URLs --- .local/bin/play | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/.local/bin/play b/.local/bin/play index 69c8321..8858975 100755 --- a/.local/bin/play +++ b/.local/bin/play @@ -32,7 +32,7 @@ ${B}OPTIONS${N} ${B}-f${N}, ${B}--shuffle${N} [${U}URLS${N}...] Shuffle audio playlist (disables video playback). - ${B}-q${N}, ${B}--queue${N} [${U}URLS${N}...] + ${B}-u${N}, ${B}--queue${N} [${U}URLS${N}...] Add multiple videos to the unique mpv's queue. ${B}-s${N}, ${B}--stream${N} [${U}URLS${N}...] @@ -46,6 +46,18 @@ EOF # -------------------------------------- qualityFormat() { + url="$1" + + # Twitch urls dont support fancy matching + if echo "$url" | grep -q "twitch\.tv"; then + if [ -z "$quality" ]; then + echo "Source" + else + echo "$quality" + fi + return + fi + # , separator = download several formats # + separator = merge several formats into a single file # / separator = or @@ -70,7 +82,7 @@ play() { notify-send -t 2500 "Loading video: $url" setsid -f mpv --no-terminal \ - --ytdl-format="$(qualityFormat)" \ + --ytdl-format="$(qualityFormat "$url")" \ --ytdl-raw-options=add-metadata=,external-downloader=aria2c \ "$url" } @@ -108,7 +120,7 @@ queue() { notify-send -t 2500 "Loading video: $urls" # shellcheck disable=2086 setsid -f mpv $options \ - --ytdl-format="$(qualityFormat)" \ + --ytdl-format="$(qualityFormat $urls)" \ --ytdl-raw-options=add-metadata=,external-downloader=aria2c \ $urls fi