Work in progress - Modify Play Counter via script

Download and get help for different MediaMonkey Addons.

Moderators: Peke, Gurus

Anubis
Posts: 439
Joined: Fri Feb 04, 2005 4:57 pm
Location: Sydney, Australia

Post by Anubis » Sat Jul 16, 2005 8:11 am

Anonymous wrote: 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?

:(
What version of MM are you using?
Try 2.4.2, I'm pretty sure the code tables bug is corrected in 2.4.2.

Guest

Post by Guest » Sat Jul 16, 2005 3:37 pm

241.862 is the version i have did not relize i did not get the updated one ? will check with that maybe it will fix the trouble with my other script not starting in the auto folder thread also. :o

Guest

Post by Guest » Sun Jul 17, 2005 8:22 am

okay got the new one and it did not fix the trouble with my script in the other thread.

but not sure on this playcounter script as i got them all changed before?

i guess i could change them just to test it?

okay it changes more then 300 now. :lol: :D

mjs93
Posts: 158
Joined: Fri Jun 17, 2005 3:28 am

Post by mjs93 » Fri Aug 12, 2005 6:48 pm

I was afraid to try all these scripts because I'm pretty scripts-stupid, but I finally had to to keep my stats balanced. This is great! I used PlayCounter.vbs (the second one posted) and IncrPlayCntr.vbs. Just wanted to say thanks. :) Btw, is this still a problem?
Pablo wrote: You're right! My Set Counter and Set Counter (advanced) scripts DO NOT update the database. Maybe the playCounter field was somehow implemented as read-only...
...because they seem to update fine for me?

ETA: Just found a couple of things, when you click "Restore Play Counter," your playcounter reverts to MM count only and loses the iPod song counts you synced to it. That was when I was only using PlayCounter.vbs. Then after installing IncrPlayCntr.vbs, Restore Play Counter won't work at all. Hmm.

Well, still many thanks for these scripts!

Guest

Glitchy weirdness

Post by Guest » Thu Aug 25, 2005 8:51 pm

Hallo All-
I'm running 2.4.2.874, and when I try the IncrPlayCounter script, either it seems not to work (even after tapping F5),
or returns an error indicating that "...a related record is required in the table 'Songs'"
Then I get another, more specific, pointing to Line 29, Column 4 of IncrPlayCntr.

All this is being attempted on a playlist actually located on my Archos. Is that an issue?
I get the same result on the whole list, three files, of just one.

I've perused the Forum topic wher I found the scripts, and I don't think this was mentioned
The Change Play Counter script seems to work fine. Anything I'm missing/got botched?

Thanks mooch,
-G

jwc905
Posts: 3
Joined: Wed Sep 28, 2005 10:46 am

Modifying play count for tracks on a Mass Storage device

Post by jwc905 » Thu Nov 24, 2005 11:01 pm

I installed this script in the hopes that I could manually update the play statistics for my iAudio X5 (a mass storage device) whenever I synced it up. Unfortunately I ran into a little snag.

The process I planned to use was to take whatever playlist I had been listening to, select upto whatever track I was on, and then run this script. Then I would be able to generate a new playlist which reflected these changes.

Unfortunately the playlists I'm using are auto playlists so the version on MM doesn't reflect the one on my X5. If I run this script using the playlist on my X5 then I get a lot DB errors.

The only solutions I can see are:

1) save a copy of the autoplay lists when I sync so that I can refer to them on the next sync
2) Somehow map the tracks on the iAudio back to the MM library. Which should be possible they were generated by MM in the first place.

Does anyone have any tips on how I might go about modifying this script or using a set of scripts to accomplish the above?

Thanks in advance,
Jeff

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

Post by rovingcowboy » Fri Dec 16, 2005 8:20 pm

I am now having trouble with this script in beta version 4.

it is not changing the playcount to any other number then zero.

i think i am using the last script in the thread.

i am not sure whom wrote it. as there were so many updating it.

but i use to beable to change the code from +1 to +500 and change the count to 500 or make it -5000 and change the count down 5000 from what it was?

but now it only changes to 0 not a big problem unless you want to make certian songs show up in the top 50 list at different times of the year. like now it is christmas time so i was trying to up all the christmas songs to be the only ones in the top 50 list but it zero'ed them all so now i have to keep making all the other songs zero so the christmas songs add to their count and the rest do not?

