mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-27 04:21:27 +02:00
Added: Setting for Colon Replacement Format (#2711)
Fixes #2140 Fixes #2657
This commit is contained in:
@@ -248,8 +248,9 @@ namespace NzbDrone.Core.Organizer
|
||||
{
|
||||
AddMovieFileTokens(tokenHandlers, new MovieFile { SceneName = $"{movie.Title} {movie.Year}", RelativePath = $"{movie.Title} {movie.Year}"});
|
||||
}
|
||||
|
||||
return CleanFolderName(ReplaceTokens(namingConfig.MovieFolderFormat, tokenHandlers, namingConfig));
|
||||
|
||||
string name = ReplaceTokens(namingConfig.MovieFolderFormat, tokenHandlers, namingConfig);
|
||||
return CleanFolderName(name, namingConfig);
|
||||
}
|
||||
|
||||
public static string CleanTitle(string title)
|
||||
@@ -283,11 +284,14 @@ namespace NzbDrone.Core.Organizer
|
||||
return title.Trim();
|
||||
}
|
||||
|
||||
public static string CleanFileName(string name, bool replace = true)
|
||||
public static string CleanFileName(string name, NamingConfig namingConfig)
|
||||
{
|
||||
bool replace = namingConfig.ReplaceIllegalCharacters;
|
||||
var colonReplacementFormat = namingConfig.ColonReplacementFormat.GetFormatString();
|
||||
|
||||
string result = name;
|
||||
string[] badCharacters = { "\\", "/", "<", ">", "?", "*", ":", "|", "\"" };
|
||||
string[] goodCharacters = { "+", "+", "", "", "!", "-", "", "", "" };
|
||||
string[] goodCharacters = { "+", "+", "", "", "!", "-", colonReplacementFormat, "", "" };
|
||||
|
||||
for (int i = 0; i < badCharacters.Length; i++)
|
||||
{
|
||||
@@ -297,12 +301,12 @@ namespace NzbDrone.Core.Organizer
|
||||
return result.Trim();
|
||||
}
|
||||
|
||||
public static string CleanFolderName(string name)
|
||||
public static string CleanFolderName(string name, NamingConfig namingConfig)
|
||||
{
|
||||
name = FileNameCleanupRegex.Replace(name, match => match.Captures[0].Value[0].ToString());
|
||||
name = name.Trim(' ', '.');
|
||||
|
||||
return CleanFileName(name);
|
||||
return CleanFileName(name, namingConfig);
|
||||
}
|
||||
|
||||
private void AddMovieTokens(Dictionary<string, Func<TokenMatch, string>> tokenHandlers, Movie movie)
|
||||
@@ -557,7 +561,7 @@ namespace NzbDrone.Core.Organizer
|
||||
replacementText = replacementText.Replace(" ", tokenMatch.Separator);
|
||||
}
|
||||
|
||||
replacementText = CleanFileName(replacementText, namingConfig.ReplaceIllegalCharacters);
|
||||
replacementText = CleanFileName(replacementText, namingConfig);
|
||||
|
||||
if (!replacementText.IsNullOrWhiteSpace())
|
||||
{
|
||||
|
Reference in New Issue
Block a user