I am searching for a script which can modify the PlayCounter within MediaMonkey.
Due to mp3 players where playcounts are not counted and the use of AutoRate, i would like to update some of the songs manually so they pop up as high rated.
I found a script on this forum, but I didn't find any handlers (menu entrys or shortcuts) to alter the PlayCounter. A context menu or butten "+1" would be nice!
Anybody into this?
MM3 Modify PlayCount
Re: MM3 Modify PlayCount
Hi zerosignal,
I use this kind of scripts in MM3 quite for a while as I use autorate-script too.
take a look at http://www.mediamonkey.com/forum/viewto ... 9296#59296. There you find two script and icons to decrement or increment via toolbarbuttons.
If you need a script to change playcount to a specific value, then you should look at http://www.mediamonkey.com/forum/viewto ... =5777#5777.
Based on these scripts I made a modified version according to my needs, which combines increment, decrement and dialog in one script. So most of the coding is based on pablo's and viybel's work. (Thanks to them for their work.)
After placing script and icons (My script uses the icons from the mentioned script above plus one internal icon from MM.) in the Folder "Scripts\Auto " and restarting MM, you find three new buttons in the toolbar.
I use this script quite often without any problem. But as always, I cannot guarantee for anything which happens, when using this script.
I hope this helps you.
I use this kind of scripts in MM3 quite for a while as I use autorate-script too.
take a look at http://www.mediamonkey.com/forum/viewto ... 9296#59296. There you find two script and icons to decrement or increment via toolbarbuttons.
If you need a script to change playcount to a specific value, then you should look at http://www.mediamonkey.com/forum/viewto ... =5777#5777.
Based on these scripts I made a modified version according to my needs, which combines increment, decrement and dialog in one script. So most of the coding is based on pablo's and viybel's work. (Thanks to them for their work.)
After placing script and icons (My script uses the icons from the mentioned script above plus one internal icon from MM.) in the Folder "Scripts\Auto " and restarting MM, you find three new buttons in the toolbar.
Code: Select all
Option Explicit
Sub OnStartUp
Dim Bouton : Set Bouton = SDB.UI.AddMenuItem(SDB.UI.Menu_TbStandard,0,0)
SDB.Objects("Bouton") = Bouton
Bouton.Caption = "IncrementPlayCounter"
Bouton.OnClickFunc = "IncrementPlayCounter"
Bouton.UseScript = Script.ScriptPath
Bouton.Hint = "Increment Play counter"
Bouton.IconIndex = SDB.RegisterIcon("Scripts\Auto\IncrementPlayCounter.ico", 0)
Set Bouton = SDB.UI.AddMenuItem(SDB.UI.Menu_TbStandard,0,0)
SDB.Objects("Bouton") = Bouton
Bouton.Caption = "DecrementPlayCounter"
Bouton.OnClickFunc = "DecrementPlayCounter"
Bouton.UseScript = Script.ScriptPath
Bouton.Hint = "Decrement Play counter"
Bouton.IconIndex = SDB.RegisterIcon("Scripts\Auto\DecrementPlayCounter.ico", 0)
Set Bouton = SDB.UI.AddMenuItem(SDB.UI.Menu_TbStandard,0,0)
SDB.Objects("Bouton") = Bouton
Bouton.Caption = "ChangePlayCounterDialog"
Bouton.OnClickFunc = "ChangePlayCounterDialog"
Bouton.UseScript = Script.ScriptPath
Bouton.Hint = "Change play counter dialog"
Bouton.IconIndex = 37
End Sub
Sub DecrementPlayCounter(arg)
' Define variables
Dim list, itm, i
' Get list of selected tracks from MediaMonkey
Set list = SDB.SelectedSongList
' Process all selected tracks
For i=0 To list.count-1
Set itm = list.Item(i)
If itm.playcounter = 0 Then
'msgbox "Counter already zero."
'Call Test
Else
'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)
itm.playcounter = itm.playcounter - 1
itm.UpdateDB
End If
Next
End Sub
Sub IncrementPlayCounter(arg)
' Define variables
Dim list, itm, i
' Get list of selected tracks from MediaMonkey
Set list = SDB.SelectedSongList
' 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)
itm.playcounter = itm.playcounter + 1
itm.UpdateDB
Next
End Sub
Sub ChangePlayCounterDialog(arg)
Dim UI : Set UI = SDB.UI
' Create the window to be shown
Dim Form : Set Form = UI.NewForm
Form.Common.SetRect 100, 100, 267, 98
Form.FormPosition = 4 ' Screen Center
Form.Caption = "Set play counter"
Form.BorderStyle = 3 ' Dialog'
'Script.RegisterEvent Form.Common, "OnResize", "FormResize"
Dim Lbl : Set Lbl = UI.NewLabel( Form)
Lbl.Common.ControlName = "Lbl"
Lbl.Common.SetRect 10, 10, 100, 16
Lbl.Caption = "Insert a number. (Negative value to decrement.)"
Dim Edt : Set Edt = UI.NewSpinEdit(Form)
Edt.Common.ControlName = "Edt"
Edt.Common.SetRect 20, 30, 48, 16
Edt.MinValue = -100
Edt.MaxValue = 100
Edt.Value = 1
Edt.Common.Enabled = True
Edt.Common.Hint = "Set number to in- or decrement."
Dim ChB : Set ChB = UI.NewCheckBox( Form)
ChB.Common.ControlName = "ChB"
ChB.Common.SetRect 70, 30, 100, 20
ChB.Caption = "not played"
Script.RegisterEvent ChB.Common, "OnClick", "ChBClick"
Dim Btn : Set Btn = UI.NewButton( Form)
Btn.Common.ControlName = "Btn"
Btn.Common.SetRect 152, 28, 80, 25
Btn.Caption = "OK"
Btn.Default = true
Btn.ModalResult = 1
Script.RegisterEvent Btn, "OnClick", "BtnClick"
'ChBClick( Form)
SDB.Objects("MyDialogForm") = Form
'msgbox "show"
If Form.ShowModal = 1 Then
If ChB.Checked Then
'Set to 0'
Call ClearPlayCounter()
Else
If Edt.Value = 0 Then
'Nothing to do
'SDB.MessageBox "Value 0 = " & Edt.Value, mtInformation, Array(mbOk)
Elseif Edt.Value < 0 Then
'decrement'
'SDB.MessageBox "Value < 0 = " & Edt.Value, mtInformation, Array(mbOk)
Call XDecrementPlayCounter(Edt.Value)
Else
'increment'
'SDB.MessageBox "Value > 0 = " & Edt.Value, mtInformation, Array(mbOk)
Call XIncrementPlayCounter(Edt.Value)
End If
End If
Else
End If
'msgbox "back"
'Script.UnregisterAllEvents
End Sub
Sub FormResize( Form)
Dim FC : Set FC = Form.Common
Dim Lbl : Set Lbl = FC.ChildControl("Lbl")
Lbl.Caption = "("&FC.Left&","&FC.Top&")-("&FC.Width&","&FC.Height&")"
End Sub
Sub BtnClick()
'msgbox "start"
Dim FC : Set FC = SDB.Objects("MyDialogForm").Common
Dim Edt : Set Edt = FC.ChildControl("Edt")
if not isnumeric(edt.value) then
sdb.messagebox "Only Numbers allowed", mterror, Array(mbOk)
call ChangePlayCounterDialog("Restart Dialog")
else
'SDB.MessageBox "Wow, button clicked! Value = " & Edt.Value, mtInformation, Array(mbOk)
end if
'msgbox "end"
End Sub
Sub ChBClick( ChB)
Dim FC : Set FC = ChB.Common.TopParent.Common
Dim Edt : Set Edt = FC.ChildControl("Edt")
'Dim ChB :
Set ChB = FC.ChildControl("ChB")
Edt.Common.Enabled = not ChB.Checked
End Sub
Sub ClearPlayCounter()
' Define variables
Dim list, itm, i, x
'sdb.messagebox "arg= " & arg , mtInformation, Array(mbOk)
' Get list of selected tracks from MediaMonkey
Set list = SDB.SelectedSongList
' Process all selected tracks
For i=0 To list.count-1
Set itm = list.Item(i)
If itm.playcounter = 0 Then
'msgbox "Counter already zero."
'Call Test
Else
'Only set to 0'
'sdb.messagebox "result= " & (itm.playcounter + x) , mtInformation, Array(mbOk)
'must use sql because itm.UpdateDB does not update the PlayCounter property
SDB.database.execSQL("UPDATE Songs SET PlayCounter=" & 0 & " WHERE Id=" & itm.songID)
itm.playcounter = 0
itm.UpdateDB
End If
Next
End Sub
Sub XDecrementPlayCounter(arg)
' Define variables
Dim list, itm, i, x
'sdb.messagebox "arg= " & arg , mtInformation, Array(mbOk)
x = arg
' Get list of selected tracks from MediaMonkey
Set list = SDB.SelectedSongList
' Process all selected tracks
For i=0 To list.count-1
Set itm = list.Item(i)
If itm.playcounter = 0 Then
'msgbox "Counter already zero."
'Call Test
Elseif (itm.playcounter + x) <= 0 Then
'Only set to 0'
'sdb.messagebox "result= " & (itm.playcounter + x) , mtInformation, Array(mbOk)
'must use sql because itm.UpdateDB does not update the PlayCounter property
SDB.database.execSQL("UPDATE Songs SET PlayCounter=" & 0 & " WHERE Id=" & itm.songID)
itm.playcounter = 0
itm.UpdateDB
Else
SDB.database.execSQL("UPDATE Songs SET PlayCounter=" & (itm.PlayCounter - Abs(x)) & " WHERE Id=" & itm.songID)
itm.playcounter = itm.playcounter - Abs(x)
itm.UpdateDB
End If
Next
End Sub
Sub XIncrementPlayCounter(arg)
' Define variables
Dim list, itm, i, x
x = arg
' Get list of selected tracks from MediaMonkey
Set list = SDB.SelectedSongList
' 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 + x) & " WHERE Id=" & itm.songID)
itm.playcounter = itm.playcounter + x
itm.UpdateDB
Next
End Sub
I hope this helps you.
-
- Posts: 32
- Joined: Tue Nov 14, 2006 8:14 am
Re: MM3 Modify PlayCount
Wow, this works like a charm!
Great thanks so much for the great work!
Great thanks so much for the great work!