Auto DJ - RadioFreeMonkey

Download and get help for different MediaMonkey Addons.

Moderators: Peke, Gurus

Auto DJ - RadioFreeMonkey

Postby Risser » Thu May 07, 2009 11:41 am

This is a variation of RadioFreeMonkey as an AutoDJ script. It randomly chooses the next song based on the following criteria:
- It chooses higher rated songs more often than lower rated songs
- If you've listened to a song recently, it won't repeat for X number of days (defined in the script)
- It boosts the chances of a song being selected based on when it was last played (or added to the DB if it hasn't been played)

Also, I'm on MM3. The 'CASE WHEN' won't work in MM2, you'd have to make it an 'iif' statement. Of course, I'm not even sure if auto DJ was available in MM2.

Anyway, give it a try and let me know what you think.
Thanks,
Peter

Code: Select all
' An AutoDJ version of Radio Free Monkey
' by Peter Risser
' v1.0
' 2009-05-07

Option Explicit
'
' [AutoDJRadioFreeMonkey]
' FileName=autoDJ-RFM.vbs
' DisplayName=Radio Free Monkey
' Language=VBScript
' ScriptType=4

' %%% Add 1 to weighting for each X days since last played
Const DayFactor = 30

' %%% Anything rated this or below will not receive the 'date boost'
Const DateBoostCutoff = 1.5

' %%% 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


Dim weightedRatingFormula, dateBoostFormula, ratingFormula, weightedPlayCountFormula
Dim daysSinceAdded : daysSinceAdded = "round((julianday('now') - julianday('1899-12-30') - Songs.DateAdded),0)"
Dim daysSincePlayed : daysSincePlayed = "round((julianday('now') - julianday('1899-12-30') - Songs.LastTimePlayed),0)"
Dim numberOfDays : numberOfDays = "CASE WHEN (lastTimePlayed > 0) THEN "&daysSincePlayed&" ELSE "&daysSinceAdded&" END"
dateBoostFormula = "Round((Songs.rating > "&(DateBoostCutoff*20)&") * "&numberOfDays &" / "&DayFactor&",3)"
ratingFormula = "((Songs.rating > 0) * Songs.rating / 10)"
weightedRatingFormula = ratingFormula & " + " & dateBoostFormula

 
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("&weightedRatingFormula&"), min("&weightedRatingFormula&") "
  FROM_Clause = " FROM Songs "
  WHERE_Clause = " WHERE " &  daysSincePlayed & " > " & MinDaysRepeat
  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 rate >= "&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
Risser
 
Posts: 183
Joined: Thu Mar 03, 2005 11:28 am

Re: Auto DJ - RadioFreeMonkey

Postby nynaevelan » Thu May 07, 2009 11:56 am

Looks interesting, but out of curiosity why are AutoDJ scripts always created based on ratings? Is it possible to create them based on the number of plays, and to limit them based on certain genre's or filters?

Nyn
3.2x - Win7 Ultimate (Zen Touch 2 16 GB/Zen 8GB)
Link to Favorite Scripts/Skins

Join Dropbox, the online site to share your files
nynaevelan
 
Posts: 5559
Joined: Wed Feb 07, 2007 11:07 pm
Location: New Jersey, USA

Re: Auto DJ - RadioFreeMonkey

Postby rovingcowboy » Thu May 07, 2009 1:34 pm

nice to see risser doing scripting he's not around much.

it wouldn't be a dj script then nynaevelan it would be a played count script.

yes it has been done but not for making play lists it has been done as part of the rating scripts to be able to set the ratings.

i also would like that little script you want just to keep the songs from repeating too often which monkey seems to do a lot of on short play sessions.

by short play sessions i mean anything shorter then 18 hours in length. 8)
roving cowboy / keith hall. My skins viewtopic.php?f=9&t=16724 for some help check on Monkey's helpful messages at viewtopic.php?p=44008#44008 MY SYSTEMS.1.Xp pro sp3, vers 3.2 jukebox, pcchips mb. amd sem... built by me) 2.WinXP pro sp3, vers 2.5.5 and vers 3.2 backup storage, shuttle 32a mb,734 MHz amd athlon put together by me.) 3.WinXp pro sp 3 version 2.5 and version 3.2 work gigabyte mb. 281 GHz amd athlon x2 240 built by me.) 4.Dell demension, winxp pro sp3, mm3.5 spare jukebox.) 5.WinXp pro sp3, vers 2.5.5, moms computer. Sony vaio.)6. Samsung Galaxy Note2. Android 4.4) 7. Proscan tablet Android 4.3 )8. amd a8-5600 apu 3.60ghz windows 7 pro bought from computer store.
rovingcowboy
 
