-
Notifications
You must be signed in to change notification settings - Fork 133
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
✨ Store listens when offline or if submission failed #521
Conversation
649ff10
to
9771317
Compare
Useful if you want to manually export them to ListenBrainz or similar later on.
9771317
to
6f7fa99
Compare
This is awesome! 😁 Could we write it to a Hive/Isar database instead and then export to file or share-sheet on-demand? 🤔 |
Also, while there is a timestamp, there is neither a duration, nor an end timestamp, nor an event type (playback started/stopped). So I'm not sure if this would be sufficient to use as playback history data? |
That would definitely be the more elaborate solution. I didn't want to bother with writing UI and database and export logic, but I suppose it would be sensible in the future.
For my use case, even just the id/mbid and timestamp would be enough. With those, I'd map the data to a ListenBrainz listen history (maybe with the help of the ListenBrainz server plugin) and submit it. |
ooo nice, this could be the start of actual playback reporting :) Saving to a file directly is a bit finnicky, if we just want to export JSON we should "share" the file, similar to how exporting logs works |
Yeah, that'd be the best solution. I think for now, we could keep the PR as is, and I can look into a Hive db later on. |
6f7fa99
to
10f871c
Compare
I guess we can get this merged. One thing I would like to have clarified, is the |
I'll just do that when adding the user ID 😄 |
10f871c
to
1071e87
Compare
Done, added the user ID, added a comment to the functions and renamed the item ID to clearly separate it from the user ID. Also tested this locally and confirmed everything still works. |
By the way, feel free to squash this PR when merging. I think it can be considered a single path. |
Went ahead and also made the code store listens in a Hive box. That should make adding a UI later on much easier. |
Awesome, thanks for putting in the effort! I'll merge it later. Any idea how many bytes per offline listen are added to the file? I'm wondering if it's necessary to clear the file at some point, put it's probably less than 1 kB per entry, so that shouldn't become a problem unless someone listens for hundreds of thousands of songs. |
It depends on the length of the track titles and such, but in my checks it was 200-300 bytes per listen. So, you'd need 5k listens to reach just one Megabyte..
And yes, once the export logic is in place, we can simply delete the file. |
Awesome. Yeah we could truncate listens older than ~1.5 years on startup, or do we need to do it sooner? I don't have much experience with Hive yet... If someone listens only in offline mode, I'd like to still have at least a year of playback data available for things like Jellyfin Rewind, at least until we can retroactively push listens to the Jellyfin server. |
1.5 years sounds good to me. I listen to a lot of music and will reach 10k listens for the first time this year, and even people listening to 10x that should be fine with the <50 MB used. |
Right. Currently sitting at 56k listens for this year (plus max. 5k offline), and the most I ever had on Spotify was 95k. So I doubt anyone will surpass 150k in a year, which would be around 75 MB. The comparion with the FLAC files probably doesn't really apply since the files are not app data and only loaded on-demand. But from a storage space used-perspective you're absolutely right. |
I admit my focus was on storage space earlier, so I didn't think about how Hive would handle that data. I expected it to only load contents it needs and on demand, but it looks like this isn't the case. According to this hive ticket, we should probably look into SQLite instead.. |
We could just migrate to Isar for that, we should do that at some point anyway :D |
Finally merged, thanks again for the PR! Edit: Forgot to squash, damn it 🙃 |
I was looking at drift earlier, but Isar also looks really nice!
Thank you so much! Happy to have this feature merged now.
lol rip. It's fine, but I suppose you could disable merge commits and only allow rebase or squash merges in the future to keep the repo cleaner. |
Useful if you want to manually export them to ListenBrainz or similar later on.
The biggest problem is that the exported file is not easily viewable at the moment. On newer Android versions, you can only view the files when attached to a computer (or with root permissions). On iOS, it's not possible at all.
However, we can probably build some export feature later on.