Auto..Weekly top of charts list script

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

Moderators: Peke, Gurus

rovingcowboy
Posts: 14163
Joined: Sat Oct 25, 2003 7:57 am
Location: (Texas)
Contact:

Auto..Weekly top of charts list script

Post by rovingcowboy »

in order to see what is needed for making the automaticly updated top of the charts play list you need to see the reply at this url.


http://www.mediamonkey.com/forum/viewto ... 4983#44983

enjoy.



8)

this code below is found in the thread it has in the code header. and is working as it was made to work by the authors.

Code: Select all

'code Author's 1. Pablo, 2. Roylayer 3. Popper 4. Anubis
' increments play counter and sets last time played to current date and time 
' Source: http://www.mediamonkey.com/forum/viewtopic.php?t=1461 
' modified to work with a non-English date format and to also update the "Played" table. 
' you need to refesh (F5) the screen to see the changes. 

Option Explicit 

Sub IncrPlayCntr 
  ' Define variables 
  Dim list, itm, i 

  ' Get list of selected tracks from MediaMonkey 
  Set list = SDB.SelectedSongList 
  If list.count=0 Then 
    Set list = SDB.AllVisibleSongList 
  End If 

  ' Process all selected tracks 
  For i=0 To list.count-1 
    Set itm = list.Item(i) 

    'must use sql because there is no itm.LastTimePlayed property 
    SDB.database.execSQL("UPDATE Songs SET PlayCounter=" & (itm.PlayCounter - 1) & ",LastTimePlayed='" & now() & "' WHERE Id=" & itm.songID) 

    ' there is another DB table that stores when the song was played, 
    ' so in order to stay consistent, we update this, too. 
    ' This table is used for the "50 last played songs" playlist 
    SDB.database.execSQL("INSERT INTO Played (IdSong, PlayDate) VALUES (" & itm.songId & ", '" & Now() & "')") 
    
  Next 
End Sub 


8)
Last edited by rovingcowboy on Sat Apr 29, 2006 9:44 am, edited 1 time in total.
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.
agentsmart

Post by agentsmart »

I am surprised that this is not yet giving any reply from the authors
i seen cowboy message he posted directly to the authors in the off topic forum and they still do not reply.
what's wrong with the authors that they ignore someones request for help with their script. :o

i think this thing cowboy is trying to get working is a good idea. all the parts of the pie are there but the auto reset of the play counter.

can't the authors fix their own script? or maybe some small way even post a reply to cowboy.

because like him i also want to make a weekly list.
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Post by trixmoto »

This will now update every track in the library when it is run. I'm not sure what else you wanted it to do.

:o NEW CODE BELOW :o
Last edited by trixmoto on Fri Apr 28, 2006 10:18 am, edited 1 time in total.
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
rovingcowboy
Posts: 14163
Joined: Sat Oct 25, 2003 7:57 am
Location: (Texas)
Contact:

Post by rovingcowboy »

wow thanks trixmoto for taking time from your other scripts to do this.

i never would have figured out how to do that. since i can only modify codes. not too good at making them yet?

the other things i need it to do is run automaticly when the file is clicked on, instead of running only from a link in the scripts menu.

i can figured it out that i can get it to start once a week with the task scheduler so that timer part is not needed.

but i don't know if it will run when the task scheduler starts it ? :-?

wow looks like others want this too.?
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.
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Post by trixmoto »

To do this you take it out of the sub procedure (and remember to link to SDB), like this:

:o NEW CODE BELOW :o
Last edited by trixmoto on Fri Apr 28, 2006 10:17 am, edited 1 time in total.
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
DiddeLeeDoo
Posts: 1017
Joined: Wed Mar 01, 2006 1:09 am
Location: In a jungle down under
Contact:

Post by DiddeLeeDoo »

Since working on a graphic user interface for that Rating Calibrator I learned a littlebit more today...

Here's just a quick and dirty one, for showing your plays over the last week, and what artist and songs...

This one do not modify anything, it just show a little report.... My first one, so do not expect much..

Just save is as say something like top40.vbs in the \scripts\auto folder, and start up the monkey.... you'll see a new icon on the standard toolbar looking like three sheets of paper on top of each other... hit this icon, and a little report window comes up..

It maybe a step in the direction you wanna go Roving Cowboy..

Added: This one have a cutting point on Sunday at 12:00 AM if your machine is set to have that as a cutting point for weeks. So the result you get today, on a Friday, willl be the same you get tomorrow, Saturday, but on Sunday, you'll see new results.

Code: Select all

' Top 40 Last Week, Test
' DiddeLeeDoo
' Simply adds a icon on the standard button bar, looking like
' three sheets of paper stacked on each other.
' Hit it,and select Last Week... just a test project..
' Save this one as \Scripts\Auto\Top40.vbs

Sub OnStartup
  Set UI = SDB.UI

  UI.AddMenuItemSep UI.Menu_TbStandard, 0, 0

  Set Mnu = UI.AddMenuItem( UI.Menu_TbStandard, 0, 0)
  Mnu.Caption = "Weekly Top 40"
  Mnu.UseScript = Script.ScriptPath
  Mnu.OnClickFunc = "ShowIt"
  Mnu.IconIndex = 35
  Mnu.Hint = "Weekly Top 40 List"
End Sub

Sub ShowIt( Itm)
  Set UI = SDB.UI

  Set Form = UI.NewForm
  Form.Common.SetRect 100, 100, 500, 600
  Form.Common.MinWidth = 200
  Form.Common.MinHeight = 150
  Form.FormPosition = 4   ' Screen Center
  Form.SavePositionName = "Report form"
  Form.Caption = "Weekly Top 40"
  Form.StayOnTop = True

  Set Head = UI.NewPanel( Form)
  Head.Common.Align = 1   ' Top
  Head.Common.Height = 30

  Set Combo = UI.NewDropDown( Head)
  Combo.Common.SetRect 5, 5, 150, 25
  Combo.Style = 2     ' List
  Combo.AddItem "Select Week"
  Combo.AddItem "Last Week"
  Combo.ItemIndex = 0
  Combo.UseScript = Script.ScriptPath
  Combo.OnSelectFunc = "OnSelect"

  ' Create a panel at the bottom of the window
  Set Foot = UI.NewPanel( Form)
  Foot.Common.Align = 2   ' Bottom
  Foot.Common.Height = 35

  ' Create a button that closes the window
  Set Btn = UI.NewButton( Foot)
  Btn.Caption = "Close"
  Btn.Common.SetRect Foot.Common.Width - 90, 9, 85, 24
  Btn.Common.Hint = "Close this report"
  Btn.Common.Anchors = 4+8   ' Right+Bottom
  Btn.UseScript = Script.ScriptPath
  Btn.OnClickFunc = "OnClose"
  
  Set WB = UI.NewActiveX( Form, "Shell.Explorer")
  WB.Common.Align = 5
  WB.Common.ControlName = "WB"
  WB.Interf.Navigate "about:" 
  Set Doc = WB.Interf.Document

  Form.Common.Visible = True
  SDB.Objects("Top40") = Form
  OnSelect( Combo)
End Sub

Sub OnClose(Btn)
  SDB.Objects("Top40") = Nothing
End Sub

Sub OnSelect(DD)
  Set Form = SDB.Objects("Top40")
  Set WB = Form.Common.ChildControl("WB")
  Set Doc = WB.Interf.Document
  If DD.ItemIndex=0 Then
    Doc.Write "Select Week Above (Just last week there at the moment)"
    Doc.Close
  End If

  If DD.ItemIndex=1 Then
    Doc.Write "<h2>Last Weeks Top 40</h2>"
    Set QueryRes = SDB.Database.OpenSQL( "SELECT Count(IdSong) AS Top40Plays, Artist, SongTitle FROM (Songs INNER JOIN Played ON Songs.ID = Played.IdSong) INNER JOIN Artists ON Songs.IDArtist = Artists.ID GROUP BY Artist, SongTitle, IdSong, DatePart('ww',PlayDate) HAVING (((DatePart('ww',[PlayDate]))=DatePart('ww',Now())-1)) ORDER BY Count(IdSong) DESC" )    
    For i = 1 to 40
     Doc.Write "Plays: " & QueryRes.StringByIndex(0) & " - " & QueryRes.StringByIndex(1) & " - " & QueryRes.StringByIndex(2) & "<br>"
     QueryRes.Next
    Next
    Doc.Close
  End If