:(
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 5 Android 5) 6. Proscan tablet Android 4.3 ) 7. amd a8-5600 apu 3.60ghz mm version 4 windows 7 pro bought from computer store.

Guest

Post by Guest » Fri Apr 14, 2006 9:22 am

Pablo.

is there any way you can make this script of yours run automatily and only run at a set day and time like once a week and make all the songs get auto selected and then reset back to zero?

if that can be done then this script combined with the auto rating script will be a great way to keep a weekly top of the charts play list.

thanks

roving cowboy / keith hall.

not logged in this moring

MeMeMe
Posts: 263
Joined: Fri Dec 23, 2005 11:42 am
Location: In front of my computer

Post by MeMeMe » Mon Apr 17, 2006 11:02 pm

When using the advanced script I get the following error:
There was a problem querying the database:
42000:[Microsoft][ODBC Microsoft Access Driver] Syntax error in UPDATE statement.

I'm using MM 2.5.2.951
Here's the code I used

Code: Select all

Sub SetPlayCounter 

  ' Define variables 
  Dim list, itm, i, newPlayCounter, mb, progress 
  
  'Get a new value for the Play Counter from the user 

  newPlayCounter = InputBox("Enter the new value for the Played field", "Set Play Counter") 
  
  'If Canceled, exit 
  If  newPlayCounter = "" Then 
     Exit Sub 
  End If 
  
  'Check that the text entered is a valid parameter. Inform user if it isn't. 
  If Not IsNumeric(newPlayCounter) Then 
     mb = MsgBox("You did not enter a number. Please try again.",0,"Error") 
     Exit Sub 
  ElseIf newPlayCounter < 0 Then 
     mb = MsgBox("Only positive numbers or 0 are allowed. Please try again.",0,"Error") 
     Exit Sub 
  End If 

  ' Get list of selected tracks from MediaMonkey 
  Set list = SDB.SelectedSongList 
  If list.count=0 Then 
     Set list = SDB.AllVisibleSongList 
  End If  
  
  'No songs selected? 
  If list.count = 0 Then 
     mb = MsgBox("No songs were selected. Please select some songs and try again",0,"Error") 
     Exit Sub 
  End If 
  
  'Set up progress 
  Set Progress = SDB.Progress 
  Progress.Text = "Writing New Play Counters..." 
  Progress.MaxValue = list.count 

  'Process all selected tracks 
  For i=0 To list.count-1 
    Set itm = list.Item(i) 
    'Set the Play Counter 
    itm.PlayCounter = newPlayCounter 
    itm.UpdateDB 
    Progress.value = i+1 
    If Progress.terminate Then 
       Exit For 
    End if    
  Next 
  
  Set Progress =  nothing 
  
End Sub 

Sub ResetPlayCounter 
    
   'This is drastic, so require confirmation from user 
    
   Dim yesimsure 

   yesimsure = InputBox("Are you sure you want to reset the play counter for all tracks in the Library? Write YES to proceed. Note: You will have to refresh the view (F5) in order to see the changes.", "Reset Play Counter") 
    
   If yesimsure <> "YES" Then 
      Exit Sub 
   End If 

   'Reset the counter... 
   SDB.Database.ExecSQL("UPDATE SONGS SET PLAYCOUNTER = 0 WHERE TRUE=TRUE") 

End Sub 

Sub RestorePlayCounter 

   'This is drastic, so require confirmation from user 
    
   Dim yesimsure 

   yesimsure = InputBox("Are you sure you want to restore the play counter to the number of times each track was played in MediaMonkey? Write YES to proceed. Note: You will have to refresh the view (F5) in order to see the changes.", "Restore Play Counter") 
    
   If yesimsure <> "YES" Then 
      Exit Sub 
   End If 

   Dim Str1, Str2, Str3, Str4, Str5 
    
   'Create a temporary table which stores song IDs and the number of times each song was played 
   Str1 = "SELECT Songs.ID, timesPlayed INTO updateCounter " 
   Str2 = "FROM Songs, [SELECT Played.idSong as SID, Count(Played.idSong) AS timesPlayed  FROM Played GROUP BY Played.idSong]. AS subq " 
   Str3 = "WHERE Songs.Id =subq.SID" 
    
   SDB.Database.ExecSQL(Str1 & Str2 & Str3) 
    
   'Use the table just created to update the playCounter field in the songs table 
   Str4 = "UPDATE Songs, updateCounter SET songs.playcounter = updateCounter.timesPlayed " 
   Str5= "WHERE songs.id=updateCounter.id" 
    
   SDB.Database.ExecSQL(Str4 & Str5) 
    
   'Delete temporary table 
   SDB.Database.ExecSQL("DROP TABLE updateCounter") 
    

