Skip to content

Commit 3374014

Browse files
committed
extras: Update extras/mpvc-tui -s to suggest random song
1 parent 2415e6f commit 3374014

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

extras/mpvc-tui

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,29 @@ mpvctui_notify()
173173
} '
174174
}
175175

176+
mpvctui_suggest()
177+
{
178+
awk '
179+
BEGIN {
180+
srand()
181+
}
182+
! /https:/ {
183+
gsub($1,"")
184+
gsub($1,"")
185+
if(length($0) > 0)
186+
{
187+
tracks[n++]=$0
188+
seen[$0]++
189+
}
190+
}
191+
END {
192+
r=int(rand() * n)
193+
t=tracks[r]
194+
print r,seen[t],t
195+
}
196+
' "$MPVC_SCROBBLER"
197+
}
198+
176199
mpvctui_usage()
177200
{
178201
echo "usage: $PROGNAME -[$optflags] args # @version $PROGVERSION (c) $PROGAUTHOR $PROGURL"
@@ -184,7 +207,7 @@ mpvctui_usage()
184207
exit;
185208
}
186209

187-
optflags="d:htTm:nN:P:x"
210+
optflags="d:htTm:nN:sP:x"
188211
mpvctui_main()
189212
{
190213
mpvctui_config
@@ -204,6 +227,7 @@ mpvctui_main()
204227
m) shift; mpvctui_notify "$OPTARG" ;;
205228
n) shift; mpvc idleloop | mpvctui_notify ;;
206229
N) shift; mpvc idleloop | mpvctui_notify "$OPTARG" ;;
230+
s) shift; mpvctui_suggest ;;
207231
x) shift; quiet command -v $MPVC_TERM && $MPVC_TERM -e "$0" "$@"; exit;;
208232
*) mpvctui_usage;;
209233
esac

0 commit comments

Comments
 (0)