Some refactoring

This commit is contained in:
h3llrais3r 2023-03-03 22:42:13 +01:00
parent 470e1e1819
commit c1b9779786

View File

@ -559,26 +559,22 @@ public static class Extensions
/// <returns><see cref="bool"/> indicating if the <see cref="Episode"/> matches a <see cref="TraktEpisodeWatchedHistory"/>.</returns>
public static bool IsMatch(Episode item, TraktEpisodeWatchedHistory episodeHistory)
{
// Match by provider id's
if (IsMatch(item, episodeHistory.Episode))
// Match by provider id's if available, Match by show, season and episode number if not
if (HasAnyProviderTvIds(item))
{
return true;
return IsMatch(item, episodeHistory.Episode);
}
else
{
return IsMatch(item.Series, episodeHistory.Show) && item.GetSeasonNumber() == episodeHistory.Episode.Season && item.ContainsEpisodeNumber(episodeHistory.Episode.Number);
}
}
// Match by show, season and episode number if no provider id's are available
if (!HasAnyProviderTvIds(item) && IsMatch(item.Series, episodeHistory.Show) && item.GetSeasonNumber() == episodeHistory.Episode.Season && item.ContainsEpisodeNumber(episodeHistory.Episode.Number))
private static bool HasAnyProviderTvIds(Episode item)
{
return true;
}
return false;
}
private static bool HasAnyProviderTvIds(BaseItem item)
{
return item.HasProviderId(MetadataProvider.Imdb)
return item.HasProviderId(MetadataProvider.Tvdb)
|| item.HasProviderId(MetadataProvider.Tmdb)
|| item.HasProviderId(MetadataProvider.Tvdb)
|| item.HasProviderId(MetadataProvider.Imdb)
|| item.HasProviderId(MetadataProvider.TvRage);
}
}