Posts: 13886
Joined: Sat Oct 25, 2003 7:57 am
Location: (Texas)

Re: Auto DJ - RadioFreeMonkey

Postby Teknojnky » Thu May 07, 2009 1:43 pm

Risser wrote:Of course, I'm not even sure if auto DJ was available in MM2.


Auto-DJ scripts are MM 3.x or higher feature.
Teknojnky
 
Posts: 5509
Joined: Tue Sep 06, 2005 11:01 pm

Re: Auto DJ - RadioFreeMonkey

Postby nynaevelan » Thu May 07, 2009 5:18 pm

rovingcowboy wrote:nice to see risser doing scripting he's not around much.

it wouldn't be a dj script then nynaevelan it would be a played count script.

yes it has been done but not for making play lists it has been done as part of the rating scripts to be able to set the ratings.

i also would like that little script you want just to keep the songs from repeating too often which monkey seems to do a lot of on short play sessions.

by short play sessions i mean anything shorter then 18 hours in length. 8)



RC:

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??
3.2x - Win7 Ultimate (Zen Touch 2 16 GB/Zen 8GB)
Link to Favorite Scripts/Skins

Join Dropbox, the online site to share your files
nynaevelan
 
Posts: 5559
Joined: Wed Feb 07, 2007 11:07 pm
Location: New Jersey, USA

Re: Auto DJ - RadioFreeMonkey

Postby rovingcowboy » Fri May 08, 2009 1:03 am

hey Teknojnky there was a script in mm 2. that would automaticlly pick songs from a playlist and add to the now playing list when all the songs in that now playing list had been played.

it was called non stop music or something like that.



nynaevelan i had thought you were wanting a script that would pick songs from any place in the library and play them, but doing so according to playcount not ratings.

:-?
roving cowboy / keith hall. My skins viewtopic.php?f=9&t=16724 for some help check on Monkey's helpful messages at viewtopic.php?p=44008#44008 MY SYSTEMS.1.Xp pro sp3, vers 3.2 jukebox, pcchips mb. amd sem... built by me) 2.WinXP pro sp3, vers 2.5.5 and vers 3.2 backup storage, shuttle 32a mb,734 MHz amd athlon put together by me.) 3.WinXp pro sp 3 version 2.5 and version 3.2 work gigabyte mb. 281 GHz amd athlon x2 240 built by me.) 4.Dell demension, winxp pro sp3, mm3.5 spare jukebox.) 5.WinXp pro sp3, vers 2.5.5, moms computer. Sony vaio.)6. Samsung Galaxy Note2. Android 4.4) 7. Proscan tablet Android 4.3 )8. amd a8-5600 apu 3.60ghz windows 7 pro bought from computer store.
rovingcowboy
 
Posts: 13886
Joined: Sat Oct 25, 2003 7:57 am
Location: (Texas)

Re: Auto DJ - RadioFreeMonkey

Postby trixmoto » Fri May 08, 2009 4:31 am

That was an "OnPlay" script, Teknojnky is correct that the "AutoDJ" scripts are new to MM3 and allow you to create a new source for MM's auto DJ rather than adding tracks manually to Now Playing as we had to before.
Download my scripts at trixmoto.net. If you're interested, check out my Uniface blog.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.

Image Image
trixmoto
 
Posts: 9961
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK

Re: Auto DJ - RadioFreeMonkey

Postby Guest » Fri May 08, 2009 6:05 am

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.


Maybe RadioDJ can help you there.
Set all the weightings for the ratings to the same value -- thus effectively disabling this feature.
RadioDJ uses playlists as input and it can boost entries that come before others.
So when you are able to create a playlist (or maybe auto playlist) that is sorted according your criteria, you have what you want.

