Merge pull request #124 from Shadowghost/fixup

This commit is contained in:
Cody Robibero 2022-04-24 13:27:22 -06:00 committed by GitHub
commit a56fff07c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 24 deletions

View File

@ -180,7 +180,7 @@ public static class Extensions
/// <param name="dateTime">The <see cref="DateTime"/>.</param>
/// <returns>string.</returns>
public static string ToISO8601(this DateTime dateTime)
=> dateTime.ToUniversalTime().ToString("yyyy-MM-dd'T'HH:mm:ss.fffffff'Z'", CultureInfo.InvariantCulture);
=> dateTime.ToUniversalTime().ToString("o", CultureInfo.InvariantCulture);
/// <summary>
/// Gets the season number of an <see cref="Episode"/>.
@ -405,23 +405,4 @@ public static class Extensions
return false;
}
/// <summary>
/// Checks if a <see cref="Episode"/> matches a <see cref="TraktEpisodeWatched"/>.
/// </summary>
/// <param name="item">The <see cref="Episode"/>.</param>
/// <param name="episode">The <see cref="TraktEpisodeWatched"/>.</param>
/// <returns><see cref="bool"/> indicating if the <see cref="Episode"/> matches a <see cref="TraktEpisodeWatched"/>.</returns>
public static bool IsMatch(Episode item, TraktEpisodeWatched episode)
{
var episodeNumber = episode.Number;
var itemIndexNumber = item.IndexNumber;
var itemIndexNumberEnd = item.IndexNumberEnd;
return !itemIndexNumber.HasValue
? episodeNumber == -1
: (itemIndexNumberEnd.HasValue && itemIndexNumberEnd > itemIndexNumber
? itemIndexNumber <= episodeNumber && episodeNumber <= itemIndexNumberEnd
: episodeNumber == itemIndexNumber);
}
}

View File

@ -334,7 +334,7 @@ public class SyncFromTraktTask : IScheduledTask
if (matchedWatchedSeason != null)
{
// Check for matching episodes including multi-episode entities
var matchedWatchedEpisode = matchedWatchedSeason.Episodes.FirstOrDefault(x => Extensions.IsMatch(episode, x));
var matchedWatchedEpisode = matchedWatchedSeason.Episodes.FirstOrDefault(x => episode.ContainsEpisodeNumber(x.Number));
// Prepend a check if the matched episode is on a rewatch cycle and
// discard it if the last play date was before the reset date

View File

@ -463,9 +463,9 @@ public class SyncLibraryTask : IScheduledTask
{
isPlayedTraktTv = traktWatchedShow.Seasons.Any(
season => season.Number == episode.GetSeasonNumber()
&& season.Episodes != null
&& season.Episodes.Any(e => Extensions.IsMatch(episode, e)
&& e.Plays > 0));
&& season.Episodes != null
&& season.Episodes.Any(e => episode.ContainsEpisodeNumber(e.Number)
&& e.Plays > 0));
}
// If the show has been played locally and is unplayed on trakt.tv then add it to the list