public string ExtractAlbum(string birth, FileInfo file)
{
if (information[1] != null) //AlbumFormat may be called first which may grab the album name
return information[1];
switch (birth)
{
case "waffles":
{
/*Look for a space on either side of the dash*/
int startingPosition = 0;
int dashes = file.Name.Split('-').Length;
for (int a = 0; a <= dashes; a++)
{
int dash = file.Name.IndexOf('-', startingPosition);
if (file.Name[dash - 1].Equals(' ') && file.Name[dash + 1].Equals(' '))
{
return file.Name.Substring(dash + 2, (file.Name.IndexOf('[') - (dash + 2))); //return the album
}
startingPosition = dash + 1;
}
/*If that fails...*/
return IssueError("Can't parse album", file);
}
case "what":
{
try
{
/*Look for a space on either side of the dash*/
int startingPosition = 0;
int dashes = file.Name.Split('-').Length;
for (int a = 0; a <= dashes; a++)
{
int dash = file.Name.IndexOf('-', startingPosition);
if (file.Name[dash - 1].Equals(' ') && file.Name[dash + 1].Equals(' '))
{
try
{
return file.Name.Substring(dash + 2, ((file.Name.IndexOf('-', dash + 1)) - (dash + 2))); //return the album
}
catch (Exception e)
{
information[14] = "true";
ew.IssueGeneralWarning("File error while extracting album name", "Please report", e.Message + "\n" + e.StackTrace);
return null;
}
}
startingPosition = dash + 1;
}
/*If that fails...*/
return IssueError("Can't parse album", file);
}
catch (Exception e)
{
ew.IssueGeneralWarning("Error extracting album", "Please report", e.Message + "\n" + e.StackTrace);
return IssueError("Can't parse album", file);
}
}
default:
return IssueError("Can't parse album", file);
}
}