Page 3 of 6

Last Played not updated

Posted: Mon Jun 27, 2005 2:53 pm
by Barracuda
Nice script, the played counter increases by 1 as it is supposed to, but the field Last Time Played does not show any changes.

I'm using latest official MM Gold.

Any ideas?

Posted: Wed Jun 29, 2005 3:21 am
by Anubis
I decided to try out the IncrPlayCntr script and I am also finding that the LastPlayField is not getting updated in the Songs table. The date/time field in the Played table is being updated.

Here is the code segment in question...

Code: Select all

  For i=0 To list.count-1
    Set itm = list.Item(i)
    'must use sql because itm.UpdateDB does not update the PlayCounter property
    SDB.database.execSQL("UPDATE Songs SET PlayCounter=" & (itm.PlayCounter + 1) & " WHERE Id=" & itm.songID)
    SDB.database.execSQL("UPDATE Songs SET 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() & "')")
   
    'refreshes screen
    itm.playcounter = itm.playcounter + 1
    itm.UpdateDB
  Next

anyone any ideas?

Posted: Fri Jul 01, 2005 12:05 am
by Barracuda
Unfortunately I don't know anything about scripting. I checked in my database and the playcounter does increase with the script. But the lastplayed date does not get updated.
The script looks ok to me, but again... I have no clue what I am looking at.

Posted: Fri Jul 01, 2005 2:53 am
by Anubis
Yeah. I know a little about programming, but nothing specific about VBScripting. It looks fine to me too.
The only thing I can think of is it is some sort of date format (USA vs Australian vs European?) problem, but I tried different formats and it still didn't work. I also tried using #'s around the date and putting a hard coded date in. <very strange>
I am actually wondering whether it could be a BUG with MM 2.4.
Hopefully the MM developers will have a look and set us straight.

Posted: Fri Jul 01, 2005 2:59 am
by Anubis
Ahhh, hold on...
I think I just worked out that I need to stop and start MM after changing scripts.
All my previous tests are invalid.
I'm just about to go out, so I don't have a chance to prove my theory for 3 hours.
Arrghh..

Posted: Fri Jul 01, 2005 10:18 am
by Barracuda
Thanks Anubis for looking into this.

Posted: Fri Jul 01, 2005 9:30 pm
by Anubis
OK, here is what works for me...
Couple of comments.
- I was wrong, you can update scripts (or at least this one) and run it without stopping and starting MM.
- The problem as I see it, was that it was using execlSQL and UpdateDB. It seems only one or the other can be used against the data.
- This script does not refresh the screen, you need to do a manual REFRESH (F5). I couldn't see a way of forcing a refresh (I didn't look too hard either).
This works for me, hope it does for you.

Code: Select all

' 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

Yes!

Posted: Sat Jul 02, 2005 12:30 am
by Barracuda
Yes, you did it. Thanks a lot.
It's a nice little script that I use after copying songs to my Iriver flashplayer. Keeps my autoplaylists updated correctly.

cheers.

Posted: Sat Jul 02, 2005 2:10 am
by Anubis
Good to hear it works for you too.

I use it to record the stats of what CD's I listen to in the car. I listen to music more in the car then anywhere else, and I have not liked that the "car stats" were not being collected.

One day I'll get an iPOD (and a car system that can handle an iPOD) and than MM will get the stats automatically.

Posted: Mon Jul 11, 2005 5:23 pm
by Guest
i copied this last code you said works and saved it so now where do i put it and how do i use it to change the played count in the media monkey list's

thanks

Posted: Mon Jul 11, 2005 5:52 pm
by Bex
Anonymous wrote:i copied this last code you said works and saved it so now where do i put it and how do i use it to change the played count in the media monkey list's

thanks
You must modify your scripts.ini file as well. It's described in the very first post in this thread. Then you'll find the script in Tools->Scripts

Posted: Mon Jul 11, 2005 10:11 pm
by Guest
so i got to go back and get all the other scripts? starting with the first one?
or do i just subitute this last script for the first script , and then copy the first script ini change in the first post?

Posted: Tue Jul 12, 2005 3:27 am
by Anubis
Anonymous wrote:so i got to go back and get all the other scripts? starting with the first one?
or do i just subitute this last script for the first script , and then copy the first script ini change in the first post?
Put this in your script.ini

Code: Select all

[IncrementPlayCounter]
FileName=IncrPlayCntr.vbs
ProcName=IncrPlayCntr
Order=20
DisplayName=Increment Play Counter
Description=Increment the play counter by 1
Language=VBScript
ScriptType=0
And save the LAST script as IncrPlayCntr.vbs into your scripts folder and stop and start MM. Then look under TOOLS->SCRIPT for INCREMENT PLAY COUNTER.

That should do it...

Posted: Tue Jul 12, 2005 3:57 am
by Guest
thank you i will do that and to answer your other post in the other message. :) i did look 8)

Posted: Tue Jul 12, 2005 3:34 pm
by Guest
as a suggestion !!!

anyone copying the above ini code.

in the display name you might want to add " F5 for Results"
:lol:

i had read some where in one of the posts? to stop and start media monkey so i was doing that until i thought to try refreshing the playlist..
:roll:

also you can change that number one in the vbs script code to anything you want i even changed it to subtract the numbers and zero them back out.

only i have trouble with media monkey not beeing able to open code tables past the amount of 300?

makes it a little tiresome when you have 10,000 you want to change?

:(