need a script for top 50 lists

Download and get help for different MediaMonkey for Windows 4 Addons.

Moderators: Peke, Gurus

Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm

Post by Steegy »

My "code" is just the database data, equal to the auto-playlist that psyxonova suggested you to make. I knew you couldn't create/edit auto-playlists on your free version. That's why I made it, and gave you the code that you can use in your database (in case you can edit it). It's really just a workaround of the disability to add/edit auto-playlists in the standard (free) version. You can't edit the database, so my code doesn't have any value to you then.

Scripts are of course possible, but it should be possible to do this using Magic Nodes, if necessary after fixing a bug in that script.

Maybe ask this in the Magic Nodes forum. If you don't get a fix/answer there, a script can still be written. I (and possibly most other scripters) just don't want to do "useless" work, if the same can be archieved much easier with Magic Nodes.

Cheers
Steegy
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
Guest

Post by Guest »

i thought script was easier?

i have magic nodes from last november or so. i tried to create a node with it but it did not work so i took magic nodes out?

i must be to dumb to know how to use that?
:P

roving cowboy / keith hall.

just a leaning over the fence again.
brianon
Posts: 78
Joined: Wed Dec 07, 2005 4:48 am

Post by brianon »

Try this.
It'll ask for a start date and end date "dd/mm/yyyy".
And then the number of tracks to include.

I use it to create weekly/monthly/yearly charts.

It creates a playlist for you once complete.

scripts.ini

Code: Select all

[CreateChart]
FileName=CreateChart.vbs
ProcName=CreateCHart
Order=100
DisplayName=&CreateChart
Description=CreateChart
Language=VBScript
ScriptType=0
CreateChart.vbs

Code: Select all

