//
// BandTag.cs
//
// Author:
// Jacob Johnston (jacobj@inchoatethoughts.com)
//
// Copyright (C) 2009 Jacob Johnston
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
using System.IO;
namespace ZenLibrary.RuleBase
{
///
/// This rule is designed to make sure the AlbumArtist tag matches the
/// Artist tag. Some media players index bands by the "Artist" tag
/// while others use "AlbumArtist." The only time when these shouldn't
/// match is when the "AlbumArtist" tag has "Various Artists" as its
/// entry, indicating the album is a compilation.
///
class BandTag : Rule
{
public override string Name
{
get { return "Album Artist Tag Matches Artist Tag"; }
}
public override TestType TestType
{
get { return TestType.FileScan; }
}
public override RuleTestResult RunTest(DirectoryInfo directoryInfo, FileInfo fileInfo)
{
TagLib.File file = TagLib.File.Create(fileInfo.FullName);
if (file.Tag.AlbumArtists.Length > 0 && file.Tag.Performers.Length > 0 &&
(file.Tag.AlbumArtists[0].CompareTo(file.Tag.Performers[0]) == 0 || file.Tag.AlbumArtists[0].CompareTo("Various Artists") == 0))
{
RuleTestResult result = new RuleTestResult();
result.TestPassed = true;
return result;
}
else
{
RuleTestResult result = new RuleTestResult();
result.TestPassed = false;
result.ResultPath = fileInfo.FullName;
result.RuleTestFailedString = string.Format("The \"Album Artist\" tag does not match \"Artist\" tag in \"{0}\"", result.ResultPath);
return result;
}
}
}
}