scripts/appscripts/sxmo_youtube.sh: Switch back to using codemadness-frontends

We originally switched off codemadness-frontends / idiotbox because it was
no longer functional. Nowadays it works again and is substantially faster
then ytdl.

Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
master
Miles Alan 3 years ago committed by Maarten van Gompel
parent c427a0eb7b
commit f63852a801
  1. 24
      scripts/appscripts/sxmo_youtube.sh

@ -5,16 +5,16 @@
. "$(dirname "$0")/sxmo_common.sh" . "$(dirname "$0")/sxmo_common.sh"
HISTORY_FILE="$XDG_CACHE_HOME"/sxmo/youtubehistory.tsv HISTORY_FILE="$XDG_CACHE_HOME"/sxmo/youtubehistory.tsv
NRESULTS=5
AUDIOONLY=0 AUDIOONLY=0
youtubesearch() { youtubesearch() {
QUERY="$1" QUERY="$1"
NRESULTS="$2" youtube-cli "$QUERY" |
youtube-dl -f '[height<420]' -e --get-id --get-duration "ytsearch$NRESULTS:$QUERY" | grep -Ev '^(Channelid|Atom feed|Channel title|Published|Viewcount|Userid):' |
paste - - - -d ' ' | sed -E 's/^(URL|Duration):\s+/\t/g' |
awk -F" " '{DUR=$NF; NF-=1; print DUR " " $0}' | tr -d '\n' |
sed -E 's#([^ ]+)$#ytdl://\1#g' sed 's/===/\n/g' |
gawk -F'\t' '{ print $3 " " $1 " " $2}'
} }
searchmenu() { searchmenu() {
@ -27,10 +27,6 @@ searchmenu() {
ENTRY="$( ENTRY="$(
printf %b " printf %b "
Close Menu Close Menu
Show 1 Result $([ "$NRESULTS" = "1" ] && echo "$icon_chk")
Show 5 Results $([ "$NRESULTS" = "5" ] && echo "$icon_chk")
Show 10 Results $([ "$NRESULTS" = "10" ] && echo "$icon_chk")
Show 20 Results $([ "$NRESULTS" = "20" ] && echo "$icon_chk")
$HISTORY $HISTORY
" | " |
xargs -0 echo | xargs -0 echo |
@ -41,12 +37,10 @@ searchmenu() {
if [ "Close Menu" = "$ENTRY" ]; then if [ "Close Menu" = "$ENTRY" ]; then
exit 0 exit 0
elif echo "$ENTRY" | grep -E "Show [0-9]+ Results*"; then
NRESULTS="$(echo "$ENTRY" | grep -oE "[0-9]+")"
else else
ENTRY="$(echo "$ENTRY" | sed 's#^History: ##')" ENTRY="$(echo "$ENTRY" | sed 's#^History: ##')"
printf %b "$ENTRY\n" >> "$HISTORY_FILE" printf %b "$ENTRY\n" >> "$HISTORY_FILE"
youtubesearch "$ENTRY" "$NRESULTS" | resultsmenu youtubesearch "$ENTRY" | resultsmenu
fi fi
done done
} }
@ -64,7 +58,7 @@ resultsmenu() {
xargs -0 echo | xargs -0 echo |
sed '/^[[:space:]]*$/d' | sed '/^[[:space:]]*$/d' |
awk '{$1=$1};1' | awk '{$1=$1};1' |
dmenu -c -l 10 -p "Results" -fn Terminus-20 dmenu -c -l 10 -p "Results"
)" )"
if [ "Change Search" = "$PICKED" ]; then if [ "Change Search" = "$PICKED" ]; then
@ -91,4 +85,4 @@ audio() {
searchmenu searchmenu
} }
$1 "$@"

Loading…
Cancel
Save