Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use LastUpdated Time Instead of Current Time for missing Stop event #87

Merged
merged 1 commit into from
Jul 17, 2024

Conversation

speatzle
Copy link

@speatzle speatzle commented Jun 8, 2024

Potentially Fixes #69 and #81.

As far as i can tell, the above issues happen due to misbehaving Clients and or a Bad Connection to The Server, Resulting in very long and Unrealistic Play times being Recorded:
image

The PlayBack Tracker is identified using the user id, device id and item id combined. Sometimes for whatever reason it seems that the SessionManager_PlaybackStop function does not get called when playback stops and the playback tracker does not get removed and no Stop event is added to the PlayBack Trackers log.

If the Server is then not restarted and the User starts a new playback of the same item on the same device some time later, the generated PlayBack Tracker identifier is the same and we run into this condition https://github.com/jellyfin/jellyfin-plugin-playbackreporting/blob/8bb1d7a2108400631390ee71f631112b5a1899eb/Jellyfin.Plugin.PlaybackReporting/EventMonitorEntryPoint.cs#L149C18-L149C19 (Can be spotted in the logs if triggered with the Message "Existing tracker found!") This triggers a cleanup of the existing Playback Tracker before starting a new one for the new Playback. The Cleanup Calls the track.CalculateDuration function to Calculate the Final duration of the Play. This function checks if the Last Event in its log is a Stop Event (which it isn't since SessionManager_PlaybackStop was never called which would normally generate this event) and appends one with the current time as the end time if it is missing.

This PR Changes the Time Used for the Generated Stop Event to be the LastUpdated Time which gets set every time SessionManager_PlaybackProgress gets called. This should be way more accurate than the current time.

@crobibero crobibero added the bug This PR or Issue describes or fixes something that isn't working label Jun 10, 2024
@crobibero crobibero merged commit d837dd2 into jellyfin:master Jul 17, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This PR or Issue describes or fixes something that isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Playtime is off the charts, literally. More than 24h in one day per user
2 participants