Fix offline scrobbling for servers without lucene support #4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Current implementation of offline scrobbling is to save all
required data to submit scrobble in local shared preferences file
and when back online, DSub sends them to server.
When in Offline mode, dsub uses pathes to local files as their identifies
as opposite to Online mode where server side identifies are utilized.
In order to send scrobble it is required to specify server side ID
in a query.
Thus, Dsub has to match identifies of what it has scrobbled while offline
(paths to files in file system) to server side identifies. To do so, it relies
on
Querying local database, which contains mapping local path to file <-> server side id.
It sounds good but we don't live in perfect world and there are couple flaws in this implementation:
a) Dsub's local database only contains information for songs that have been played in online
mode at least once.
b) It just doesn't work since in scrobble OfflineMusicService.scrobble method id of a song comes with ".complete"
postfix and in database it's saved without this ".complete" postfix so it fails to lookup server side id.
Querying the server with lucene syntax search clause. Subsonic api doesn't say anything about lucene
search syntax support and not all servers have support for it (i.e. see this issue for navidrome
DSub Offline plays fail to scrobble when returning online. navidrome/navidrome#1466). Besides, it isn't precise in case you have multiple
songs with same artist and title (i.e. multiple editions of an album).
This commit and according PR focus on fixing problems with looking up local path to file <-> server side id.
It is achieved with removing ".complete" substring from all identifies which
comes to OfflineMusicSerivce.scrobble. And by adding all cached songs to local db on download stage
so when DSub switches to offline mode it always has server side identifies for all media files it has
locally.