End Sub
Image
Guest

Post by Guest »

thanks for the redo of your redo trixmoto

and diddeleedoo i will try yours too and see what is going on with it.

all this help at once? i been trying to do something with this since they first wrote that script i posted above.

roving cowboy / keith hall.

not logged in again. 8)
rovingcowboy
Posts: 14163
Joined: Sat Oct 25, 2003 7:57 am
Location: (Texas)
Contact:

Post by rovingcowboy »

okay i just check the scripts out.
Diddeleedoo

your report script works fine just like you said it would do a report it does.

that can be a good tool for radio stations or anyonre else that wants to print out an hard copy of the the top 40 from the previous week.


trixmoto in your script were you took it out of the sub..

i get a vbs runtime error at line 9 char 3,
it says sdb is not defined.

i think that means the computer don't know what that is? :-?
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.
DiddeLeeDoo
Posts: 1017
Joined: Wed Mar 01, 2006 1:09 am
Location: In a jungle down under
Contact:

Post by DiddeLeeDoo »

I must admit I do not quite understand what you're trying to do Roving Cowboy, and what sort of results you're really after.

Could you try to explain what result you want in one, or max two lines... like a bullet point, without any extras... just one line to get the point...

Reset all the playcounters.... I get that.. but why?
Image
rovingcowboy
Posts: 14163
Joined: Sat Oct 25, 2003 7:57 am
Location: (Texas)
Contact:

Post by rovingcowboy »

DiddeLeeDoo wrote:I must admit I do not quite understand what you're trying to do Roving Cowboy, and what sort of results you're really after.

Could you try to explain what result you want in one, or max two lines... like a bullet point.

Reset all the playcounters.... I get that.. but why?
monkeys now playing list shows the times the song was played using the database table of songs and the field of playcount.

if you make an autoplaylist that will show the songs played the last 7 days and make it place them in that list according to the order played then you will get the most played song at the top of the list. and the lowest played song at the bottom of the list..

that is fine for one week when you start them all marked as only played zero times. but the next week the count will be adding both weeks counts so you don't get the true count of what was played in one week.

the songs table's playcount field needs to be reset to zero every week once a week doing this will change the songs listed in the autoplaylist. for the next time you play that playlist on saturday. because it will only have the playcounts for the songs from that one week.

at the present time i have to use the script i posted in the frist message of this thread, which is a manual script. it needs to have me select all the songs i want to reset then it needs me to go to the tools menu then to the scripts menu, and click on the scripts name. then press f 5 to refresh the list.

i would like it to do all those steps automaticly with out me having to click on anything.

so i am trying to get the script to start once on sunday morning and reset all the playcounts to zero in the songs table's playcount field for all the songs in the libriary. then close and do that every week with out me having to click on anything.

8)

by doing that then my auto playlist will always have the songs played that week showing up,

:lol:
your auto ratings script would be setting the songs from the history playcount field and would not be messed up. but the songs would always have the correct rating no matter how many times the play count in the songs table has been changed.

so the ratings part is taken care of when you get the new improved script completed to make it use the history playcount field.

:)
the autoplaylist is working but is not getting the proper data because the songs table playcount field is not being reset automaticly to zero every week.

did that longer explaining of them all help instead of the short explaintions.?

8)
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.
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Post by trixmoto »

I just forgot to declare it. Try this:

