Work in progress - Modify Play Counter via script

Download and get help for different MediaMonkey Addons.

Moderators: Peke, Gurus

shoney
Posts: 11
Joined: Sat Nov 17, 2007 11:11 am

Post by shoney » Mon Jan 14, 2008 6:35 pm

I have a version of this script installed but when I upgraded to MM3, it started putting 12/31/1899 as the last played date. Below is the code. Anyone have any ideas how to fix this problem?

' 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

jk2587
Posts: 6
Joined: Mon Dec 03, 2007 11:11 pm

Post by jk2587 » Tue Jan 15, 2008 1:17 am

You just need to convert the now() to a double by doing CDbl(now()) and it will show up properly.
Hope that works for you.

shoney
Posts: 11
Joined: Sat Nov 17, 2007 11:11 am

Post by shoney » Tue Jan 15, 2008 1:51 pm

thanks jk2587. So to make sure I have it right, it should read:

SDB.database.execSQL("UPDATE Songs SET PlayCounter=" & (itm.PlayCounter + 1) & ",LastTimePlayed='" & CDbl(now()) & "' WHERE Id=" & itm.songID)

jk2587
Posts: 6
Joined: Mon Dec 03, 2007 11:11 pm

Post by jk2587 » Tue Jan 15, 2008 5:51 pm

Yep that should do it!

Guest

Post by Guest » Thu Jan 17, 2008 4:37 am

