Conversation
Parsing of the Spotify configuration for local files and the JSON returned by the web API
| } | ||
|
|
||
| pub fn get_username(&self) -> Option<String> { | ||
| match &self.credentials { |
There was a problem hiding this comment.
map would be better here I think?
| .init(); | ||
|
|
||
| let config = Config::load().unwrap_or_default(); | ||
| let username = config.get_username(); |
There was a problem hiding this comment.
This won't really work the first time user launches the app. Can we maybe inject the username (or the LocalTrackManager) into WebApi a bit later?
| local: match username { | ||
| Some(u) => LocalTrackManager::new(u), | ||
| _ => None | ||
| } |
There was a problem hiding this comment.
Again map I personally find preferable here, but maybe we should re-think how the manager is initialized, see above.
| // https://developer.spotify.com/documentation/web-api/reference/#endpoint-get-playlist | ||
| pub fn get_playlist(&self, id: &str) -> Result<Playlist, Error> { | ||
| let request = self.get(format!("v1/playlists/{}", id))?; | ||
| let request = self.get(format!("v1/me/playlists/{}", id))?; |
There was a problem hiding this comment.
Is the endpoint really incorrect?
| * If the varint size is 0 this is a null string | ||
| * | ||
| * The end of a trailer for a given track is signified by 0x78, 0x04 from what I can tell | ||
| */ |
| Ok(s) => Ok(s.to_string()), | ||
| // TODO: This can definitely be done better | ||
| Err(_) => Err(io::Error::from(io::ErrorKind::Other)) | ||
| } |
There was a problem hiding this comment.
Maybe using String::from_utf8 directly, with map_err, would be better?
| let file_path = match Config::spotify_local_files(username) { | ||
| Some(p) => p, | ||
| _ => return None | ||
| }; |
| pub explicit: bool, | ||
| pub is_local: bool, | ||
| #[serde(skip_deserializing)] | ||
| pub local_path: Option<Arc<String>>, |
Small changes to follow more Rustisms and fixed a bug where the username will not be known on the first run
|
I committed most of the changes you suggested. The problem I was running into was injecting the username into the |
|
Hi @sleepychaser, I've made some more changes (mostly some style nits, functionality should be identical I think). It works on macOS. The playback is next! |
|
Re. multiple codecs support: this is definitely needed (not even all Spotify tracks are in Vorbis). Options:
It's sad the the rust audio output is in such a bad state (rodio can not even keep the buffers full in debug mode, cpal has >100 issues open and maintainers don't seem to care, etc.), so it seems like we're stuck with a C library for this. |
|
Merged to master, sorry about the delay :) Playback is still not supported, but now that we have Symphonia, it wouldn't be that hard to do. |
|
Will playback ever be supported? |
|
Hi @Kyiro, I've opened an issue for this. No ETA, though :( |
Parsing of the Spotify configuration for local files and the JSON returned by the web API.
Changes
Local files imported by Spotify is stored in a custom binary format at
<SpotifyConfigDir>/Users/<username>-user/local-files.bnk. When playlist tracks are attempted to be loaded instead of discarding any local tracks attempt to find a local track in thelocal-files.bnkand if a matching title, artist, album, etc. are found then return a properly formatted Track structureTODO: