Thanks for the good work. Incrementing the "played#" counter was something I was looking for for quite a while now!
In case anyone is still reading this topic, I have made some minor modifications to your IncrPlayCntr script that I wanted to give back to the forum.
I don't know much about VBS programming, but it seems that what I've done is actually working:
- Now it also works on a Windows with a non-English regional setting.
- LastTimePlayed is set to "Now" which also includes the exact time of day.
- Now also the separate "Played" DB table is updated with the new data so that the information stays consistent across the database.
Hope you like it.
Code: Select all
' increments play counter
' 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.
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 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
End Sub