Click here to Skip to main content
Click here to Skip to main content

Yamo - A simple music library organizer and album art downloader written in C#

By , 22 Mar 2006
Rate this:
Please Sign up or sign in to vote.

Introduction

Yamo (Yet another music organizer), manages a music library, moving and renaming song files based on a set of options specified by the user. Yamo is composed of a dynamic library that implements the library manager engine, and a wizard application that allows easy access to the Yamo engine services. Both the library and the wizard are written in C#. Being a library, the Yamo engine can be used even inside third party applications.

Additionally, Yamo can download album art for your music collection, using custom internet sources. Actually, Amazon web service is the only album art provider available, but others can be added expanding a simple Yamo library interface.

Background

The implementation of Yamo started because I, as a WinAmp user, felt the need for an application able to organize my music library in a custom way (WinAmp, at least in its current version, lacks this feature). Other media players like WMP and ITunes already implement a library manager, but neither of them were completely OK for my needs, because they both act in a quite fixed behaviour (i.e. WMP organizes library folders following an Artist/Album pattern, I wanted my library organized by Genre/Album).

Using the wizard

Using the Yamo wizard application is quite straightforward, anyway here is a brief guide on the steps to follow to get Yamo ready to process your music library

Step 1: Music library root

In this step, you simply have to specify what's the root of your music library, and tell Yamo what operations you want to perform on it.

Step 2: Options

Here you can specify all your preferences about the way Yamo will get your library reorganized.

For instance, if you want your songs to be organized first by artist and then by album, like Windows Media Player does, you simply have to write the string Artist/Album in the library folder structure box. If you wish to place songs with no artist information to be placed in a folder named Unknown Artist, add it in round brackets after the Artist tag: Artist(Unknown Artist)/Album. The same thing applies to every other supported tag.

To set your preferences about music file names, write a format string in the filename format box (or choose from the predefined ones). Tags specified inside square brackets will expand to the corresponding piece of information stored in the single file (i.e. the [Track] token will expand to the track number of the song). Every other character specified outside square brackets will be left as it is in the resulting file name.

To get help for these and every other supported options, simply hold your mouse pointer over one of the ? signs in the Options window.

That's it. Now Yamo should be ready to go Smile | :)

After the first run, your preferences will be stored in an external options file. If you are going to add several files to your library and want Yamo to organize them, then you probably don't need to change any of your previous choices. In this case, you can start Yamo with the r option set (for instance by typing Yamo -r at the command prompt). Yamo will then directly start processing your library with the saved preferences.

Using Yamo in your application

If you want to include the Yamo engine in your code, first of all you need to add a reference to the SharpFactory.Yamo.Core.dll library in your project. Note that this is not the only library you will have to take along in order to use the engine. You'll need the Interop.ShazamMP3.dll and WMFSDKWrapper.dll libraries too (You can find them in the source and binary distributions of Yamo). You don't have to add references to these libraries in your project though.

Once the reference is set, you can start using the engine. The following code is a complete console application that will take as argument the path to a music library and will organize it using some default 'hardcoded' options:

using System;
using SharpFactory.Yamo.Core;

namespace YamoSample
{
    class SampleApp
    {
        [STAThread]
        static void Main(string[] args)
        {
            // This sample application will show 
            // how to user the Yamo engine inside 
            // a third party application. In order 
            // to keep as simple as possible, the
            // sample will set some standard engine 
            // options without asking the user.
            // The only argument passed to the 
            // application is the path of the music library.

            Options options = new Options();
            Engine engine = new Engine();

            engine.EngineEvent+=
                new EngineEventHandler(engine_EngineEvent);

            // First command line argument is the path 
            // of the music library we want to organize.
            options.LibraryRoot = args[0];

            // (***NEW***) Enable music library reorganization.
            options.OrganizeMusic = true;

            // Organize songs by genre and then by album.
            // This corresponds to the 
            // 'Genre(Unknown Genre)/Album(Unknown Album) 
            // format string in the Yamo Wizard.
            options.FolderOptions.Add(
                new FolderOption(FolderType.Genre, "Unknown Genre"));
            options.FolderOptions.Add(
                new FolderOption(FolderType.Album, "Unknown Album"));

            // Song file names will contain track and title.
            // This corresponds to the '[Track] - [Title]' 
            // format string in the Yamo Wizard.
            options.FilenameOptions.Add(
                new FilenameOption(FilenameComponent.Track));
            options.FilenameOptions.Add(
                new FilenameOption(" - "));
            options.FilenameOptions.Add(
                new FilenameOption(FilenameComponent.Title));

            // Enable the Shazam tag reader.
            options.TagReader = TagReaders.Shazam;

            // Enable album art downloading and activate the
            // Amazon media information provider.
            options.DownloadAlbumArt = true;
            options.MediaInformationProviders.Add("Amazon");


            Console.WriteLine("Press [enter] to stop music " + 
                                          "library refactoring.");
            System.Threading.Thread.Sleep(1000);

            // Start library refactoring.
            engine.Start(options);

            // Wait until processing has ended or uses presses esc.
            while(engine.IsRunning && Console.In.Peek() == -1)
            {
                System.Threading.Thread.Sleep(500);
            }

            // If engine is still running stop it now.
            // (this happens when the user presses the [enter] key)
            if(engine.IsRunning) 
            {
                engine.Stop();
            }
        }

