Help with a simple mass-tagging script

This forum is for questions / discussions regarding development of addons / tweaks for MediaMonkey.

Moderator: Gurus

Help with a simple mass-tagging script

Postby Lediur » Sat Dec 26, 2009 9:46 pm

After hearing a lot of good things about MediaMonkey's tag management, I decided to use it to organize my music library for playback in Foobar2000.

To help with this, I've decided to write a script to help alleviate one of my pet peeves: missing disc numbers.

Basically, this script would iterate through the music library, check if the ID3 tags for %discnumber% and %totaldiscs% are present, and if not, insert '1' into each tag. There's no need for a user interface.

I'm familiar with C# and Java programming, but not with VBScript, nor the MediaMonkey API; please pardon the influence on my code :)

I've got this so far:

Code: Select all
' ---------------
'   DISC HUNTER
' ---------------
' Iterates through music and appends to TotalDiscs and CurrentDiscs Tag
' ---------------

Sub DiscHunter
    ' Vars
    Dim SongList, SelectedSong, Iterate
   
    ' Import the song database, break if empty.
    Set SongList = SDB.CurrentSongList
    If SongList.Count = 0 Then
        Exit Sub
    End If
   
    ' Iterate through song database.
    For Iterate = 0 To SongList.count - 1
        Set SelectedSong = SongList.Item(Iterate)
       
        ' If the DiscNumber tag is empty, replace it with '1'.
        If SelectedSong.DiscNumber = null Then
            SelectedSong.DiscNumber = 1
        End If
       
        ' Same, but with the TotalDiscs.
        If SelectedSong.TotalDiscs = null Then
            SelectedSong.TotalDiscs = 1
        End If
       
    Next
    SongList.UpdateAll
End Sub


This is what I'm aiming at, in C#:
Code: Select all
public class DiscHunter
{
    ArrayList SongList;
    Song SelectedSong;

   public DiscHunter()
   {
        SongList = SDB.CurrentSongList;
   }

    public void RunScript()
    {
        for (int i = 0; i < SongList.length; i++)
        {
            SelectedSong = SongList[i];

            if (SelectedSong.DiscNumber == null)
            {
                SelectedSong.DiscNumber = 1;
            }

            if (SelectedSong.TotalDiscs == null)
            {
                SelectedSong.TotalDiscs = 1;
            }
        }

        SongList.UpdateAll();
    }
}


I'm not sure how MediaMonkey's scripting interface interacts with tags, but from what I've gathered from some built-in scripts (mainly AutoIncTrackN.vbs), is it just a property of the Song?

P.S. Is there somewhere I could get a list of methods (functions) and their descriptions? I'm looking for something like the Javadocs or the MSDN documentation, but any list would do.

Thanks. :D
Lediur
 
Posts: 2
Joined: Sat Dec 26, 2009 9:04 pm

Re: Help with a simple mass-tagging script

Postby Melloware » Sat Dec 26, 2009 11:19 pm

You might want to try Bex's Tagging Inconsistencies plug-in. I used it to correct my entire collection and Missing Disc #'s is one of his searches. It is the greatest plugin for mass organizing a large collection and finding the weirdest and craziest mistakes.

http://www.mediamonkey.com/forum/viewtopic.php?f=2&t=14734
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Melloware Inc.
MonkeyTunes - DACP Server for MediaMonkey
Intelliremote - Take Back Control of your HTPC!
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Melloware
 
Posts: 332
Joined: Mon Aug 18, 2008 9:46 am
Location: Philadelphia, PA, US

Re: Help with a simple mass-tagging script

Postby trixmoto » Sun Dec 27, 2009 6:29 am

There is no "TotalDiscs" in MM and I think this check would work better for the "DiscNumber"...
Code: Select all
        If SelectedSong.DiscNumberStr = "" Then
            SelectedSong.DiscNumber = 1
        End If

Check the wiki for SongData properties... http://www.mediamonkey.com/wiki/index.php/SDBSongData
Download my scripts at trixmoto.net. If you're interested, check out my Uniface blog.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.

Image Image
trixmoto
 
Posts: 9948
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK

Re: Help with a simple mass-tagging script

Postby Lediur » Sun Dec 27, 2009 7:20 pm

trixmoto wrote:There is no "TotalDiscs" in MM and I think this check would work better for the "DiscNumber"...
Code: Select all
        If SelectedSong.DiscNumberStr = "" Then
            SelectedSong.DiscNumber = 1
        End If

Check the wiki for SongData properties... http://www.mediamonkey.com/wiki/index.php/SDBSongData


Thanks!

Melloware wrote:You might want to try Bex's Tagging Inconsistencies plug-in. I used it to correct my entire collection and Missing Disc #'s is one of his searches. It is the greatest plugin for mass organizing a large collection and finding the weirdest and craziest mistakes.

http://www.mediamonkey.com/forum/viewtopic.php?f=2&t=14734


I'll take a look at it.
Lediur
 
Posts: 2
Joined: Sat Dec 26, 2009 9:04 pm


Return to Addons developer forum

Who is online

Users browsing this forum: No registered users and 1 guest