Skip to content

Commit

Permalink
extras: Update extras/mpvc-tui -s to suggest random song
Browse files Browse the repository at this point in the history
  • Loading branch information
gmt4 committed Apr 30, 2023
1 parent 2415e6f commit 3374014
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion extras/mpvc-tui
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,29 @@ mpvctui_notify()
} '
}

mpvctui_suggest()
{
awk '
BEGIN {
srand()
}
! /https:/ {
gsub($1,"")
gsub($1,"")
if(length($0) > 0)
{
tracks[n++]=$0
seen[$0]++
}
}
END {
r=int(rand() * n)
t=tracks[r]
print r,seen[t],t
}
' "$MPVC_SCROBBLER"
}

mpvctui_usage()
{
echo "usage: $PROGNAME -[$optflags] args # @version $PROGVERSION (c) $PROGAUTHOR $PROGURL"
Expand All @@ -184,7 +207,7 @@ mpvctui_usage()
exit;
}

optflags="d:htTm:nN:P:x"
optflags="d:htTm:nN:sP:x"
mpvctui_main()
{
mpvctui_config
Expand All @@ -204,6 +227,7 @@ mpvctui_main()
m) shift; mpvctui_notify "$OPTARG" ;;
n) shift; mpvc idleloop | mpvctui_notify ;;
N) shift; mpvc idleloop | mpvctui_notify "$OPTARG" ;;
s) shift; mpvctui_suggest ;;
x) shift; quiet command -v $MPVC_TERM && $MPVC_TERM -e "$0" "$@"; exit;;
*) mpvctui_usage;;
esac
Expand Down

0 comments on commit 3374014

Please sign in to comment.