I tried this today, but now I get 16.1.1900 00:14 (instead of todays's date, 10:29)

Do you have another advice maybe?

Thanks

dgcom
Posts: 4
Joined: Mon Mar 19, 2007 5:02 pm

Post by dgcom » Wed Jan 30, 2008 2:44 am

If you look closer, you'll see that there are 2 lines where now() function is used. You need to replace it with CDbl(now()) in both of them.

I just tried - it works!
DG/NJ

spacefish
Posts: 1427
Joined: Mon Jan 14, 2008 7:21 am
Location: Denmark

Post by spacefish » Mon Mar 31, 2008 10:44 am

I'm looking for a script that will allow me to decrease playcounts. Will this script do that? I've read that it might be possible but I'm really not following how that could be accomplished. I'm also unclear on what modifications I need to make to the original script, if any.

If there is another, easier method to edit play counts, please point me to it. I understand I could have used Access for MM2. Is there an equivalent application for MM3's type of database that will allow me to see and edit values directly?

Thanks for any help!

Cheers,
Paula
Image
MM Gold 3.0.3.1183 : Vista HP SP1 (x86) : Zen Stone (2GB)
Zekton: An original MM3 skin by Eyal.
Scripts in Use: Add/Remove PlayStat | Auto Album DJ | AutoRateAccurate | Backup
Case & Leading Zero Fixer | Classification & Genre Changer | Clean Scripts.ini | Clear
Field | Custom Report | Discogs Auto-Tag Web Search | Forget Crossfade | Invert
Selection/Select None | Last 100... | Lyricator | Lyrics to Instrumental | MonkeyRok
MusicBrainz Tagger | My Custom Nodes | Now Playing Art Node | Play History & Stats
Right Click for Reports | Right Click for Scripts | Right Click for Web | Stop After Current
WebNodes

nynaevelan
Posts: 5559
Joined: Wed Feb 07, 2007 11:07 pm
Location: New Jersey, USA
Contact:

Post by nynaevelan » Mon Mar 31, 2008 11:07 am

spacefish wrote:I'm looking for a script that will allow me to decrease playcounts. Will this script do that? I've read that it might be possible but I'm really not following how that could be accomplished. I'm also unclear on what modifications I need to make to the original script, if any.

If there is another, easier method to edit play counts, please point me to it. I understand I could have used Access for MM2. Is there an equivalent application for MM3's type of database that will allow me to see and edit values directly?

Thanks for any help!

Cheers,
Paula
Paula:

You could try the Change Playcounter script, that is what I use when I want to change playcounts.

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

spacefish
Posts: 1427
Joined: Mon Jan 14, 2008 7:21 am
Location: Denmark

Post by spacefish » Mon Mar 31, 2008 12:14 pm

nynaevelan wrote:You could try the Change Playcounter script, that is what I use when I want to change playcounts.
OMG, that's awesome! And it worked out of the box. Thanks, Nyn! :)
Image
MM Gold 3.0.3.1183 : Vista HP SP1 (x86) : Zen Stone (2GB)
Zekton: An original MM3 skin by Eyal.
Scripts in Use: Add/Remove PlayStat | Auto Album DJ | AutoRateAccurate | Backup
Case & Leading Zero Fixer | Classification & Genre Changer | Clean Scripts.ini | Clear
Field | Custom Report | Discogs Auto-Tag Web Search | Forget Crossfade | Invert
Selection/Select None | Last 100... | Lyricator | Lyrics to Instrumental | MonkeyRok
MusicBrainz Tagger | My Custom Nodes | Now Playing Art Node | Play History & Stats
Right Click for Reports | Right Click for Scripts | Right Click for Web | Stop After Current
WebNodes

martialartsguy
Posts: 266
Joined: Mon Apr 03, 2006 9:11 am
Location: Denver, CO

Post by martialartsguy » Tue Apr 15, 2008 9:10 am

Can anyone tell me what's the newest updated version of this and if/how well it works with MM3.

Thanks!
MM 4.1.10.1778

dypsis
Posts: 1101
Joined: Wed Apr 30, 2008 9:51 pm

Post by dypsis » Thu May 01, 2008 3:35 pm

There are a few scripts posted in the thread.

Which is the best one?

Also. Why do we need scripts to reset the play counter? Shouldn't this be a built-in feature?

rrfpacker
Posts: 1041
Joined: Sat Jul 12, 2008 5:47 pm

Re: Work in progress - Modify Play Counter via script

Post by rrfpacker » Thu Mar 12, 2009 11:34 am

I see the latest post is from the middle of 2008 and noone responded. I hope this thread is still active.

I installed MM about 9 months ago, I only put a few songs into library so I could play and learn. Now that I am going to keep MM, I want to be able to reset my playcounts before I start filling in the library.

I installed the first script in the thread and inserted the corresponding script in the script.ini file. I can't tell if this works or not. The playcount field in track properties, classification tab does not change when I use Reset Play Counter and press F5. It does change if I use the Set Play Counter script.

I suppose I could use the Set Play Counter to set all songs to 0, but then what is the point for Reset?

As a couple others have posted, which one of the many scripts in this thread are the ones to use?

nynaevelan
Posts: 5559
Joined: Wed Feb 07, 2007 11:07 pm
Location: New Jersey, USA
Contact:

Re: Work in progress - Modify Play Counter via script

Post by nynaevelan » Thu Mar 12, 2009 11:46 am

RRF:

I am sure you will get many opinions on which is the "best", however I find Bex's AddRemove PlayStats offers the most flexbility and it is one of the most used scripts in my arsenal. :wink:

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

Benn
Posts: 300
Joined: Sat Jul 12, 2008 11:59 am
Location: Cornwall, United Kingdom

Re: Work in progress - Modify Play Counter via script

Post by Benn » Thu Mar 12, 2009 11:50 am

I second that ^^. :D

rrfpacker
Posts: 1041
Joined: Sat Jul 12, 2008 5:47 pm

Re: Work in progress - Modify Play Counter via script

Post by rrfpacker » Thu Mar 12, 2009 2:10 pm

I was actually talking about this particular script as it seems there are a couple versions along with other people's modifications. Looks like only the Set Playcount works for me, not the Reset Playcount. Does that mean that this script and AddRemovePlayStats are redundant?

However, I have played with AddRemovePlayStats quite a bit today, along with others, to reset all of my tracks at once (I've been practicing on just artists today), since I will begin to fill my library soon. Looks like AddRemovePlayStats only has a couple actions that change more than one track at a time. I'll have to deal with that.

One other thing. I noticed that MR does not completely agree with the Playing History & Stats node. A couple counts are off by one (not a biggee) but MR has two artists in the top 10 that I wiped out their playcounts.

Does it make sense to reset remove all plays if I reset the playcount? Is that the issue in MR?

Guess I have more to learn about these relationships.

Post Reply