//
// Lyrics.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;
using ZenLibrary.RuleBase;
namespace ZenLibrary.Rules
{
///
/// This rule tests for the presence of lyrics in
/// each file that it scans.
///
class Lyrics : Rule
{
public override string Name
{
get { return "Contains Lyrics"; }
}
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(!string.IsNullOrEmpty(file.Tag.Lyrics))
{
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 file \"{0}\" does not contain lyrics.", result.ResultPath);
return result;
}
}
}
}