Shuttle2
Shuttle2 copied to clipboard
Ability to export playlists
💬 User story
I am a user who edits playlists.
I'd like to export these modified playlists
📝 Notes
- Importing playlists is only supported with S2 Media Provider, not with Android Media Store.
👩🔧 Technical Design Notes
Exporting as m3u file format sounds sensible
The following playlists should be considered:
- Local playlists, originally imported by the S2 Media Provider (no playlists are (currently) imported from Android Media Store) Instead of adding a new button/menu (and a dialog to choose where the playlist files should be exported), we may want to overwrite the original m3u file as soon as the playlists is changed. Does this require new Android permissions from the user? Is it fine to consider no other app will be competing for these files, and that it is safe to overwrite them without checking no one else has modified it? Or should we rather not do anything with the original file, and only accept writing new files somewhere else?
- Remote playlists (Plex, Emby, Jellyfin) Is there an API to edit these remote playlists on the server? Maybe these APIs should be called as soon as the playlists are modified, so that they are always in sync with the server. What about the case where an error happens when trying to update the remote playlists (error or no connection available)? Should we store them and try again later?
- Playlists the user has created himself Where should we store them? Is there a sensible place we could do this, so that the export is done automatically as soon as the user creates/modifies these playlists? Or should it be on-demand, with a dialog asking where to export it? Not sure there is one sensible location, because I already can think of two of them: in /Music on the device, and in /Music in the SD card (if any)
🤝 Relationships
- In case it is fine to automatically overwrite local files, this will (probably) be helpful for #107 and I could make a PR myself (at least for the "local playlists imported by S2 Media Provider" part)
- The Jellyfin part already has its own issue #102
We could also start by providing an Export to file...
(+ an associated "choose folder" dialog) in the overflow menu of every playlist (local or remote, created or already existing).
Then, adding specific logic for local playlists imported by S2 Media Provider would be easy, we'll just have to call the new playlist.export(file_path)
function, with the original file path
Well, this is more complicated at it seemed at first sight.
M3U files contain either absolute paths, absolute web URLs, or relative paths.
The S2 Media Provider uses neither of them, as it uses content://
URIs, and there is no API to convert it to actual paths, let alone to relativize them to the folder the M3U is stored into.
Also, we'll need to create and OutputStream
to write the M3U file:
- When we create them by
content://
URI, theContentResolver
API does not accept creating new files, but only already existing ones. So, overwriting already existing M3U files would be kind-of easy (even though relativizing the file paths for the songs would be hacky -- note that importing M3U is hacky as well: it does not use proper path handling and comparison, but merely checks for "is the relative path included in any of the songs in the library"). - I have no idea if/how the Android sandbox allows to create them by path (there may be an API, but will this require the user granting extra Android permissions?). Thus, I'm not sure I'll be able to do the "write new files at a user-specified location" part.