Click here to Skip to main content
11,709,220 members (72,390 online)
Click here to Skip to main content

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

, 22 Mar 2006 99.6K 1.5K 89
Rate this:
Please Sign up or sign in to vote.
Yamo is a C# application capable of organizing a music library, moving files, renaming them and downloading album cover art through pluggable media information providers.

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

Share

About the Author

Febret
Instructor/Trainer
Italy Italy
No Biography provided

You may also be interested in...

Comments and Discussions

 
QuestionHELP PLZ!!! [modified] Pin
cworkman2972918-May-09 2:32
membercworkman2972918-May-09 2:32 
QuestionError getting Pin
Andrew Staffer20-Mar-09 18:49
memberAndrew Staffer20-Mar-09 18:49 
AnswerRe: Error getting Pin
carpenn24-Jun-09 15:54
membercarpenn24-Jun-09 15:54 
Generalalbum art code Pin
Amrykid22-Nov-07 17:07
memberAmrykid22-Nov-07 17:07 
GeneralRe: album art code Pin
Alessandro Febretti26-May-08 9:26
memberAlessandro Febretti26-May-08 9:26 
Generaltop of it Pin
Amrykid22-Nov-07 16:07
memberAmrykid22-Nov-07 16:07 
GeneralRe: top of it Pin
Alessandro Febretti26-May-08 9:31
memberAlessandro Febretti26-May-08 9:31 
QuestionPlans to Add More AlbumArt Sources??? Pin
Sukhjinder_K26-Oct-07 6:35
memberSukhjinder_K26-Oct-07 6:35 
GeneralExtract image Pin
Webtijn2-Jan-07 5:03
memberWebtijn2-Jan-07 5:03 
QuestionNew user to YAMO Pin
actigner12-Dec-06 17:38
memberactigner12-Dec-06 17:38 
GeneralCopy files Pin
Logge26-Apr-06 20:41
memberLogge26-Apr-06 20:41 
GeneralRe: Copy files Pin
thracx27-Jun-08 7:18
memberthracx27-Jun-08 7:18 
Generaldifuculty installing aplication Pin
rorobebe2-Apr-06 2:29
memberrorobebe2-Apr-06 2:29 
GeneralRe: difuculty installing aplication Pin
Alessandro Febretti2-Apr-06 23:29
memberAlessandro Febretti2-Apr-06 23:29 
GeneralUndo Option Pin
Maxim Discord23-Mar-06 5:25
memberMaxim Discord23-Mar-06 5:25 
GeneralRe: Undo Option Pin
Febret23-Mar-06 6:01
memberFebret23-Mar-06 6:01 
GeneralRe: Undo Option Pin
lolocmwa3-Apr-06 3:33
memberlolocmwa3-Apr-06 3:33 
JokeSweet! Suggestion - junction links Pin
Dan F23-Mar-06 0:26
memberDan F23-Mar-06 0:26 
GeneralRe: Sweet! Suggestion - junction links Pin
Febret23-Mar-06 6:00
memberFebret23-Mar-06 6:00 
GeneralLisense Pin
tayspen30-Nov-05 9:33
membertayspen30-Nov-05 9:33 
GeneralRe: Lisense Pin
Alessandro Febretti1-Dec-05 3:28
memberAlessandro Febretti1-Dec-05 3:28 
GeneralRe: Lisense Pin
tayspen3-Dec-05 11:31
membertayspen3-Dec-05 11:31 
GeneralLooks great! Pin
kryzchek1-Nov-05 6:32
memberkryzchek1-Nov-05 6:32 
GeneralRe: Looks great! Pin
Febret1-Nov-05 7:02
memberFebret1-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 | Terms of Use | Mobile
Web04 | 2.8.150819.1 | Last Updated 23 Mar 2006
Article Copyright 2005 by Febret
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid