Author Topic: Script to mass edit play counters  (Read 5394 times)

TekGamer

  • Newbie
  • *
  • Posts: 2
Has anyone written a script/plugin that could do the following or can help with this request?

- Say I have a playlist that I exported out of another program that I imported into MusicBee
- This playlist is called "Top 1000 Played EDM Tracks"
- Since I am new to MusicBee the play counts on all my files are 0
- I am looking for a script that will take a selected x number of tracks and take the track at the top and set its play count to x, the 2nd track set to a play count of x-1 and so on, until the last track in the selected list of tracks gets a play count of 1

If this is an easy ask, can anyone help and "whip something up"? It would be greatly appreciated ;-)

If it helps... I had a vb script in that other program called "AutoDecrementPlayCounters" that would ask for the top # and do the same thing as described above, I just don't know how to convert it to a MusicBee plugin

Code
Sub AutoDecrementPlayCounters
  ' Define variables
  Dim list, itm, i, tmp

  ' Get list of selected tracks from MediaMonkey
  Set list = SDB.CurrentSongList
  If list.Count=0 Then
    Exit Sub
  End If

  Set UI = SDB.UI

  ' Create the window to be shown
  Set Form = UI.NewForm
  Form.Common.SetRect 0, 0, 400, 180
  Form.FormPosition = 4   ' Screen Center
  Form.BorderStyle = 3    ' Dialog
  Form.Caption = SDB.Localize("Auto-decrement Play Counters")

  Set Lbl = UI.NewLabel( Form)
  Lbl.Common.SetRect 10,15,370,40
  Lbl.AutoSize = False
  Lbl.Multiline = True
  Lbl.Caption = SDB.LocalizedFormat( "This will modify the play count field in sequential decreasing order for the %d selected tracks. Do you want to proceed?", list.Count, 0, 0)     ' TODO:  Localize

  Set Lbl = UI.NewLabel( Form)
  Lbl.Common.SetRect 10,65,280,20
  Lbl.Caption = SDB.Localize("Start numbering from:")

  Set SE = UI.NewSpinEdit( Form)
  SE.Common.SetRect Lbl.Common.Left+Lbl.Common.Width+10, 61, 50, 20
  SE.MinValue = 1
  SE.MaxValue = 9999
  SE.Value = 1

  Set Btn = UI.NewButton( Form)
  Btn.Caption = SDB.Localize("OK")
  Btn.Common.SetRect 115,100,75,25
  Btn.ModalResult = 1
  Btn.Default = true

  Set Btn = UI.NewButton( Form)
  Btn.Caption = SDB.Localize("Cancel")
  Btn.Common.SetRect 220,100,75,25
  Btn.ModalResult = 2
  Btn.Cancel = true
  
  if Form.ShowModal=1 then
    number = SE.Value
    ' Process all selected tracks
    For i=0 To list.count-1
      Set itm = list.Item(i)

      ' Swap the fields
      itm.PlayCounter = number
      number = number - 1
    Next
    list.UpdateAll
  End If
End Sub

NighTeagle

  • Jr. Member
  • **
  • Posts: 22
I'm looking into something similar (https://getmusicbee.com/forum/index.php?topic=28835.0). I was hoping to write a script in VBA to accomplish this, but got stuck in getting the reference for Musicbee added into VBA. Eventually I found a way to generate a type library based on the Musicbee API, which I could then add as reference, but I couldn't get any script to work. I guess this just isn't supported in the API.

So I wanted to follow Steven's suggestion and try writing a plugin in VB.Net, but the learning curve was a bit steeper than I thought and I haven't made any progress. However someone was able to retrieve the basic 'How To Create A Simple Plugin' from a removed wiki page (https://getmusicbee.com/forum/index.php?topic=28826.0). So my next step was to start there and see where I end up.

Maybe we can try and figure this out together  ;)

TekGamer

  • Newbie
  • *
  • Posts: 2
NighTeagle,

The code I provided as an example (from a MediaMonkey addon) I did not write, I tweaked the original code a bit to modify it from changing track #s to changing played #s.

Sorry, I'm not a scripter/coder  :-X

NighTeagle

  • Jr. Member
  • **
  • Posts: 22
Well, I'll definitely post something here if I ever figure this out :)

NighTeagle

  • Jr. Member
  • **
  • Posts: 22
Turns out there was an easy way to do this after all with a python script and the MusicBeeIPC plugin. For more info, check this topic: https://getmusicbee.com/forum/index.php?topic=29389.0

It should be fairly straightforward to change this according to your needs.