Sub CreateChart
  ' define vars
  Dim strStartDate
  Dim strEndDate
  Dim strUSStartDate
  Dim strUSEndDate
  Dim strPlaylistName
  Dim strTmp
  Dim strSQL
  Dim strOut
  Dim strOut2
  Dim howMany
  Dim strPlaylistId
  Dim x


  '''''''''''''''''''' 
  ' get the start date
  strStartDate = ""
  strStartDate = InputBox("Enter the Start date [eg. '01/10/2005']", "Start Date") 
  
  'If Canceled, exit 
  If strStartDate = "" Then 
     Exit Sub 
  End If 
  
  'Check that the text entered is a valid parameter. Inform user if it isn't. 
  If Not IsDate(strStartDate) Then 
     mb = MsgBox("You did not enter a valid date. Please try again.",0,"Error") 
     Exit Sub
  End If

  ''''''''''''''''''''
  ' get the end date
  strEndDate = ""
  strEndDate = InputBox("Enter the End date [eg. '31/10/2005']", "End Date") 
  
  'If Canceled, exit 
  If strEndDate = "" Then 
     Exit Sub 
  End If 
  
  'Check that the text entered is a valid parameter. Inform user if it isn't. 
  If Not IsDate(strEndDate) Then 
     mb = MsgBox("You did not enter a valid date. Please try again.",0,"Error") 
     Exit Sub
  End If


  ''''''''''''''''''''''''''''''''
  ' make the name of the playlist
  strPlaylistName = "Chart-" & strStartDate & "--to--" & strEndDate

  ''''''''''''''''''''''''''''''''
  ' make sure it doesn't already exist
  strSQL = "select Count(Playlists.IDPlaylist) AS CountOfPlaylists from Playlists where Playlists.PlaylistName = '" & strPlaylistName & "'"
  Set qryStats = SDB.Database.OpenSQL(strSQL)
  strPlaylists = qryStats.StringByName("CountOfPlaylists")

  ' if it does exist see if the user wants to delete it
  If Not strPlaylists = 0 then
    strTmp = InputBox("Already have playlist with this name. Replace ? [y/n]", "Playlist Replace")

    If strTmp = "n" then
      Exit Sub
    else
      ' delete the playlist
      SDB.Database.ExecSQL("delete from Playlists where Playlists.PlaylistName = '" & strPlaylistName & "'")
    end if
  End If 


  ''''''''''''''''''''''''''''''''''''
  ' add the playlist to Playlist table
  SDB.Database.ExecSQL("insert into Playlists (PlaylistName, ParentPlaylist, Comment) values ('" & strPlaylistName & "',0,'Auto Generated Chart Playlist')")


  '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  ' create the list of songs for the playlist

  ' find out the max for the list
  howMany = InputBox("Is this a Top 50 (+ ties) or ... ?", "Top X")
  
 ' now get the ID of the playlist we added earlier
  strSQL = "select Playlists.IDPlaylist AS PlaylistId from Playlists where Playlists.PlaylistName = '" & strPlaylistName & "'"
  Set qryStats = SDB.Database.OpenSQL(strSQL)
  strPlaylistId = qryStats.StringByName("PlaylistId")

  ' if it does exist then we are screwed!
  If strPlaylistId = 0 then
    strTmp = InputBox("Playlist not created!", "Error")
  End If 
  
  ''''''''''''''''''''''''''''''''
  ' change the two dates from dd/mm/yyyy to mm/dd/yyyy for the comparision
  strUSStartDate = Month(strStartDate) & "/" & Day(strStartDate) & "/" & Year(strStartDate)
  strUSEndDate = Month(strEndDate) & "/" & Day(strEndDate) & "/" & Year(strEndDate)
  
  ' create the tmp table
  SDB.Database.ExecSQL ("drop table tmpIds")
  SDB.Database.ExecSQL ("drop table tmpChart")
  SDB.Database.ExecSQL ("create table tmpIds (IdSong int not null)")
  SDB.Database.ExecSQL ("create table tmpChart (IdSong int not null, SongCount int not null)")
  
  ' tmpIds
  strSQL = "select Played.IdSong AS Ids from Played where Played.PlayDate between #" & strUSStartDate & "# and #" & strUSEndDate & "# order by IdSong "  
  Set qryStats = SDB.Database.OpenSQL(strSQL)
  
  '''''''''''''''''
  ' insert into tmp
  While Not qryStats.EOF
    strOut = qryStats.StringByName("Ids")
    SDB.Database.ExecSQL("insert into tmpIds (IdSong) values (" & strOut & ")")
    qryStats.Next
  Wend
  
  ' tmpChart
  strSQL = "select distinct IdSong as topIds, Count(IdSong) as myCount from tmpIds group by IdSong"
  Set qryStats = SDB.Database.OpenSQL(strSQL)
  
  
  ''''''''''''''''''''''''
  ' insert into temp chart
  While Not qryStats.EOF
    strOut = qryStats.StringByName("topIds")
    strOut2 = qryStats.StringByName("myCount")
    SDB.Database.ExecSQL("insert into tmpChart (IdSong, SongCount) values ("&strOut&","&strOut2&")")
    qryStats.Next
  Wend
  

  ' query the temp chart
  strSQL = "select TOP " & howMany & " tmpChart.IdSong as topIds from tmpChart order by SongCount DESC"  
  Set qryStats = SDB.Database.OpenSQL(strSQL)
  
  x = 0
  While Not qryStats.EOF
    strOut = qryStats.StringByName("topIDs")
    SDB.Database.ExecSQL("insert into PlaylistSongs (IDPlaylist, IDSong, SongOrder) values (" & strPlaylistId & "," & strOut & "," & x & ")")
    x = x + 1
    qryStats.Next
  Wend
  
  
End Sub


'strSQL = "select distinct Played.IdSong as topIds, Count(Played.IdSong) as myCount from Played where Played.PlayDate between #" & strStartDate & "# and #" & strEndDate & "# group by IdSong"  

Guest

Post by Guest »

this looks like it requires user input every week.

is it possible to make it do all the date changes automaticly ?

and to replace the playlist it saves them to every week with out asking?

that would be great.

but thanks for this one right now. 8)

roving cowboy / keith hall.

not logged in just reaching over the fence.
Guest

Post by Guest »

script did not work in this winXp with the latest rc 3 version of monkey.

it told me there was no teplt in the mdb and i did not have access for the mdb or could not access the mdb with out permission? strange.

i took the ini part back out of the file and kept the others there just in case you can figure out what was wrong.?

but i was right you do need to fill in the info all the time and save it to a new playlist every time.

i am lazy that is too much work for me i want it to do it by it's self. :lol: but thanks for the effort. 8)

rovingcowboy / keith hall

just fence leanin' again.
brianon
Posts: 78
Joined: Wed Dec 07, 2005 4:48 am

Post by brianon »

no worries.
I wrote it a while ago and have been using.

Its far from perfect but does the job for me :)

I have just run it once a month to create monthly charts as playlists.
rovingcowboy
Posts: 14163
Joined: Sat Oct 25, 2003 7:57 am
Location: (Texas)
Contact:

Post by rovingcowboy »

could something like this be done in javascript? and added in to monkey?
if so i might be willing to learn how since i am trying to do javascripts on my web page?

:-?
roving cowboy / keith hall. My skins http://www.mediamonkey.com/forum/viewto ... =9&t=16724 for some help check on Monkey's helpful messages at http://www.mediamonkey.com/forum/viewto ... 4008#44008 MY SYSTEMS.1.Jukebox WinXp pro sp 3 version 3.5 gigabyte mb. 281 GHz amd athlon x2 240 built by me.) 2.WinXP pro sp3, vers 2.5.5 and vers 3.5 backup storage, shuttle 32a mb,734 MHz amd athlon put together by me.) 3.Dell demension, winxp pro sp3, mm3.5 spare jukebox.) 4.WinXp pro sp3, vers 3.5, dad's computer bought from computer store. )5. Samsung Galaxy A51 5G Android ) 6. amd a8-5600 apu 3.60ghz mm version 4 windows 7 pro bought from computer store.
Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm

Post by Steegy »

The Script Runtime that is used in MediaMonkey can handle VBScript, as wel as JScript (javascript). These two languages are similar so it shouldn't be difficult no "translate" this VBScript into a JScript.
For the same reason, VBScript programs can be easily understood by JScript programmers, and also the other way around.
Once you know one (general) programming language, you mostly can easily understand other languages. The only thing you need to know when you write a new language is the small differences (e.g. VBScript has "subs" and "functions", JScript calls these both "functions", comment mark ' changes to //, ...)

Cheers
Steegy
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
rovingcowboy
Posts: 14163
Joined: Sat Oct 25, 2003 7:57 am
Location: (Texas)
Contact:

Post by rovingcowboy »

i am only able to adjust or reconfigure somebody elses javascripts to make them work the way i want to i do not know codeing enough to make one from scratch and what i do know takes me 20 times long to do then some one that can do codes.

so what you just said about subs and functions can be sum'ed up with one sound.

wooooosh!!

:o
roving cowboy / keith hall. My skins http://www.mediamonkey.com/forum/viewto ... =9&t=16724 for some help check on Monkey's helpful messages at http://www.mediamonkey.com/forum/viewto ... 4008#44008 MY SYSTEMS.1.Jukebox WinXp pro sp 3 version 3.5 gigabyte mb. 281 GHz amd athlon x2 240 built by me.) 2.WinXP pro sp3, vers 2.5.5 and vers 3.5 backup storage, shuttle 32a mb,734 MHz amd athlon put together by me.) 3.Dell demension, winxp pro sp3, mm3.5 spare jukebox.) 4.WinXp pro sp3, vers 3.5, dad's computer bought from computer store. )5. Samsung Galaxy A51 5G Android ) 6. amd a8-5600 apu 3.60ghz mm version 4 windows 7 pro bought from computer store.
confused

Post by confused »

so how about it is anyone going to do this since cowboy can't understand it.
and neither can i but it is a good idea for a script? :-?
rovingcowboy
Posts: 14163
Joined: Sat Oct 25, 2003 7:57 am
Location: (Texas)
Contact:

Post by rovingcowboy »

your right confused it is over my head,

i just can not figure it out, and i don't think

and one else wants to do this, right now since

there are lots of errors still trying to be figured out.
roving cowboy / keith hall. My skins http://www.mediamonkey.com/forum/viewto ... =9&t=16724 for some help check on Monkey's helpful messages at http://www.mediamonkey.com/forum/viewto ... 4008#44008 MY SYSTEMS.1.Jukebox WinXp pro sp 3 version 3.5 gigabyte mb. 281 GHz amd athlon x2 240 built by me.) 2.WinXP pro sp3, vers 2.5.5 and vers 3.5 backup storage, shuttle 32a mb,734 MHz amd athlon put together by me.) 3.Dell demension, winxp pro sp3, mm3.5 spare jukebox.) 4.WinXp pro sp3, vers 3.5, dad's computer bought from computer store. )5. Samsung Galaxy A51 5G Android ) 6. amd a8-5600 apu 3.60ghz mm version 4 windows 7 pro bought from computer store.
Guest

Post by Guest »

check out this thread for more on this playlist thing.

http://www.mediamonkey.com/forum/viewto ... 2424#42424

rovingcowboy / keith hall.

not logged in
Post Reply