CleanFileName when getting new filename from MediaFileProvider.

pull/4/head
Mark McDowall 14 years ago
parent 244e0f04f4
commit 208feb7d19

@ -349,5 +349,15 @@ namespace NzbDrone.Core.Test
}
[Test]
[TestCase("Law & Order: Criminal Intent - S10E07 - Icarus [HDTV]", "Law & Order- Criminal Intent - S10E07 - Icarus [HDTV]")]
public void CleanFileName(string name, string expectedName)
{
//Act
var result = MediaFileProvider.CleanFilename(name);
//Assert
Assert.AreEqual(expectedName, result);
}
}
}

@ -55,17 +55,5 @@ namespace NzbDrone.Core.Helpers
return String.Format("{0} - S{1:00}E{2} - {3}", erm.SeriesName, erm.EpisodeFile.Episodes[0].SeasonNumber,
epNumberString, epNameString);
}
public static string CleanFilename(string name)
{
string result = name;
string[] badCharacters = {"\\", "/", "<", ">", "?", "*", ":", "|", "\""};
string[] goodCharacters = {"+", "+", "{", "}", "!", "@", "-", "#", "`"};
for (int i = 0; i < badCharacters.Length; i++)
result = result.Replace(badCharacters[i], goodCharacters[i]);
return result.Trim();
}
}
}

@ -129,6 +129,18 @@ namespace NzbDrone.Core.Providers
result = result.Replace(' ', '.');
Logger.Debug("New File Name is: {0}", result.Trim());
return CleanFilename(result.Trim());
}
public static string CleanFilename(string name)
{
string result = name;
string[] badCharacters = { "\\", "/", "<", ">", "?", "*", ":", "|", "\"" };
string[] goodCharacters = { "+", "+", "{", "}", "!", "@", "-", "#", "`" };
for (int i = 0; i < badCharacters.Length; i++)
result = result.Replace(badCharacters[i], goodCharacters[i]);
return result.Trim();
}
}

@ -129,7 +129,7 @@ namespace NzbDrone.Web.Controllers
var path =
rootPath.Replace('|', Path.DirectorySeparatorChar).Replace('^', Path.VolumeSeparatorChar).Replace(
'`', '\'') +
Path.DirectorySeparatorChar + EpisodeRenameHelper.CleanFilename(seriesName);
Path.DirectorySeparatorChar + MediaFileProvider.CleanFilename(seriesName);
//Create the folder for the new series and then Add it
_diskProvider.CreateDirectory(path);

Loading…
Cancel
Save