Code: Select all

  'code Author's 1. Pablo, 2. Roylayer 3. Popper 4. Anubis 5. Trixmoto
  ' increments play counter and sets last time played to current date and time
  ' Source: http://www.mediamonkey.com/forum/viewtopic.php?t=1461
  ' modified to work with a non-English date format and to also update the "Played" table.
  ' you need to refesh (F5) the screen to see the changes.
 
  Option Explicit
  Dim SDB
  Set SDB = CreateObject("SongsDB.SDBApplication")

    Dim s,itm
    Set s = SDB.Database.QuerySongs("")
    Do While Not s.EOF
      SDB.ProcessMessages
      Set itm = s.Item
 
      'must use sql because there is no itm.LastTimePlayed property
      SDB.database.execSQL("UPDATE Songs SET PlayCounter=" & (itm.PlayCounter - 1) & ",LastTimePlayed='" & now() & "' WHERE Id=" & itm.songID)
 
      ' there is another DB table that stores when the song was played,
      ' so in order to stay consistent, we update this, too.
      ' This table is used for the "50 last played songs" playlist
      SDB.database.execSQL("INSERT INTO Played (IdSong, PlayDate) VALUES (" & itm.songId & ", '" & Now() & "')")
     
      s.Next
    Loop
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
DiddeLeeDoo
Posts: 1017
Joined: Wed Mar 01, 2006 1:09 am
Location: In a jungle down under
Contact:

Post by DiddeLeeDoo »

This is a one-liner.

Need Song Playcount to be reset to 0 on Sunday at 12:00AM due to my playlists are currently configured to do.... something..

This can easely be solved too, but a tiny little .exe file that opens MM at that point in time, and set all the songs PlayCounter to 0 on Sunday at 12:00AM. If I make you an exe file like that I guess the problem you're trying to solve may be solved ?
Last edited by DiddeLeeDoo on Fri Apr 28, 2006 10:26 am, edited 1 time in total.
Image
rovingcowboy
Posts: 14163
Joined: Sat Oct 25, 2003 7:57 am
Location: (Texas)
Contact:

Post by rovingcowboy »

i am not any good at one line explainations :oops:

i tried to make it short but could not do so.

the exe is not needed if i can get the script to change it the way i want then i should beable to have that script run by a task scheduler job and that will work as the timer.
8)

okay trixmoto will check this one now.

Yes that is working Trixmoto it runs by just clicking on the script.

now i can use the task scheduler to make it run..


now if i can just figure a way to make it reset to zero instead of just subtracting one.?

the same script on the win98 ? i think it is the same script is reseting them all to zero maybe it has something to do with win98? will have to check them both side by side and see what is up?
Last edited by rovingcowboy on Fri Apr 28, 2006 10:34 am, edited 2 times in total.
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.
DiddeLeeDoo
Posts: 1017
Joined: Wed Mar 01, 2006 1:09 am
Location: In a jungle down under
Contact:

Post by DiddeLeeDoo »

That is what I mean, a tiny exe file, triggered by the scheduler to activate a cleaning script at 12:00AM every Sunday.

BTW, I'm sorry to be a bit short... It just makes it a bit hard pick out the point... I do not like to delete database data unless it's for a good purpose, but I understand it has something to do with how you use your playlists. ( I found the value of the MM data finally, silly me have kept deleting the data before I knew how it could be used in a good way)
Image
rovingcowboy
Posts: 14163
Joined: Sat Oct 25, 2003 7:57 am
Location: (Texas)
Contact:

Post by rovingcowboy »

DiddeLeeDoo wrote:That is what I mean, a tiny exe file, triggered by the scheduler to activate a cleaning script at 12:00AM every Sunday.
but the scripts monkey uses can be trigger by the task scheduler there is no need to do all that extra coding to make it in to an exe.

edited in
i just seen the way your exe would work. if some one is not playing monkey at the time then it would need to be started and closed.
i keep forgetting that others do not run monkey 24 /7 like i do.

i am right now triggering over 300 scripts for monkey by the task scheduler they work better because they use less memory when running.

but the exe's i try and run with task scheduler when monkey is playing music, they take up to much ram and mess up the songs.

trixmoto got this script working by triggering with the task scheduler.
now i have to figure out why it only subtacts one count.?

as i believe i have the same script on the win98 computer and it resets them all back to zero.

same script so it has to be the different os's that cause the different ways of running?

but i will check them both side by side and see what the other sciript is coded like just to make sure it was the same one i posted first here.
8)

thanks for the report script i got that to use now also. .

i have also added it to the all scripts thread.
Last edited by rovingcowboy on Fri Apr 28, 2006 10:57 am, edited 1 time in total.
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.
Post Reply