-
Notifications
You must be signed in to change notification settings - Fork 5
/
roadmap.txt
80 lines (66 loc) · 2.8 KB
/
roadmap.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
SCRIPT=$0
InstructionFile=""
DefaultPriority=1
tmp2=$(mktemp)
ModGenre=()
ModValue=()
GenreWeight=()
ChooseGenre=()
SONGLENGTH=10
# initialize choosing array (this will be called from a function, so it can be
# easily added in from relay when we loop the process).
# get default weight
# go through list of genres from mpc/mpd
# is it in our instruction file?
# if not, weight=default
# if so, weight=value from instruction file
# i = 0; while i until $weight;do
# add element to choosing array with GenreName
# done
# in choosing section, get rand# then choose that element. BOSH, done.
ModGenre+=("${IGenre}")
function determine_genre_weights {
#This is not light, but it's only done once a run.
#loop through genre, if not in array ModGenre, then apply DefaultWeight
TotalNumSongs=$(mpc --host $MPD_HOST --port $MPD_PORT listall | wc -l)
for ((i = 0; i < ${#Genre[@]}; i++));do
#determine weight of genre in music directory
if [[ "${MODE}" =~ "song" ]];then
GenreNumSongs[$i]=$(mpc --host $MPD_HOST --port $MPD_PORT find genre "${Genre[$i]}" | wc -l)
GenreSongWeight[$i]=$(printf "%.0f\n" `echo "(${GenreNumSongs[$i]} / $TotalNumSongs)*1000" | bc -l`)
if [ ${GenreSongWeight[$i]} = 0 ];then
GenreSongWeight[$i]=1
fi
for (( i2 = 0; i2 < ${#ModGenre[@]}; i2++ ));do
if [[ "${Genre[$i]}" = "${ModGenre[$i2]}" ]];then
GenreWeight[$i]=$(printf "%.0f\n" `echo "${GenreSongWeight[$i]} * ${ModValue[$i2]}" | bc -l`)
#GenreWeight[$i]=$(echo "${ModValue[$i2]}")
break
else
GenreWeight[$i]=$(printf "%.0f\n" `echo "${GenreSongWeight[$i]} * ${DefaultWeight}" | bc -l`)
fi
done
else # regular weighting without number of songs
for (( i2 = 0; i2 < ${#ModGenre[@]}; i2++ ));do
if [[ "${Genre[$i]}" = "${ModGenre[$i2]}" ]];then
GenreWeight[$i]=$(echo "${ModValue[$i2]}")
fi
done
fi
if [ -z ${GenreWeight[$i]} ];then
GenreWeight[$i]=${DefaultWeight}
fi
loud "${Genre[$i]} - ${GenreWeight[$i]}"
done
#populating the "weighted" array
#add the name GenreWeight times... giving us a sloppy weighting mechanism (and if it's zero, it SHOULD exit before hitting this)
for (( i = 0; i < ${#Genre[@]}; i++));do
if [[ ! -z "${GenreWeight[$i]}" ]];then
for (( i2 = 1; "$i2" <= "${GenreWeight[$i]}"; i2++ ));do
if [ "${GenreWeight[$i]}" != "0" ]; then
ChooseGenre+=("${Genre[$i]}")
fi
done
fi
done
}