Turns out Jellyfin uses a really esoteric form of Musicbrainz ID for
tracks. Instead of using the recording ID, it uses the specific hash for
a given version of a recording. A noble effrot to be specific, but we'd
much rather use Mopidy's recording ID when it's available.
Thus, we'll use Jellyfin's ID if that's all we have, but if we scrobble
the same track from Mopidy, overwrite the value.
Unlike Jellyfin, Mopidy's webhook only gives us a start and stopped call
to determine when a track should be scrobbled. This means we don't have
continous updating of playback ticks.
This commit adds a fallback when ticks are not there to use the track
duration and time since the scrobble was created. That said, this is not
perfect. If you pause the track and start again, the progress will get
very out of whack. But thankfully, Mopidy only sends us audio, and it's
rare that audio tracks are paused repeatedly and started again before
finishing a scrobble. So hopefully this shouldn't happen very often.
If you send Track data from the Jellyfin Webhook plugin, we'll do the
right thing with it. Lots more to do to clean this up, but it also
involved moduralizing the code for scrobbling so it's a little simpler
to understand what's going on.
Biggest thing here is adding the ability to scrobble until the video is
95% done and then not scrobble the same video file again for 15 minutes.
This seems hacky, but in practice works pretty well, so long as you
don't monkey around with the 95% completion thing. Unlike music, videos
are generally watched all the way through.