        private static void engine_EngineEvent(
                                object sender, EngineEventArgs args)
        {
            // Uncomment the following to avoid excessive verbosity.
            //if(args.EventType != EngineEventType.Message) 
            {
                Console.WriteLine(args.Message);
            }
        }
    }
}

Conclusion

So, that's it. But I want to end with a brief note: I created this program mainly for my personal use. I needed something of this kind, and had fun coding it. I'm now distributing Yamo hoping that someone else finds at least some piece of the code useful, but I don't make any kind of guarantee on the program itself! Yamo was coded in little time, and has more than a pair of bugs, for sure. It works well on my music library (about 2000 files), but if you really want to try it on yours, make sure you take a backup copy of it first! (You should have done it already, anyway Poke tongue | ;-P ).

History

  • 31-Oct-05
    • Article
      • First release.
    • Code (0.4)
      • First release.
  • 6-Feb-06
    • Article
      • Revised.
    • Code (1.0 Preview)
      • Project ported to .NET Framework 2.0 / Visual Studio 2005.
      • The ignored file list now works correctly and supports wildcard characters.
      • The wizard was ignoring saved folder options (bug fix).
      • The engine can now move a set of user specified relevant files along with music files. (In the previous version some relevant files (like album art) were hard coded in the engine.)
      • Complete restyling of the wizard.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Febret
Instructor/Trainer
Italy Italy
No Biography provided

Comments and Discussions

 
QuestionHELP PLZ!!! [modified] Pinmembercworkman2972918-May-09 2:32 
QuestionError getting PinmemberAndrew Staffer20-Mar-09 18:49 
AnswerRe: Error getting Pinmembercarpenn24-Jun-09 15:54 
Generalalbum art code PinmemberAmrykid22-Nov-07 17:07 
GeneralRe: album art code PinmemberAlessandro Febretti26-May-08 9:26 
Generaltop of it PinmemberAmrykid22-Nov-07 16:07 
GeneralRe: top of it PinmemberAlessandro Febretti26-May-08 9:31 
QuestionPlans to Add More AlbumArt Sources??? PinmemberSukhjinder_K26-Oct-07 6:35 
GeneralExtract image PinmemberWebtijn2-Jan-07 5:03 
QuestionNew user to YAMO Pinmemberactigner12-Dec-06 17:38 
GeneralCopy files PinmemberLogge26-Apr-06 20:41 
GeneralRe: Copy files Pinmemberthracx27-Jun-08 7:18 
Generaldifuculty installing aplication Pinmemberrorobebe2-Apr-06 2:29 
GeneralRe: difuculty installing aplication PinmemberAlessandro Febretti2-Apr-06 23:29 
GeneralUndo Option PinmemberMaxim Discord23-Mar-06 5:25 
GeneralRe: Undo Option PinmemberFebret23-Mar-06 6:01 
GeneralRe: Undo Option Pinmemberlolocmwa3-Apr-06 3:33 
JokeSweet! Suggestion - junction links PinmemberDan F23-Mar-06 0:26 
GeneralRe: Sweet! Suggestion - junction links PinmemberFebret23-Mar-06 6:00 
GeneralLisense Pinmembertayspen30-Nov-05 9:33 
GeneralRe: Lisense PinmemberAlessandro Febretti1-Dec-05 3:28 
GeneralRe: Lisense Pinmembertayspen3-Dec-05 11:31 
GeneralLooks great! Pinmemberkryzchek1-Nov-05 6:32 
GeneralRe: Looks great! PinmemberFebret1-Nov-05 7:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web03 | 2.8.140415.2 | Last Updated 23 Mar 2006
Article Copyright 2005 by Febret
Everything else Copyright © CodeProject, 1999-2014
Terms of Use
Layout: fixed | fluid