-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add title preprocessing for better searching
- Loading branch information
Showing
3 changed files
with
38 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Text.RegularExpressions; | ||
|
||
namespace Jellyfin.Plugin.Shikimori { | ||
public static class SearchHelper { | ||
// Taken from Anilist Jellyfin plugin | ||
public static String PreprocessTitle(String path) { | ||
String input = path; | ||
|
||
//Season designation | ||
input = Regex.Replace( | ||
input, | ||
@"(\s|\.)S[0-9]{1,2}", String.Empty); | ||
// ~ ALT NAME ~ | ||
input = Regex.Replace( | ||
input, | ||
@"\s*~(\w|[0-9]|\s)+~", String.Empty); | ||
|
||
// Native Name (English Name) | ||
// Only replaces if the name ends with a parenthesis to hopefully avoid mangling titles with parens (e.g. Evangelion 1.11 You Are (Not) Alone) | ||
input = Regex.Replace( | ||
input.Trim(), | ||
@"\((\w|[0-9]|\s)+\)$", String.Empty); | ||
|
||
// Replace & with "and" to avoid lookup failures | ||
input = Regex.Replace(input, @"\s?&\s?", " and "); | ||
|
||
// Replace the following characters with a space, to avoid failed lookups | ||
input = Regex.Replace(input, @"\#", " "); | ||
|
||
// Truncate suggested Jellyfin folder format for the shikimori search. Example: The Melancholy of Haruhi Suzumiya (2006) [tvdbid-79414] | ||
input = Regex.Replace(input.Trim(), @"\([0-9]{4}\)\s*\[(\w|[0-9]|-)+\]$", String.Empty); | ||
|
||
return input; | ||
} | ||
} | ||
} |