Skip to content

Commit

Permalink
Merge pull request #11 from bonukai/patch
Browse files Browse the repository at this point in the history
Patch
  • Loading branch information
bonukai authored Aug 7, 2024
2 parents d205207 + ccc0c0d commit 6b26662
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
2 changes: 0 additions & 2 deletions Jellyfin.Plugin.MediaTracker/ServerEntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,6 @@ private async void OnPlaybackChanged(PlaybackProgressEventArgs e, string action)
var progress = (float)positionTicks / runTimeTicks;
var durationInMilliseconds = (runTimeTicks / TimeSpan.TicksPerSecond) * 1000;

progressDictionary.Cleanup();

if (e.Item is Episode)
{
if (e.Item is not Episode episode)
Expand Down
15 changes: 5 additions & 10 deletions Jellyfin.Plugin.MediaTracker/src/PreviousActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,6 @@ public PreviousActions()
markedAsSeenHistory = [];
}

public void Cleanup()
{
progressDictionary = progressDictionary.Where(item => item.Value.IsWithinTimeLimit()).ToDictionary(p => p.Key, p => p.Value);

markedAsSeenHistory = markedAsSeenHistory.Where(item => DateTime.Now.Subtract(item.Value).TotalHours < 12).ToDictionary(p => p.Key, p => p.Value);
}

public bool ShouldSkipAction(User user, Video video, float progress, string action)
{
var id = Tuple.Create(user.Id, video.Id);
Expand All @@ -88,12 +81,14 @@ public bool CanMarkAsSeen(User user, Video video)
{
var id = Tuple.Create(user.Id, video.Id);

if (markedAsSeenHistory.ContainsKey(id))
if (markedAsSeenHistory.TryGetValue(id, out DateTime value))
{
return false;
markedAsSeenHistory[id] = DateTime.Now;

return (DateTime.Now.Subtract(value).TotalHours >= 12);
}

markedAsSeenHistory.Add(id, DateTime.Now);
markedAsSeenHistory[id] = DateTime.Now;

return true;
}
Expand Down
2 changes: 1 addition & 1 deletion build.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
name: "MediaTracker"
guid: "c4772eae-799e-490d-abff-4de21f99c95e"
version: "2.0.0.1"
version: "2.0.0.2"
targetAbi: "10.9.1.0"
framework: "net8.0"
overview: "MediaTracker scrobbler"
Expand Down

0 comments on commit 6b26662

Please sign in to comment.