End Sub 

Function Min(x, y) 
   If x<y Then 
      Min = x 
   Else 
      Min = y 
   End If 
End Function 
          
Function Max(x, y) 
   If x>y Then 
      Max = x 
   Else 
      Max = y 
   End If 
End Function 

Sub SetPlayCounterAdvanced 

  ' Define variables 
  Dim list, itm, i, userInput, newC , mb, progress, C 
  
  'Get a new value for the Play Counter from the user 

  userInput = InputBox("Enter a formula for the new play counter. Use C to refer to the current value. Examples: 0, C+1, Max(1,C).", "Set Play Counter (Advanced)") 
  
  'If Canceled, exit 
  If  userInput = "" Then 
     Exit Sub 
  End If 
  

  ' Get list of selected tracks from MediaMonkey 
  Set list = SDB.SelectedSongList 
  If list.count=0 Then 
     Set list = SDB.AllVisibleSongList 
  End If  
  
  'No songs selected? 
  If list.count = 0 Then 
     mb = MsgBox("No songs were selected. Please select some songs and try again",0,"Error") 
     Exit Sub 
  End If 
  
  'Set up progress 
  Set Progress = SDB.Progress 
  Progress.Text = "Writing New Play Counters..." 
  Progress.MaxValue = list.count 

  'Process all selected tracks 
  For i=0 To list.count-1 
  
    Set itm = list.Item(i) 
    C = itm.playCounter 
    'Evaluate user input 
    newC = Eval(userInput) 
    
    'Set the Play Counter 
    itm.PlayCounter =  SDB.database.execSQL("UPDATE Songs SET PlayCounter=" & newValue & " WHERE Id=" & itm.songID)
    itm.playCounter = itm.playCounter + 1 
    itm.updateDB 
    Progress.value = i+1 
    If Progress.terminate Then 
       Exit For 
    End if    
  Next 
  
  Set Progress =  nothing 
  
End Sub 

agentsmart

Post by agentsmart » Wed Apr 26, 2006 2:32 pm

i just re read this whole thread and it looks like you got pablos first or second script. check page 3 and get that last one there.
see if that works for you. :o

MeMeMe
Posts: 263
Joined: Fri Dec 23, 2005 11:42 am
Location: In front of my computer

Post by MeMeMe » Thu Apr 27, 2006 4:31 am

Are you referring to the second one by Anubis on that page?

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

Post by rovingcowboy » Thu Apr 27, 2006 7:49 am

i looked at that page and i think he is meaning the same code i reposted in the new thread here of "auto weekly top of the charts thread."

as i got the same code from that page and that is the one that works

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 5 Android 5) 6. Proscan tablet Android 4.3 ) 7. amd a8-5600 apu 3.60ghz mm version 4 windows 7 pro bought from computer store.

MeMeMe
Posts: 263
Joined: Fri Dec 23, 2005 11:42 am
Location: In front of my computer

Post by MeMeMe » Thu Apr 27, 2006 7:59 am

Okay, thanks.

clubsoda

Post by clubsoda » Tue Jan 01, 2008 2:35 pm

Hi all,

I'm using the script Anubis posted on page 3 of this thread - MM 3 (3.0.1.1127) does something weird with the date when I try to increment the play counter:

The "last played" field changes to 31.12.1899, 00:14. It seems that the new year has something to do with it, but I'm totally clueless about scripting. Does anyone have an idea?

Thx

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

Post by rovingcowboy » Tue Jan 01, 2008 4:08 pm

its old code i even took it off my win98 it does mess up things.
and it was not wrote with mm 3 even in mind. it was done for mm 2.0 or 2.1 way back.
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 5 Android 5) 6. Proscan tablet Android 4.3 ) 7. amd a8-5600 apu 3.60ghz mm version 4 windows 7 pro bought from computer store.

Post Reply