Permalink
Browse files

Improvements to "Unrecognized" Utility

* shows AniDB's AnimeID next to each Series listed in the ListBox
* Allows to search for AniDB's AnimeID
  • Loading branch information...
Baine committed Sep 27, 2018
1 parent 31b7a4f commit 939e0447d03394c460a1e62ca2c82fd8bfb26c37
@@ -30,7 +30,7 @@
<!-- SimpleAnimeSeriesTemplate -->
<DataTemplate x:Key="SimpleAnimeSeriesTemplate">
<TextBlock Text="{Binding Path=SeriesName}" Margin="3" />
<TextBlock Text="{Binding Path=SeriesName_with_aID}" Margin="3" />
</DataTemplate>
<!-- SimpleAnimeEpisodeTemplate -->
@@ -11,6 +11,7 @@ namespace Shoko.Desktop.ViewModel.Helpers
{
public class GroupSearchFilterHelper
{
public static bool EvaluateGroupTextSearch(VM_AnimeGroup_User grp, string filterText)
{
if (string.IsNullOrEmpty(filterText)) return true;
@@ -36,12 +37,24 @@ public static bool EvaluateGroupTextSearch(VM_AnimeGroup_User grp, string filter
return false;
}
/// <summary>
/// checks if a given string is actually just a number. optimized version provided by cazzar
/// </summary>
/// <param name="str">potential number to check</param>
/// <returns></returns>
private static bool IsDigitsOnly(string s) => long.TryParse(s, out long _);
public static bool EvaluateSeriesTextSearch(VM_AnimeSeries_User series, string filterText, SeriesSearchType searchType = SeriesSearchType.Everything)
{
if (string.IsNullOrEmpty(filterText)) return true;
if (series == null) return false;
if (IsDigitsOnly((filterText)))
{
return (Convert.ToInt32(filterText) == series.AniDBAnime.AniDBAnime.AnimeID);
}
if (!string.IsNullOrEmpty(series.SeriesNameOverride) && series.SeriesNameOverride.FuzzyMatches(filterText))
return true;
@@ -216,6 +216,27 @@ public string SeriesName
}
}
[ScriptIgnore, JsonIgnore, XmlIgnore]
public string SeriesName_with_aID
{
get
{
if (AniDBAnime != null)
{
if (!string.IsNullOrEmpty(SeriesNameOverride))
return SeriesNameOverride + " [" + AniDBAnime.AniDBAnime.AnimeID + "]";
if (VM_ShokoServer.Instance.SeriesNameSource == DataSourceType.AniDB)
return AniDBAnime.AniDBAnime.FormattedTitle + " [" + AniDBAnime.AniDBAnime.AnimeID + "]";
if (TvDB_Series != null && TvDB_Series.Count > 0 && !string.IsNullOrEmpty(TvDB_Series[0].SeriesName) &&
!TvDB_Series[0].SeriesName.ToUpper().Contains("**DUPLICATE"))
return TvDB_Series[0].SeriesName + " [" + AniDBAnime.AniDBAnime.AnimeID + "]";
return AniDBAnime.AniDBAnime.FormattedTitle + " [" + AniDBAnime.AniDBAnime.AnimeID + "]";
}
return "";
}
}
[ScriptIgnore, JsonIgnore, XmlIgnore]
public string SeriesNameTruncated
{

0 comments on commit 939e044

Please sign in to comment.