Skip to content

Commit

Permalink
mpc find instead of mpc search so it stops overmatching
Browse files Browse the repository at this point in the history
  • Loading branch information
uriel1998 committed Dec 7, 2020
1 parent 064e355 commit acec2a5
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions mpdq
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,12 @@ function choose_next_song {
OkayGenre=""
while [ -z ${OkayGenre} ] && [ ${counter} -lt ${NUMGENRES} ] ;do
ChosenGenre=${ChooseGenre[$RANDOM % ${#ChooseGenre[@]} ]}
#echo "$ChosenGenre"
UsedGenre=$(grep -c "@@@${ChosenGenre}" "${GenreLogFile}")
for (( i2 = 0; i2 < ${#ModGenre[@]}; i2++ ));do
#echo "${ChosenGenre}:${UsedGenre} and ${ModGenre[$i2]}:${GenreWeight[$i2]}"

if [[ "${ChosenGenre}" = "${ModGenre[$i2]}" ]];then

#echo "${ChosenGenre}:${UsedGenre} and ${ModGenre[$i2]}:${GenreWeight[$i2]}"
if [ "${UsedGenre}" -gt "${GenreWeight[$i2]}" ]; then
echo "${ChosenGenre} already used up this hour, moving on"
OkayGenre=""
Expand All @@ -213,10 +214,11 @@ function choose_next_song {
echo "$nowtime@@@${ChosenGenre}" >> "$GenreLogFile"
echo "Choosing song from $ChosenGenre..."

evalme=$(printf "mpc --host %s@%s --port %s search genre \"%s\" | shuf -n1" "$MPD_PASS" "$MPD_HOST" "$MPD_PORT" "${ChosenGenre}")
evalme=$(printf "mpc --host %s@%s --port %s find genre \"%s\" | shuf -n1" "$MPD_PASS" "$MPD_HOST" "$MPD_PORT" "$ChosenGenre")
#echo "$evalme"
SongStem=$(eval "$evalme")
# Changed to deal with more spaces and escaping...
#SongStem=$(mpc --host $MPD_PASS@$MPD_HOST --port $MPD_PORT search genre '${ChosenGenre}' | shuf -n1)
#SongStem=$(mpc --host $MPD_PASS@$MPD_HOST --port $MPD_PORT find genre '${ChosenGenre}' | shuf -n1)
SongFile="$MPDBASE/$SongStem"
#echo "$SongStem"
#echo "$SongFile"
Expand Down

0 comments on commit acec2a5

Please sign in to comment.