Just annotations of little "how to's", so I know I can find how to do something I've already done when I need to do it again, in case I don't remember anymore, which is not unlikely. Hopefully they can be useful to others, but I can't guarantee that it will work, or that it won't even make things worse.
Random song constrained by keyword on MPC
Save it as a script, perhaps even as an alias:
Then type at some terminal:
mpcr[andom] <artist/keyword>
(or however you chose to name/alias it)
And mpc will play a random song from the pool resulting from the keyword filter.
I guess the whole chain of pipes could probably be elegantly replaced by some awesome sed parameter, but that will do it as it is, anyway.
Code:
mpc play `shuf -e $(mpc playlist -f "[(%position%) %artist% %title% %file%]" |egrep $1 | grep -Eo "\(.*\)"| sed 's:).*::g' | sed 's:(::g') -n 1`
mpcr[andom] <artist/keyword>
(or however you chose to name/alias it)
And mpc will play a random song from the pool resulting from the keyword filter.
I guess the whole chain of pipes could probably be elegantly replaced by some awesome sed parameter, but that will do it as it is, anyway.
Total Comments 1
Comments
-
Newer, improved version:
Code:#!/bin/sh for i in $* ; do # search term parsing loop a="$a grep -i $i |" # makes a chain of greps from the search terms done a="mpc playlist -f \"[(@(%position%)@) %artist% %title% %file%]\" | $a" # adds a start to the grep chain - a start which is the generation of playist with special character markings for easier later extraction of the music number mpc play `shuf -e $(eval $(echo $a| sed 's/.\{2\}$//') | sed 's:)@).*::g' | sed 's:(@(::g') -n 1 ` # evals the search, then extract the number via sed, plays it obmpc.sh osd &
"obmpc.sh osd" is just a function of a different MPD-related script I have, would only show the selected song with aosd_cat at the bottom of the screen for a second.Posted 10-16-2011 at 07:42 PM by the dsc
Updated 10-16-2011 at 09:31 PM by the dsc