Add title without umlauts as base variation
This commit is contained in:
@@ -103,7 +103,9 @@ namespace UmlautAdaptarr.Models
|
|||||||
TitleSearchVariations = GenerateVariations($"{expectedAuthor} {expectedTitle}", mediaType).ToArray();
|
TitleSearchVariations = GenerateVariations($"{expectedAuthor} {expectedTitle}", mediaType).ToArray();
|
||||||
AuthorMatchVariations = GenerateVariations(expectedAuthor, mediaType).ToArray();
|
AuthorMatchVariations = GenerateVariations(expectedAuthor, mediaType).ToArray();
|
||||||
|
|
||||||
if (mediaType == "book" && (expectedAuthor?.Contains(' ') ?? false))
|
if (mediaType == "book")
|
||||||
|
{
|
||||||
|
if (expectedAuthor?.Contains(' ') ?? false)
|
||||||
{
|
{
|
||||||
var nameParts = expectedAuthor.Split(' ', StringSplitOptions.RemoveEmptyEntries);
|
var nameParts = expectedAuthor.Split(' ', StringSplitOptions.RemoveEmptyEntries);
|
||||||
var lastName = nameParts.Last();
|
var lastName = nameParts.Last();
|
||||||
@@ -113,6 +115,7 @@ namespace UmlautAdaptarr.Models
|
|||||||
AuthorMatchVariations = [.. AuthorMatchVariations, .. GenerateVariations(alternativeExpectedAuthor, mediaType)];
|
AuthorMatchVariations = [.. AuthorMatchVariations, .. GenerateVariations(alternativeExpectedAuthor, mediaType)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private IEnumerable<string> GenerateVariations(string? title, string mediaType)
|
private IEnumerable<string> GenerateVariations(string? title, string mediaType)
|
||||||
{
|
{
|
||||||
@@ -135,6 +138,11 @@ namespace UmlautAdaptarr.Models
|
|||||||
cleanTitle.RemoveGermanUmlautDots()
|
cleanTitle.RemoveGermanUmlautDots()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (mediaType == "book" || mediaType == "audio")
|
||||||
|
{
|
||||||
|
baseVariations.Add(cleanTitle.RemoveGermanUmlauts());
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: determine if this is really needed
|
// TODO: determine if this is really needed
|
||||||
// Additional variations to accommodate titles with "-"
|
// Additional variations to accommodate titles with "-"
|
||||||
if (cleanTitle.Contains('-'))
|
if (cleanTitle.Contains('-'))
|
||||||
|
|||||||
@@ -132,6 +132,18 @@ namespace UmlautAdaptarr.Utilities
|
|||||||
.Replace("ß", "ss");
|
.Replace("ß", "ss");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string RemoveGermanUmlauts(this string text)
|
||||||
|
{
|
||||||
|
return text
|
||||||
|
.Replace("ö", "")
|
||||||
|
.Replace("ü", "")
|
||||||
|
.Replace("ä", "")
|
||||||
|
.Replace("Ö", "")
|
||||||
|
.Replace("Ü", "")
|
||||||
|
.Replace("Ä", "")
|
||||||
|
.Replace("ß", "");
|
||||||
|
}
|
||||||
|
|
||||||
public static string RemoveExtraWhitespaces(this string text)
|
public static string RemoveExtraWhitespaces(this string text)
|
||||||
{
|
{
|
||||||
return MultipleWhitespaceRegex().Replace(text, " ");
|
return MultipleWhitespaceRegex().Replace(text, " ");
|
||||||
|
|||||||
Reference in New Issue
Block a user