Hope that helps.
CIAo, uwe..
Guest
 

Re: Auto DJ - RadioFreeMonkey

Postby 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
Last edited by Risser on Fri May 08, 2009 1:04 pm, edited 1 time in total.
Risser
 
Posts: 183
Joined: Thu Mar 03, 2005 11:28 am

Re: Auto DJ - RadioFreeMonkey

Postby nynaevelan » Fri May 08, 2009 12:59 pm

Thanks, I'll give it a whirl this weekend.

Nyn
3.2x - Win7 Ultimate (Zen Touch 2 16 GB/Zen 8GB)
Link to Favorite Scripts/Skins

Join Dropbox, the online site to share your files
nynaevelan
 
Posts: 5559
Joined: Wed Feb 07, 2007 11:07 pm
Location: New Jersey, USA

Re: Auto DJ - RadioFreeMonkey

Postby rovingcowboy » Fri May 08, 2009 3:52 pm

trixmoto wrote:That was an "OnPlay" script, Teknojnky is correct that the "AutoDJ" scripts are new to MM3 and allow you to create a new source for MM's auto DJ rather than adding tracks manually to Now Playing as we had to before.


i wasn't saying he was wrong there, i just said there was a script i thought that was like the autodj scripts.
but thanks for the confirm.. 8)
roving cowboy / keith hall. My skins viewtopic.php?f=9&t=16724 for some help check on Monkey's helpful messages at viewtopic.php?p=44008#44008 MY SYSTEMS.1.Xp pro sp3, vers 3.2 jukebox, pcchips mb. amd sem... built by me) 2.WinXP pro sp3, vers 2.5.5 and vers 3.2 backup storage, shuttle 32a mb,734 MHz amd athlon put together by me.) 3.WinXp pro sp 3 version 2.5 and version 3.2 work gigabyte mb. 281 GHz amd athlon x2 240 built by me.) 4.Dell demension, winxp pro sp3, mm3.5 spare jukebox.) 5.WinXp pro sp3, vers 2.5.5, moms computer. Sony vaio.)6. Samsung Galaxy Note2. Android 4.4) 7. Proscan tablet Android 4.3 )8. amd a8-5600 apu 3.60ghz windows 7 pro bought from computer store.
rovingcowboy
 
Posts: 13886
Joined: Sat Oct 25, 2003 7:57 am
Location: (Texas)

Re: Auto DJ - RadioFreeMonkey

Postby Guest » Sat May 09, 2009 2:23 pm

Am I right to conclude that this is differnt than the old RADIOFREEMONKEY script?

/Jeff
Guest
 

Re: Auto DJ - RadioFreeMonkey

Postby kazadharri » Sun May 10, 2009 12:04 pm

My bad forgot to log in.
kazadharri
 
Posts: 106
Joined: Fri Jul 28, 2006 1:07 am

Re: Auto DJ - RadioFreeMonkey

Postby Risser » Mon May 11, 2009 11:29 am

Guest wrote:Am I right to conclude that this is differnt than the old RADIOFREEMONKEY script?


Yeah, sorta. It uses the same rating algorithm to determine which songs should be more likely to be heard, based on rating & time since last played. But it pulls the actual songs using a different (easier/less accurate) algorithm. Also, it's an autoDJ script, rather than a script that pulls up 20 random songs into a window.

So, yeah.

I've updated the RFM script for MM3 if y'all want that too.
Peter
Risser
 
Posts: 183
Joined: Thu Mar 03, 2005 11:28 am

Re: Auto DJ - RadioFreeMonkey

Postby jomtones » Fri Aug 07, 2009 3:29 am

Forgive me but how do I install this? I tried saving the code as AutoDJRadioFreeMonkey.vbs in the C:\Program Files\MediaMonkey\Scripts\Auto folder but can't see it after a reboot...
jomtones
 
Posts: 145
Joined: Mon Jul 02, 2007 5:06 pm
Location: London, UK

Next

Return to Need Help with Addons?

Who is online

Users browsing this forum: No registered users and 10 guests