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

Fix offline scrobbling for servers without lucene support #4

Merged
merged 2 commits into from
Apr 11, 2024

Conversation

norohind
Copy link

@norohind norohind commented Apr 6, 2024

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

  1. 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.

  2. 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.

norohind added 2 commits April 6, 2024 17:33
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
1. 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.

2. 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
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.
@paroj paroj merged commit c36328c into paroj:edge Apr 11, 2024
@norohind norohind deleted the fix-3-offline-scrobbling branch April 11, 2024 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants