by Risser » Fri May 08, 2009 12:55 pm
nynaevelan wrote:
I'm confused as to your post. I am not looking for a script to set ratings nor a script to create playlists. I want an autodj script that would make it's selections based on the playcounts instead of ratings but to exclude certain genre's, such as holiday. Or if not exclude the particular genre's, then to select the tracks from a certain filter. How is this different?? My ratings system is based on playcounts so I want the script to select songs which I like, ie I've played them over a certain amount of times. I already have playlists created for when I want to listen to those least played tracks. Every now and again I would like to have someone else pick the tracks I listen to but none of the autodj scripts meet my needs except there was an external one but I don't know sql and I prefer internal scripts so that one was not usable for me. Should I open a request for such a script??
So, something that weights based on playcount? If I'm reading correctly, you'd like things that have a higher playcount to be played more often?
That should be easy.
Let me see...
(5 minutes later)
I don't know if this works, but it's close. I basically subbed playcount for the complicated rating calc. So things with higher playcounts have a greater chance of getting played.
It's got the same bias problems that the other one has, but it's quick.
Peter
Edit: I forgot to exclude genres. Again this is totally untested so it probably won't work straight out of the gate, but you should be able to tweak it to make it work.
Code: Select all
' An AutoDJ the plays items with a higher playcount more often and exclude some genres
' by Peter Risser
' v1.0
' 2009-05-08
Option Explicit
'
' [AutoDJPlayCount]
' FileName=autoDJ-PlayCount.vbs
' DisplayName=Higher Play Counts are Played More Often
' Language=VBScript
' ScriptType=4
' %%% The minimum number of days that must pass before a song is repeated. Zero means, go ahead
' and repeat it right away.
Const MinDaysRepeat = 4
' %%% A pipe delimited list of genres to ignore.
Const ignoreGenres = "Holiday|Polka|" & _
"Bubblegum|Cheese"
Dim daysSincePlayed : daysSincePlayed = "round((julianday('now') - julianday('1899-12-30') - Songs.LastTimePlayed),0)"
Dim badGenreList : badGenreList = Split(ignoreGenres,"|")
Dim badGenreExclusionClause : badGenreExclusionClause = ""
For i = 0 to UBound(badGenreList)
badGenreExclusionClause = badGenreExclusionClause & " AND Songs.Genre <> '"&badGenreList(i)&"'"
Next
Sub InitConfigSheet( Panel)
' TODO: Make the configurable items actual options in the dialog.
End Sub
' Panel = Panel where UI controls were previously placed by the script
' SaveConfig = Whether user pressed Ok and values in the dialog should be applied and saved (to registry, ini file, or so)
Sub CloseConfigSheet( Panel, SaveConfig)
' TODO: Save values to Registry, apply them to our internal variables.
End Sub
Function GenerateNewTrack
Dim SQLStatement, TotalsSQLStatement
Dim SELECT_Clause, SELECT_TOTALS_Clause, FROM_Clause, WHERE_Clause, ORDER_Clause
Dim Iter, res, total, max, min, delta, cutoff, ID
Randomize
SELECT_Clause = " SELECT Songs.Id, "&weightedRatingFormula&" as rate "
SELECT_TOTALS_Clause = " SELECT count(Songs.Id), max(Songs.PlayCounter), min(Songs.PlayCounter) "
FROM_Clause = " FROM Songs "
WHERE_Clause = " WHERE " & daysSincePlayed & " > " & MinDaysRepeat & badGenreExclusionClause
ORDER_Clause = " ORDER BY random(*)"
TotalsSQLStatement = SELECT_TOTALS_Clause & FROM_Clause & WHERE_Clause
'res = SDB.MessageBox(SQLStatement, mtError, Array(mbOk))
Set Iter = SDB.Database.OpenSQL(TotalsSQLStatement)
total = Iter.ValueByIndex(0)
max = Iter.ValueByIndex(1)
min = Iter.ValueByIndex(2)
delta = max - min
cutoff = rnd() * delta + min
SQLStatement = SELECT_Clause & FROM_Clause & WHERE_Clause & " and Songs.PlayCounter >= "&cutoff& ORDER_Clause
Set Iter = SDB.Database.OpenSQL(SQLStatement)
ID = Iter.ValueByIndex(0)
'res = SDB.MessageBox("max: "&max&"; cutoff:"&cutoff&"; result:"&Iter.ValueByIndex(1), mtError, Array(mbOk))
Set Iter = SDB.Database.QuerySongs( "ID=" & ID)
Set GenerateNewTrack = Iter.Item
End Function
[quote="nynaevelan"]
I'm confused as to your post. I am not looking for a script to set ratings nor a script to create playlists. I want an autodj script that would make it's selections based on the playcounts instead of ratings but to exclude certain genre's, such as holiday. Or if not exclude the particular genre's, then to select the tracks from a certain filter. How is this different?? My ratings system is based on playcounts so I want the script to select songs which I like, ie I've played them over a certain amount of times. I already have playlists created for when I want to listen to those least played tracks. Every now and again I would like to have someone else pick the tracks I listen to but none of the autodj scripts meet my needs except there was an external one but I don't know sql and I prefer internal scripts so that one was not usable for me. Should I open a request for such a script??[/quote]
So, something that weights based on playcount? If I'm reading correctly, you'd like things that have a higher playcount to be played more often?
That should be easy.
Let me see...
(5 minutes later)
I don't know if this works, but it's close. I basically subbed playcount for the complicated rating calc. So things with higher playcounts have a greater chance of getting played.
It's got the same bias problems that the other one has, but it's quick.
Peter
Edit: I forgot to exclude genres. Again this is totally untested so it probably won't work straight out of the gate, but you should be able to tweak it to make it work.
[code]
' An AutoDJ the plays items with a higher playcount more often and exclude some genres
' by Peter Risser
' v1.0
' 2009-05-08
Option Explicit
'
' [AutoDJPlayCount]
' FileName=autoDJ-PlayCount.vbs
' DisplayName=Higher Play Counts are Played More Often
' Language=VBScript
' ScriptType=4
' %%% The minimum number of days that must pass before a song is repeated. Zero means, go ahead
' and repeat it right away.
Const MinDaysRepeat = 4
' %%% A pipe delimited list of genres to ignore.
Const ignoreGenres = "Holiday|Polka|" & _
"Bubblegum|Cheese"
Dim daysSincePlayed : daysSincePlayed = "round((julianday('now') - julianday('1899-12-30') - Songs.LastTimePlayed),0)"
Dim badGenreList : badGenreList = Split(ignoreGenres,"|")
Dim badGenreExclusionClause : badGenreExclusionClause = ""
For i = 0 to UBound(badGenreList)
badGenreExclusionClause = badGenreExclusionClause & " AND Songs.Genre <> '"&badGenreList(i)&"'"
Next
Sub InitConfigSheet( Panel)
' TODO: Make the configurable items actual options in the dialog.
End Sub
' Panel = Panel where UI controls were previously placed by the script
' SaveConfig = Whether user pressed Ok and values in the dialog should be applied and saved (to registry, ini file, or so)
Sub CloseConfigSheet( Panel, SaveConfig)
' TODO: Save values to Registry, apply them to our internal variables.
End Sub
Function GenerateNewTrack
Dim SQLStatement, TotalsSQLStatement
Dim SELECT_Clause, SELECT_TOTALS_Clause, FROM_Clause, WHERE_Clause, ORDER_Clause
Dim Iter, res, total, max, min, delta, cutoff, ID
Randomize
SELECT_Clause = " SELECT Songs.Id, "&weightedRatingFormula&" as rate "
SELECT_TOTALS_Clause = " SELECT count(Songs.Id), max(Songs.PlayCounter), min(Songs.PlayCounter) "
FROM_Clause = " FROM Songs "
WHERE_Clause = " WHERE " & daysSincePlayed & " > " & MinDaysRepeat & badGenreExclusionClause
ORDER_Clause = " ORDER BY random(*)"
TotalsSQLStatement = SELECT_TOTALS_Clause & FROM_Clause & WHERE_Clause
'res = SDB.MessageBox(SQLStatement, mtError, Array(mbOk))
Set Iter = SDB.Database.OpenSQL(TotalsSQLStatement)
total = Iter.ValueByIndex(0)
max = Iter.ValueByIndex(1)
min = Iter.ValueByIndex(2)
delta = max - min
cutoff = rnd() * delta + min
SQLStatement = SELECT_Clause & FROM_Clause & WHERE_Clause & " and Songs.PlayCounter >= "&cutoff& ORDER_Clause
Set Iter = SDB.Database.OpenSQL(SQLStatement)
ID = Iter.ValueByIndex(0)
'res = SDB.MessageBox("max: "&max&"; cutoff:"&cutoff&"; result:"&Iter.ValueByIndex(1), mtError, Array(mbOk))
Set Iter = SDB.Database.QuerySongs( "ID=" & ID)
Set GenerateNewTrack = Iter.Item
End Function
[/code]