Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
54ac94c168 | ||
|
|
5dbdc04cd4 | ||
|
|
391a554736 | ||
|
|
fa5f25e69b | ||
|
|
6dc8f0d9f2 | ||
|
|
d9594a5de5 |
No files matched your search
Generated
+16
-2
@@ -2992,7 +2992,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "musyx"
|
name = "musyx"
|
||||||
version = "0.3.0"
|
version = "0.4.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"block2 0.6.2",
|
"block2 0.6.2",
|
||||||
"directories",
|
"directories",
|
||||||
@@ -3010,6 +3010,7 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"souvlaki",
|
"souvlaki",
|
||||||
|
"subsonic-api",
|
||||||
"sys-locale",
|
"sys-locale",
|
||||||
"tokio",
|
"tokio",
|
||||||
"winresource",
|
"winresource",
|
||||||
@@ -5009,6 +5010,19 @@ dependencies = [
|
|||||||
"float-cmp",
|
"float-cmp",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "subsonic-api"
|
||||||
|
version = "0.4.0"
|
||||||
|
dependencies = [
|
||||||
|
"md-5",
|
||||||
|
"rand 0.9.5",
|
||||||
|
"reqwest",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
"thiserror 2.0.21",
|
||||||
|
"tokio",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "subtle"
|
name = "subtle"
|
||||||
version = "2.6.1"
|
version = "2.6.1"
|
||||||
@@ -6671,7 +6685,7 @@ checksum = "e01738255b5a16e78bbb83e7fbba0a1e7dd506905cfc53f4622d89015a03fbb5"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ym-api"
|
name = "ym-api"
|
||||||
version = "0.3.0"
|
version = "0.4.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"serde",
|
"serde",
|
||||||
|
|||||||
+2
-2
@@ -1,9 +1,9 @@
|
|||||||
[workspace]
|
[workspace]
|
||||||
resolver = "3"
|
resolver = "3"
|
||||||
members = ["crates/ym-api", "crates/musyx"]
|
members = ["crates/ym-api", "crates/subsonic-api", "crates/musyx"]
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
version = "0.3.0"
|
version = "0.4.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
publish = false
|
publish = false
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ publish.workspace = true
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
ym-api = { path = "../ym-api" }
|
ym-api = { path = "../ym-api" }
|
||||||
|
subsonic-api = { path = "../subsonic-api" }
|
||||||
iced = { version = "0.14.0", features = ["svg", "image", "tokio", "advanced", "qr_code", "lazy", "canvas"] }
|
iced = { version = "0.14.0", features = ["svg", "image", "tokio", "advanced", "qr_code", "lazy", "canvas"] }
|
||||||
keyring = "4.2.0"
|
keyring = "4.2.0"
|
||||||
rodio = { version = "0.23.0", default-features = false, features = ["playback", "mp3", "mp4", "flac"] }
|
rodio = { version = "0.23.0", default-features = false, features = ["playback", "mp3", "mp4", "flac"] }
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<!-- @license lucide-static v0.460.0 - ISC -->
|
||||||
|
<svg
|
||||||
|
class="lucide lucide-server"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="24"
|
||||||
|
height="24"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
stroke-width="2"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
>
|
||||||
|
<rect width="20" height="8" x="2" y="2" rx="2" ry="2" />
|
||||||
|
<rect width="20" height="8" x="2" y="14" rx="2" ry="2" />
|
||||||
|
<line x1="6" x2="6.01" y1="6" y2="6" />
|
||||||
|
<line x1="6" x2="6.01" y1="18" y2="18" />
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 491 B |
+182
-23
@@ -15,12 +15,13 @@ use ym_api::{
|
|||||||
PlaylistId, PlaylistSummary, Station, Track, WaveSettings, YmClient,
|
PlaylistId, PlaylistSummary, Station, Track, WaveSettings, YmClient,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::covers::Covers;
|
use crate::covers::{Covers, Fetcher};
|
||||||
use crate::player::{self, Audio, Effect, Player};
|
use crate::player::{self, Audio, Effect, Player};
|
||||||
use crate::route::{Navigator, Route};
|
use crate::route::{Navigator, Route};
|
||||||
use crate::screens::browse::{self, Discover, HomeData};
|
use crate::screens::browse::{self, Discover, HomeData};
|
||||||
use crate::screens::collection::{Library, Liked, Tab};
|
use crate::screens::collection::{Library, Liked, Tab};
|
||||||
use crate::screens::search::{self, Search};
|
use crate::screens::search::{self, Search};
|
||||||
|
use crate::screens::server::{self, ServerScreen};
|
||||||
use crate::screens::wave::WaveScreen;
|
use crate::screens::wave::WaveScreen;
|
||||||
use crate::screens::detail::{self, Page};
|
use crate::screens::detail::{self, Page};
|
||||||
use crate::screens::{self, Loadable, sign_in};
|
use crate::screens::{self, Loadable, sign_in};
|
||||||
@@ -63,6 +64,8 @@ pub struct App {
|
|||||||
discover: Discover,
|
discover: Discover,
|
||||||
genre_playlists: HashMap<usize, Loadable<Vec<PlaylistSummary>>>,
|
genre_playlists: HashMap<usize, Loadable<Vec<PlaylistSummary>>>,
|
||||||
wave: WaveScreen,
|
wave: WaveScreen,
|
||||||
|
/// The user's own music server: its connection, lists and pages.
|
||||||
|
server: ServerScreen,
|
||||||
/// Drives the My Wave hero animation.
|
/// Drives the My Wave hero animation.
|
||||||
wave_phase: f32,
|
wave_phase: f32,
|
||||||
covers: Covers,
|
covers: Covers,
|
||||||
@@ -106,6 +109,7 @@ pub enum Message {
|
|||||||
Navigate(Route),
|
Navigate(Route),
|
||||||
Back,
|
Back,
|
||||||
Search(search::Msg),
|
Search(search::Msg),
|
||||||
|
Server(server::Msg),
|
||||||
ToggleDrawer(Panel),
|
ToggleDrawer(Panel),
|
||||||
CloseDrawer,
|
CloseDrawer,
|
||||||
ShowNowPlaying(bool),
|
ShowNowPlaying(bool),
|
||||||
@@ -217,6 +221,7 @@ impl App {
|
|||||||
discover: Discover::default(),
|
discover: Discover::default(),
|
||||||
genre_playlists: HashMap::new(),
|
genre_playlists: HashMap::new(),
|
||||||
wave: WaveScreen::default(),
|
wave: WaveScreen::default(),
|
||||||
|
server: ServerScreen::default(),
|
||||||
wave_phase: 0.0,
|
wave_phase: 0.0,
|
||||||
covers: Covers::default(),
|
covers: Covers::default(),
|
||||||
likes: LikedIds::default(),
|
likes: LikedIds::default(),
|
||||||
@@ -259,6 +264,8 @@ impl App {
|
|||||||
return (app, Task::batch([appearance, restore(), config.capture()]));
|
return (app, Task::batch([appearance, restore(), config.capture()]));
|
||||||
}
|
}
|
||||||
app.session = config.session();
|
app.session = config.session();
|
||||||
|
// No keychain in snapshots: My server shows its connect form.
|
||||||
|
let _ = app.server.update(server::Msg::Restored(Ok(None)));
|
||||||
app.library.liked = Liked::loaded(config.sample_liked(), &Liked::NotLoaded);
|
app.library.liked = Liked::loaded(config.sample_liked(), &Liked::NotLoaded);
|
||||||
app.pages.insert(Route::Album(1), Loadable::Loaded(config.sample_album()));
|
app.pages.insert(Route::Album(1), Loadable::Loaded(config.sample_album()));
|
||||||
app.pages.insert(Route::Playlist(crate::snapshot::OWN_PLAYLIST), Loadable::Loaded(config.sample_playlist()));
|
app.pages.insert(Route::Playlist(crate::snapshot::OWN_PLAYLIST), Loadable::Loaded(config.sample_playlist()));
|
||||||
@@ -275,7 +282,7 @@ impl App {
|
|||||||
return (app, Task::batch([appearance, config.capture()]));
|
return (app, Task::batch([appearance, config.capture()]));
|
||||||
}
|
}
|
||||||
|
|
||||||
(app, Task::batch([appearance, restore()]))
|
(app, Task::batch([appearance, restore(), ServerScreen::restore()]))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn title(&self) -> String {
|
pub fn title(&self) -> String {
|
||||||
@@ -556,6 +563,19 @@ impl App {
|
|||||||
}
|
}
|
||||||
return task;
|
return task;
|
||||||
}
|
}
|
||||||
|
Message::Server(msg) => {
|
||||||
|
let connected = matches!(msg, server::Msg::Checked(_, Ok(())));
|
||||||
|
if connected || matches!(msg, server::Msg::Disconnect) {
|
||||||
|
// Another server can use the same cover ids for other pictures.
|
||||||
|
self.covers.forget_server();
|
||||||
|
}
|
||||||
|
let task = self.server.update(msg);
|
||||||
|
let route = self.nav.current();
|
||||||
|
if connected && route.is_server() {
|
||||||
|
return Task::batch([task, self.on_enter(route)]);
|
||||||
|
}
|
||||||
|
return task;
|
||||||
|
}
|
||||||
Message::ToggleDrawer(panel) => {
|
Message::ToggleDrawer(panel) => {
|
||||||
self.drawer = if self.drawer == Some(panel) { None } else { Some(panel) };
|
self.drawer = if self.drawer == Some(panel) { None } else { Some(panel) };
|
||||||
self.lyric_line = None;
|
self.lyric_line = None;
|
||||||
@@ -1001,8 +1021,13 @@ impl App {
|
|||||||
}
|
}
|
||||||
Message::WaveTick => self.wave_phase = (self.wave_phase + 0.04) % 10_000.0,
|
Message::WaveTick => self.wave_phase = (self.wave_phase + 0.04) % 10_000.0,
|
||||||
Message::CoverWanted(url) => {
|
Message::CoverWanted(url) => {
|
||||||
let Some(client) = self.client().cloned() else { return Task::none() };
|
let fetcher = if url.starts_with(ym_api::SUBSONIC_COVER_PREFIX) {
|
||||||
return self.covers.want(url, &client);
|
self.server.client().cloned().map(Fetcher::Server)
|
||||||
|
} else {
|
||||||
|
self.client().cloned().map(Fetcher::Yandex)
|
||||||
|
};
|
||||||
|
let Some(fetcher) = fetcher else { return Task::none() };
|
||||||
|
return self.covers.want(url, fetcher);
|
||||||
}
|
}
|
||||||
Message::CoverLoaded(url, bytes) => self.covers.loaded(url, bytes),
|
Message::CoverLoaded(url, bytes) => self.covers.loaded(url, bytes),
|
||||||
Message::CoversTick => self.covers.flush(),
|
Message::CoversTick => self.covers.flush(),
|
||||||
@@ -1022,7 +1047,8 @@ impl App {
|
|||||||
Shortcut::VolumeUp => to_player(player::Msg::SetVolume(self.player.volume + shortcuts::VOLUME_STEP)),
|
Shortcut::VolumeUp => to_player(player::Msg::SetVolume(self.player.volume + shortcuts::VOLUME_STEP)),
|
||||||
Shortcut::VolumeDown => to_player(player::Msg::SetVolume(self.player.volume - shortcuts::VOLUME_STEP)),
|
Shortcut::VolumeDown => to_player(player::Msg::SetVolume(self.player.volume - shortcuts::VOLUME_STEP)),
|
||||||
Shortcut::ToggleLike => {
|
Shortcut::ToggleLike => {
|
||||||
let Some(track) = self.player.track().cloned() else { return Task::none() };
|
// Only Yandex tracks have a heart.
|
||||||
|
let Some(track) = self.player.track().filter(|t| t.is_yandex()).cloned() else { return Task::none() };
|
||||||
let liked = self.library.liked.contains(&track.id);
|
let liked = self.library.liked.contains(&track.id);
|
||||||
Message::LikeTrack(track, !liked)
|
Message::LikeTrack(track, !liked)
|
||||||
}
|
}
|
||||||
@@ -1171,6 +1197,9 @@ impl App {
|
|||||||
// "Yours" comes from liked albums.
|
// "Yours" comes from liked albums.
|
||||||
Task::batch([featured, self.load_tab(Tab::Albums)])
|
Task::batch([featured, self.load_tab(Tab::Albums)])
|
||||||
}
|
}
|
||||||
|
Route::Server | Route::ServerAlbum(_) | Route::ServerArtist(_) | Route::ServerPlaylist(_) => {
|
||||||
|
self.server.enter(route)
|
||||||
|
}
|
||||||
Route::Album(_) | Route::Artist(_) | Route::Playlist(_) => {
|
Route::Album(_) | Route::Artist(_) | Route::Playlist(_) => {
|
||||||
if self.pages.get(&route).is_some_and(|p| !p.needs_load()) {
|
if self.pages.get(&route).is_some_and(|p| !p.needs_load()) {
|
||||||
return Task::none();
|
return Task::none();
|
||||||
@@ -1315,6 +1344,7 @@ impl App {
|
|||||||
wave: &self.wave,
|
wave: &self.wave,
|
||||||
wave_phase: self.wave_phase,
|
wave_phase: self.wave_phase,
|
||||||
settings: &self.settings,
|
settings: &self.settings,
|
||||||
|
server: &self.server,
|
||||||
}))
|
}))
|
||||||
.height(Fill)
|
.height(Fill)
|
||||||
.style(theme::scroll);
|
.style(theme::scroll);
|
||||||
@@ -1355,28 +1385,28 @@ impl App {
|
|||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Runs the player's requests against the API.
|
/// Runs the player's requests against the API: Yandex's, or the music
|
||||||
|
/// server's for tracks from there.
|
||||||
fn run(&self, effects: Vec<Effect>) -> Task<Message> {
|
fn run(&self, effects: Vec<Effect>) -> Task<Message> {
|
||||||
let Some(client) = self.client() else { return Task::none() };
|
let ym = self.client().cloned();
|
||||||
Task::batch(effects.into_iter().map(|effect| match effect {
|
let server = self.server.client().cloned();
|
||||||
Effect::Fetch { generation, track_id } => {
|
|
||||||
let client = client.clone();
|
|
||||||
let quality = self.settings.quality;
|
let quality = self.settings.quality;
|
||||||
Task::future(async move { fetch_audio(&client, &track_id, quality).await })
|
Task::batch(effects.into_iter().map(|effect| match effect {
|
||||||
|
Effect::Fetch { generation, track } => {
|
||||||
|
Task::future(fetch_audio(ym.clone(), server.clone(), track, quality))
|
||||||
.map(move |result| Message::Player(player::Msg::Fetched { generation, result }))
|
.map(move |result| Message::Player(player::Msg::Fetched { generation, result }))
|
||||||
}
|
}
|
||||||
Effect::Prefetch { track_id } => {
|
Effect::Prefetch { track } => {
|
||||||
let client = client.clone();
|
let (ym, server) = (ym.clone(), server.clone());
|
||||||
let quality = self.settings.quality;
|
|
||||||
Task::future(async move {
|
Task::future(async move {
|
||||||
let result = fetch_audio(&client, &track_id, quality).await;
|
let track_id = track.id.clone();
|
||||||
(track_id, result)
|
(track_id, fetch_audio(ym, server, track, quality).await)
|
||||||
})
|
})
|
||||||
.map(|(track_id, result)| Message::Player(player::Msg::Prefetched { track_id, result }))
|
.map(|(track_id, result)| Message::Player(player::Msg::Prefetched { track_id, result }))
|
||||||
}
|
}
|
||||||
Effect::SignedOut => Task::done(Message::SignOut),
|
Effect::SignedOut => Task::done(Message::SignOut),
|
||||||
Effect::WaveFetch { station, session_id, queue } => {
|
Effect::WaveFetch { station, session_id, queue } => {
|
||||||
let client = client.clone();
|
let Some(client) = ym.clone() else { return Task::none() };
|
||||||
// My Wave's settings ride along as seeds when a session starts.
|
// My Wave's settings ride along as seeds when a session starts.
|
||||||
let settings = (station == MY_WAVE).then(|| self.wave.shown()).flatten();
|
let settings = (station == MY_WAVE).then(|| self.wave.shown()).flatten();
|
||||||
Task::future(async move {
|
Task::future(async move {
|
||||||
@@ -1389,7 +1419,7 @@ impl App {
|
|||||||
}
|
}
|
||||||
// Feedback and reports are fire-and-forget: a lost one only blunts recommendations.
|
// Feedback and reports are fire-and-forget: a lost one only blunts recommendations.
|
||||||
Effect::WaveFeedback { session_id, event, batch_id } => {
|
Effect::WaveFeedback { session_id, event, batch_id } => {
|
||||||
let client = client.clone();
|
let Some(client) = ym.clone() else { return Task::none() };
|
||||||
Task::future(async move {
|
Task::future(async move {
|
||||||
if let Err(e) = client.wave_feedback(&session_id, &event, batch_id.as_deref()).await {
|
if let Err(e) = client.wave_feedback(&session_id, &event, batch_id.as_deref()).await {
|
||||||
eprintln!("wave feedback {event:?} (batch {batch_id:?}): {e}");
|
eprintln!("wave feedback {event:?} (batch {batch_id:?}): {e}");
|
||||||
@@ -1398,7 +1428,7 @@ impl App {
|
|||||||
.discard()
|
.discard()
|
||||||
}
|
}
|
||||||
Effect::Report(report) => {
|
Effect::Report(report) => {
|
||||||
let client = client.clone();
|
let Some(client) = ym.clone() else { return Task::none() };
|
||||||
Task::future(async move {
|
Task::future(async move {
|
||||||
if let Err(e) = client.report_play(&report).await {
|
if let Err(e) = client.report_play(&report).await {
|
||||||
eprintln!("play report: {e}");
|
eprintln!("play report: {e}");
|
||||||
@@ -1406,17 +1436,59 @@ impl App {
|
|||||||
})
|
})
|
||||||
.discard()
|
.discard()
|
||||||
}
|
}
|
||||||
|
Effect::NowPlaying(track) => scrobble(server.clone(), &track, false),
|
||||||
|
Effect::Scrobble(track) => scrobble(server.clone(), &track, true),
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn fetch_audio(client: &YmClient, track_id: &str, quality: Quality) -> Result<Audio, Error> {
|
/// Tells the music server what's playing (`submission: false`) or what was played.
|
||||||
|
fn scrobble(server: Option<subsonic_api::Client>, track: &Track, submission: bool) -> Task<Message> {
|
||||||
|
let (Some(server), Some(song)) = (server, track.subsonic()) else { return Task::none() };
|
||||||
|
let song_id = song.song_id.clone();
|
||||||
|
Task::future(async move {
|
||||||
|
if let Err(e) = server.scrobble(&song_id, submission).await {
|
||||||
|
eprintln!("scrobble {song_id} ({submission}): {e}");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.discard()
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn fetch_audio(
|
||||||
|
ym: Option<YmClient>,
|
||||||
|
server: Option<subsonic_api::Client>,
|
||||||
|
track: Track,
|
||||||
|
quality: Quality,
|
||||||
|
) -> Result<Audio, Error> {
|
||||||
|
let Some(song) = track.subsonic() else {
|
||||||
|
let client = ym.ok_or_else(|| Error::Network("not signed in".into()))?;
|
||||||
let stream = match quality {
|
let stream = match quality {
|
||||||
Quality::Lossless => client.lossless_stream(track_id).await?,
|
Quality::Lossless => client.lossless_stream(&track.id).await?,
|
||||||
_ => client.stream(track_id, quality.max_kbps()).await?,
|
_ => client.stream(&track.id, quality.max_kbps()).await?,
|
||||||
};
|
};
|
||||||
let bytes = client.fetch(&stream).await?;
|
let bytes = client.fetch(&stream).await?;
|
||||||
Ok(Audio { stream, bytes })
|
return Ok(Audio { stream, bytes });
|
||||||
|
};
|
||||||
|
let server = server.ok_or_else(|| Error::Api("no music server connected".into()))?;
|
||||||
|
let plan = subsonic_api::StreamPlan::for_song(&song.suffix, song.bit_rate, quality.max_kbps(), quality == Quality::Lossless);
|
||||||
|
let audio = server.stream(&song.song_id, plan).await.map_err(server_error)?;
|
||||||
|
let stream = ym_api::Stream {
|
||||||
|
urls: Vec::new(),
|
||||||
|
codec: audio.codec.to_owned(),
|
||||||
|
bitrate_kbps: audio.bitrate_kbps,
|
||||||
|
preview: false,
|
||||||
|
key: None,
|
||||||
|
};
|
||||||
|
Ok(Audio { stream, bytes: audio.bytes.into() })
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A music-server failure in the player's terms. Never `Unauthorized`: that
|
||||||
|
/// would sign the user out of Yandex over a problem with another service.
|
||||||
|
fn server_error(e: subsonic_api::Error) -> Error {
|
||||||
|
match e {
|
||||||
|
subsonic_api::Error::Network(m) => Error::Network(m),
|
||||||
|
other => Error::Api(format!("music server: {other}")),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `MUSYX_TRACE=1` logs every message except the frequent background ones.
|
/// `MUSYX_TRACE=1` logs every message except the frequent background ones.
|
||||||
@@ -1663,6 +1735,93 @@ mod tests {
|
|||||||
assert!(!app.likes.clips.contains(&1));
|
assert!(!app.likes.clips.contains(&1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn server_track(id: &str) -> Track {
|
||||||
|
let song = ym_api::SubsonicSong {
|
||||||
|
song_id: id.into(),
|
||||||
|
album_id: Some("al1".into()),
|
||||||
|
album_title: Some("A".into()),
|
||||||
|
artist_id: None,
|
||||||
|
cover_art: Some("al-al1".into()),
|
||||||
|
suffix: "mp3".into(),
|
||||||
|
bit_rate: 320,
|
||||||
|
};
|
||||||
|
Track::from_subsonic(format!("S{id}"), Some("Kino".into()), std::time::Duration::from_secs(100), song)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn connected(app: &mut App) {
|
||||||
|
let config = subsonic_api::Config { url: "http://10.0.0.2:4533".into(), username: "yp".into(), password: "pw".into() };
|
||||||
|
let _ = app.update(Message::Server(server::Msg::Restored(Ok(Some(config)))));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn my_server_shows_the_connect_form_until_a_server_is_set_up() {
|
||||||
|
let mut app = signed_in();
|
||||||
|
let _ = app.update(Message::Server(server::Msg::Restored(Ok(None))));
|
||||||
|
let _ = app.update(Message::Navigate(Route::Server));
|
||||||
|
{
|
||||||
|
let mut ui = iced_test::simulator(app.view());
|
||||||
|
assert!(ui.find("Server address").is_ok());
|
||||||
|
assert!(ui.find("Connect").is_ok());
|
||||||
|
}
|
||||||
|
|
||||||
|
connected(&mut app);
|
||||||
|
let mut ui = iced_test::simulator(app.view());
|
||||||
|
assert!(ui.find("Server address").is_err(), "connected: the library shows instead");
|
||||||
|
assert!(ui.find("yp on 10.0.0.2:4533").is_ok());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn server_albums_open_their_page() {
|
||||||
|
let mut app = signed_in();
|
||||||
|
connected(&mut app);
|
||||||
|
let _ = app.update(Message::Navigate(Route::Server));
|
||||||
|
let album = subsonic_api::AlbumSummary {
|
||||||
|
id: "al1".into(),
|
||||||
|
name: "Gruppa krovi".into(),
|
||||||
|
artist: Some("Kino".into()),
|
||||||
|
artist_id: Some("ar1".into()),
|
||||||
|
cover_art: None,
|
||||||
|
song_count: 11,
|
||||||
|
duration: std::time::Duration::from_secs(2400),
|
||||||
|
year: Some(1988),
|
||||||
|
};
|
||||||
|
let epoch = app.server.epoch();
|
||||||
|
let _ = app.update(Message::Server(server::Msg::AlbumsLoaded {
|
||||||
|
epoch,
|
||||||
|
sort: subsonic_api::AlbumSort::Newest,
|
||||||
|
offset: 0,
|
||||||
|
result: Ok(vec![album]),
|
||||||
|
}));
|
||||||
|
let messages = click_in_window(&app, "Gruppa krovi");
|
||||||
|
let route = Route::ServerAlbum(crate::route::Sid::of("al1"));
|
||||||
|
assert_eq!(messages, [format!("{:?}", Message::Navigate(route))]);
|
||||||
|
let _ = app.update(Message::Navigate(route));
|
||||||
|
assert_eq!(app.nav.current(), route);
|
||||||
|
assert_eq!(app.title(), "Album · Musyx");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn server_tracks_have_no_heart_and_like_shortcuts_skip_them() {
|
||||||
|
let mut app = signed_in();
|
||||||
|
let _ = app.update(Message::PlayTracks { tracks: vec![server_track("s1")].into(), start: 0, shuffle: false });
|
||||||
|
let _ = app.update(Message::Shortcut(Shortcut::ToggleLike));
|
||||||
|
assert!(app.toast.is_none(), "nothing was liked");
|
||||||
|
let messages = click_in_window(&app, "Ss1");
|
||||||
|
assert!(!messages.iter().any(|m| m.starts_with("LikeTrack")), "{messages:?}");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn music_server_failures_never_sign_out_of_yandex() {
|
||||||
|
let rejected = server_error(subsonic_api::Error::Unauthorized("Wrong username or password".into()));
|
||||||
|
assert!(matches!(rejected, Error::Api(_)), "{rejected:?}");
|
||||||
|
assert!(matches!(server_error(subsonic_api::Error::Network("down".into())), Error::Network(_)));
|
||||||
|
let no_server = tokio::runtime::Builder::new_current_thread()
|
||||||
|
.build()
|
||||||
|
.unwrap()
|
||||||
|
.block_on(fetch_audio(None, None, server_track("s1"), Quality::Best));
|
||||||
|
assert!(matches!(no_server, Err(Error::Api(_))));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn similar_tracks_replace_the_queue_and_say_so() {
|
fn similar_tracks_replace_the_queue_and_say_so() {
|
||||||
let mut app = signed_in();
|
let mut app = signed_in();
|
||||||
|
|||||||
@@ -27,6 +27,36 @@ const PARALLEL: usize = 8;
|
|||||||
/// Side of the Now Playing backdrop in pixels; it is stretched over the window.
|
/// Side of the Now Playing backdrop in pixels; it is stretched over the window.
|
||||||
const BACKDROP: u32 = 32;
|
const BACKDROP: u32 = 32;
|
||||||
|
|
||||||
|
/// Who downloads a cover: Yandex for its own URLs, the music server for
|
||||||
|
/// `subsonic://cover/…` ones. Yandex's client sends its token with every
|
||||||
|
/// request, so it must never fetch a server URL.
|
||||||
|
#[derive(Clone)]
|
||||||
|
pub enum Fetcher {
|
||||||
|
Yandex(YmClient),
|
||||||
|
Server(subsonic_api::Client),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Fetcher {
|
||||||
|
/// The cache file name. Server covers include the host, since another
|
||||||
|
/// server can reuse the same cover id for a different picture.
|
||||||
|
fn file_name(&self, url: &str) -> String {
|
||||||
|
match self {
|
||||||
|
Fetcher::Yandex(_) => file_name(url),
|
||||||
|
Fetcher::Server(client) => file_name(&format!("{}|{url}", client.host())),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn fetch(&self, url: &str) -> Result<Vec<u8>, String> {
|
||||||
|
match self {
|
||||||
|
Fetcher::Yandex(client) => client.image(url).await.map_err(|e| e.to_string()),
|
||||||
|
Fetcher::Server(client) => {
|
||||||
|
let (id, size) = ym_api::parse_subsonic_cover(url).ok_or("not a server cover")?;
|
||||||
|
client.cover_art(id, size).await.map_err(|e| e.to_string())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub struct Covers {
|
pub struct Covers {
|
||||||
images: HashMap<String, image::Handle>,
|
images: HashMap<String, image::Handle>,
|
||||||
pending: HashSet<String>,
|
pending: HashSet<String>,
|
||||||
@@ -92,14 +122,14 @@ impl Covers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Starts fetching `url` unless it is known, in flight, or failed before.
|
/// Starts fetching `url` unless it is known, in flight, or failed before.
|
||||||
pub fn want(&mut self, url: String, client: &YmClient) -> Task<Message> {
|
pub fn want(&mut self, url: String, fetcher: Fetcher) -> Task<Message> {
|
||||||
if self.images.contains_key(&url) || self.pending.contains(&url) || self.failed.contains(&url) {
|
if self.images.contains_key(&url) || self.pending.contains(&url) || self.failed.contains(&url) {
|
||||||
return Task::none();
|
return Task::none();
|
||||||
}
|
}
|
||||||
self.pending.insert(url.clone());
|
self.pending.insert(url.clone());
|
||||||
let (client, dir, gate) = (client.clone(), self.dir.clone(), self.gate.clone());
|
let (dir, gate) = (self.dir.clone(), self.gate.clone());
|
||||||
Task::future(async move {
|
Task::future(async move {
|
||||||
let bytes = load(&client, &url, dir, &gate).await;
|
let bytes = load(&fetcher, &url, dir, &gate).await;
|
||||||
Message::CoverLoaded(url, bytes)
|
Message::CoverLoaded(url, bytes)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -117,6 +147,15 @@ impl Covers {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Drops server covers held in memory, after switching servers.
|
||||||
|
pub fn forget_server(&mut self) {
|
||||||
|
let theirs = |url: &String| url.starts_with(ym_api::SUBSONIC_COVER_PREFIX);
|
||||||
|
self.images.retain(|url, _| !theirs(url));
|
||||||
|
self.failed.retain(|url| !theirs(url));
|
||||||
|
self.backdrops.retain(|url, _| !theirs(url));
|
||||||
|
self.version += 1;
|
||||||
|
}
|
||||||
|
|
||||||
pub fn loaded(&mut self, url: String, bytes: Option<Arc<[u8]>>) {
|
pub fn loaded(&mut self, url: String, bytes: Option<Arc<[u8]>>) {
|
||||||
self.pending.remove(&url);
|
self.pending.remove(&url);
|
||||||
match bytes {
|
match bytes {
|
||||||
@@ -131,8 +170,8 @@ impl Covers {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn load(client: &YmClient, url: &str, dir: Option<PathBuf>, gate: &Semaphore) -> Option<Arc<[u8]>> {
|
async fn load(fetcher: &Fetcher, url: &str, dir: Option<PathBuf>, gate: &Semaphore) -> Option<Arc<[u8]>> {
|
||||||
let path = dir.as_ref().map(|d| d.join(file_name(url)));
|
let path = dir.as_ref().map(|d| d.join(fetcher.file_name(url)));
|
||||||
if let Some(path) = &path
|
if let Some(path) = &path
|
||||||
&& let Ok(bytes) = tokio::fs::read(path).await
|
&& let Ok(bytes) = tokio::fs::read(path).await
|
||||||
{
|
{
|
||||||
@@ -140,7 +179,7 @@ async fn load(client: &YmClient, url: &str, dir: Option<PathBuf>, gate: &Semapho
|
|||||||
}
|
}
|
||||||
|
|
||||||
let _permit = gate.acquire().await.ok()?;
|
let _permit = gate.acquire().await.ok()?;
|
||||||
let bytes = match client.image(url).await {
|
let bytes = match fetcher.fetch(url).await {
|
||||||
Ok(bytes) if !bytes.is_empty() => bytes,
|
Ok(bytes) if !bytes.is_empty() => bytes,
|
||||||
Ok(_) => return None,
|
Ok(_) => return None,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ pub fn get(english: &str) -> Option<&'static str> {
|
|||||||
"Open or close Now Playing" => "Открыть или закрыть «Сейчас играет»",
|
"Open or close Now Playing" => "Открыть или закрыть «Сейчас играет»",
|
||||||
"Go back" => "Назад",
|
"Go back" => "Назад",
|
||||||
"Close a menu or panel" => "Закрыть меню или панель",
|
"Close a menu or panel" => "Закрыть меню или панель",
|
||||||
"Home, My Wave, Search, Collection, Podcasts" => "Главная, Моя волна, Поиск, Коллекция, Подкасты",
|
"Home, My Wave, Search, Collection, My server, Podcasts" => "Главная, Моя волна, Поиск, Коллекция, Мой сервер, Подкасты",
|
||||||
"Album" => "Альбом",
|
"Album" => "Альбом",
|
||||||
"Artist" => "Исполнитель",
|
"Artist" => "Исполнитель",
|
||||||
"Playlist" => "Плейлист",
|
"Playlist" => "Плейлист",
|
||||||
@@ -375,6 +375,41 @@ pub fn get(english: &str) -> Option<&'static str> {
|
|||||||
"Moved" => "Перемещено",
|
"Moved" => "Перемещено",
|
||||||
"Couldn't move the track. Try again." => "Не удалось переместить трек. Попробуйте ещё раз.",
|
"Couldn't move the track. Try again." => "Не удалось переместить трек. Попробуйте ещё раз.",
|
||||||
|
|
||||||
|
// My server (Navidrome and other Subsonic servers)
|
||||||
|
"My server" => "Мой сервер",
|
||||||
|
"Checking your server…" => "Проверяем сервер…",
|
||||||
|
"Connect your Navidrome or another Subsonic-compatible server to browse and play your own music here." => "Подключите Navidrome или другой Subsonic-совместимый сервер, чтобы слушать здесь свою музыку.",
|
||||||
|
"Browse and play a Navidrome or other Subsonic-compatible server under My server. The password is kept in the system keychain." => "Слушайте музыку с Navidrome или другого Subsonic-совместимого сервера в разделе «Мой сервер». Пароль хранится в системной связке ключей.",
|
||||||
|
"Server address" => "Адрес сервера",
|
||||||
|
"Username" => "Имя пользователя",
|
||||||
|
"Password" => "Пароль",
|
||||||
|
"Connect" => "Подключить",
|
||||||
|
"Connecting…" => "Подключаемся…",
|
||||||
|
"Disconnect" => "Отключить",
|
||||||
|
"Connected to {} as {}." => "Подключено к {} как {}.",
|
||||||
|
"{} on {}" => "{} на {}",
|
||||||
|
"Enter the server address and your username." => "Введите адрес сервера и имя пользователя.",
|
||||||
|
"That doesn't look like a server address. Try something like music.example.com." => "Это не похоже на адрес сервера. Попробуйте, например, music.example.com.",
|
||||||
|
"Couldn't reach the server. Check the address and your connection." => "Не удалось связаться с сервером. Проверьте адрес и подключение к интернету.",
|
||||||
|
"That address didn't answer like a music server. Check it and try again." => "По этому адресу не отвечает музыкальный сервер. Проверьте адрес и попробуйте ещё раз.",
|
||||||
|
"The server didn't accept that username and password." => "Сервер не принял имя пользователя и пароль.",
|
||||||
|
"The server no longer accepts your sign-in. Disconnect it in Settings and connect again." => "Сервер больше не принимает ваш вход. Отключите его в настройках и подключите снова.",
|
||||||
|
"Search your server" => "Поиск на сервере",
|
||||||
|
"Clear" => "Очистить",
|
||||||
|
"Recently added" => "Недавно добавленные",
|
||||||
|
"A–Z" => "А–Я",
|
||||||
|
"Starred" => "Избранное",
|
||||||
|
"your starred songs" => "избранные треки",
|
||||||
|
"The server has no albums yet." => "На сервере пока нет альбомов.",
|
||||||
|
"The server has no artists yet." => "На сервере пока нет исполнителей.",
|
||||||
|
"No playlists yet. Playlists you make on the server show up here." => "Плейлистов пока нет. Плейлисты, созданные на сервере, появятся здесь.",
|
||||||
|
"No starred songs yet. Star songs on the server and they show up here." => "Избранных треков пока нет. Отметьте треки звёздочкой на сервере, и они появятся здесь.",
|
||||||
|
"Nothing on your server matches that." => "На сервере ничего не нашлось.",
|
||||||
|
"This album isn't on your server any more." => "Этого альбома больше нет на сервере.",
|
||||||
|
"This artist isn't on your server any more." => "Этого исполнителя больше нет на сервере.",
|
||||||
|
"This playlist isn't on your server any more." => "Этого плейлиста больше нет на сервере.",
|
||||||
|
"Connect your server under My server to see this page." => "Подключите сервер в разделе «Мой сервер», чтобы открыть эту страницу.",
|
||||||
|
|
||||||
// Units
|
// Units
|
||||||
"{} h {} min" => "{} ч {} мин",
|
"{} h {} min" => "{} ч {} мин",
|
||||||
"{} min" => "{} мин",
|
"{} min" => "{} мин",
|
||||||
|
|||||||
@@ -101,12 +101,13 @@ impl Media {
|
|||||||
if new_track {
|
if new_track {
|
||||||
let title = track.full_title();
|
let title = track.full_title();
|
||||||
let artist = track.artist_line();
|
let artist = track.artist_line();
|
||||||
let album = track.album.as_ref().map(|a| a.title.clone());
|
let album = track.album_title();
|
||||||
let cover = track.cover_url(covers::LARGE);
|
// Server covers are app-internal URLs the system can't open.
|
||||||
|
let cover = track.cover_url(covers::LARGE).filter(|url| url.starts_with("http"));
|
||||||
let _ = controls.set_metadata(MediaMetadata {
|
let _ = controls.set_metadata(MediaMetadata {
|
||||||
title: Some(&title),
|
title: Some(&title),
|
||||||
artist: Some(&artist),
|
artist: Some(&artist),
|
||||||
album: album.as_deref(),
|
album,
|
||||||
cover_url: cover.as_deref(),
|
cover_url: cover.as_deref(),
|
||||||
duration: Some(track.duration),
|
duration: Some(track.duration),
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -75,14 +75,25 @@ pub enum Msg {
|
|||||||
/// Work the app has to do on the player's behalf.
|
/// Work the app has to do on the player's behalf.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub enum Effect {
|
pub enum Effect {
|
||||||
Fetch { generation: u64, track_id: String },
|
/// Download `track`'s audio from wherever it lives.
|
||||||
Prefetch { track_id: String },
|
Fetch { generation: u64, track: Track },
|
||||||
|
Prefetch { track: Track },
|
||||||
/// The token stopped working mid-session.
|
/// The token stopped working mid-session.
|
||||||
SignedOut,
|
SignedOut,
|
||||||
/// Start a session (`session_id: None`) or continue one; `queue` is recent `full_id`s.
|
/// Start a session (`session_id: None`) or continue one; `queue` is recent `full_id`s.
|
||||||
WaveFetch { station: String, session_id: Option<String>, queue: Vec<String> },
|
WaveFetch { station: String, session_id: Option<String>, queue: Vec<String> },
|
||||||
WaveFeedback { session_id: String, event: WaveEvent, batch_id: Option<String> },
|
WaveFeedback { session_id: String, event: WaveEvent, batch_id: Option<String> },
|
||||||
|
/// A finished or abandoned listen of a Yandex track.
|
||||||
Report(PlayReport),
|
Report(PlayReport),
|
||||||
|
/// A track from a music server started: set it as "now playing" there.
|
||||||
|
NowPlaying(Track),
|
||||||
|
/// A music-server track was played long enough to count as a play.
|
||||||
|
Scrobble(Track),
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The usual scrobbling rule: half the track, or four minutes of a long one.
|
||||||
|
pub fn counts_as_play(played: Duration, length: Duration) -> bool {
|
||||||
|
!length.is_zero() && played >= (length / 2).min(Duration::from_secs(240))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A station being played, endlessly topped up.
|
/// A station being played, endlessly topped up.
|
||||||
@@ -381,8 +392,11 @@ impl Player {
|
|||||||
self.status = Status::Playing;
|
self.status = Status::Playing;
|
||||||
self.skips = 0;
|
self.skips = 0;
|
||||||
let mut effects = Vec::new();
|
let mut effects = Vec::new();
|
||||||
if let Some((id, full_id)) = self.track().map(|t| (t.id.clone(), t.full_id())) {
|
if let Some(track) = self.track().cloned() {
|
||||||
if let Some(wave) = &self.wave
|
let (id, full_id) = (track.id.clone(), track.full_id());
|
||||||
|
if !track.is_yandex() {
|
||||||
|
effects.push(Effect::NowPlaying(track));
|
||||||
|
} else if let Some(wave) = &self.wave
|
||||||
&& let Some(session_id) = wave.session_id.clone()
|
&& let Some(session_id) = wave.session_id.clone()
|
||||||
{
|
{
|
||||||
effects.push(Effect::WaveFeedback {
|
effects.push(Effect::WaveFeedback {
|
||||||
@@ -455,6 +469,10 @@ impl Player {
|
|||||||
let Some(id) = self.started.take() else { return vec![] };
|
let Some(id) = self.started.take() else { return vec![] };
|
||||||
let Some(track) = self.track().filter(|t| t.id == id) else { return vec![] };
|
let Some(track) = self.track().filter(|t| t.id == id) else { return vec![] };
|
||||||
let played = if finished { self.duration } else { self.position.min(self.duration) };
|
let played = if finished { self.duration } else { self.position.min(self.duration) };
|
||||||
|
// Server tracks are reported to their server, never to Yandex or its stations.
|
||||||
|
if !track.is_yandex() {
|
||||||
|
return if counts_as_play(played, self.duration) { vec![Effect::Scrobble(track.clone())] } else { vec![] };
|
||||||
|
}
|
||||||
let mut effects = vec![Effect::Report(PlayReport {
|
let mut effects = vec![Effect::Report(PlayReport {
|
||||||
track_id: id.clone(),
|
track_id: id.clone(),
|
||||||
album_id: track.album.as_ref().map(|a| a.id),
|
album_id: track.album.as_ref().map(|a| a.id),
|
||||||
@@ -575,7 +593,7 @@ impl Player {
|
|||||||
None => {
|
None => {
|
||||||
self.status = Status::Loading;
|
self.status = Status::Loading;
|
||||||
self.current = None;
|
self.current = None;
|
||||||
vec![Effect::Fetch { generation: self.generation, track_id: track.id }]
|
vec![Effect::Fetch { generation: self.generation, track }]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -610,7 +628,7 @@ impl Player {
|
|||||||
return vec![];
|
return vec![];
|
||||||
}
|
}
|
||||||
self.prefetched = None;
|
self.prefetched = None;
|
||||||
vec![Effect::Prefetch { track_id: next.id.clone() }]
|
vec![Effect::Prefetch { track: next.clone() }]
|
||||||
}
|
}
|
||||||
|
|
||||||
fn skip_unplayable(&mut self) -> Vec<Effect> {
|
fn skip_unplayable(&mut self) -> Vec<Effect> {
|
||||||
@@ -667,14 +685,14 @@ mod tests {
|
|||||||
let mut p = Player::default();
|
let mut p = Player::default();
|
||||||
let tracks: Arc<[Track]> = vec![track("a", 10), track("b", 20)].into();
|
let tracks: Arc<[Track]> = vec![track("a", 10), track("b", 20)].into();
|
||||||
let effects = p.update(Msg::Play { tracks, start: 0, shuffle: None });
|
let effects = p.update(Msg::Play { tracks, start: 0, shuffle: None });
|
||||||
assert!(effects.contains(&Effect::Fetch { generation: 1, track_id: "a".into() }), "{effects:?}");
|
assert!(effects.contains(&Effect::Fetch { generation: 1, track: track("a", 10) }), "{effects:?}");
|
||||||
assert_eq!(effects.iter().filter(|e| matches!(e, Effect::Fetch { .. })).count(), 1);
|
assert_eq!(effects.iter().filter(|e| matches!(e, Effect::Fetch { .. })).count(), 1);
|
||||||
assert_eq!(p.status(), Status::Loading);
|
assert_eq!(p.status(), Status::Loading);
|
||||||
assert!(p.update(Msg::Fetched { generation: 1, result: Ok(audio()) }).is_empty());
|
assert!(p.update(Msg::Fetched { generation: 1, result: Ok(audio()) }).is_empty());
|
||||||
let effects = p.update(Msg::Engine(Event::Loaded { generation: 1, duration: None }));
|
let effects = p.update(Msg::Engine(Event::Loaded { generation: 1, duration: None }));
|
||||||
assert_eq!(p.status(), Status::Playing);
|
assert_eq!(p.status(), Status::Playing);
|
||||||
assert_eq!(p.duration(), Duration::from_secs(10));
|
assert_eq!(p.duration(), Duration::from_secs(10));
|
||||||
assert_eq!(effects, vec![Effect::Prefetch { track_id: "b".into() }]);
|
assert_eq!(effects, vec![Effect::Prefetch { track: track("b", 20) }]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -861,7 +879,7 @@ mod tests {
|
|||||||
assert_eq!(p.status(), Status::Loading, "a wave doesn't end");
|
assert_eq!(p.status(), Status::Loading, "a wave doesn't end");
|
||||||
let batch = WaveBatch { session_id: Some("s1".into()), tracks: vec![track("w9", 50)], batch_id: Some("b2".into()) };
|
let batch = WaveBatch { session_id: Some("s1".into()), tracks: vec![track("w9", 50)], batch_id: Some("b2".into()) };
|
||||||
let effects = p.update(Msg::WaveBatch { station: "user:onyourwave".into(), result: Ok(batch) });
|
let effects = p.update(Msg::WaveBatch { station: "user:onyourwave".into(), result: Ok(batch) });
|
||||||
assert!(matches!(effects.first(), Some(Effect::Fetch { track_id, .. }) if track_id == "w9"));
|
assert!(matches!(effects.first(), Some(Effect::Fetch { track, .. }) if track.id == "w9"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -901,7 +919,7 @@ mod tests {
|
|||||||
|
|
||||||
let mut empty = Player::default();
|
let mut empty = Player::default();
|
||||||
let effects = empty.update(Msg::Append(track("solo", 5)));
|
let effects = empty.update(Msg::Append(track("solo", 5)));
|
||||||
assert!(effects.iter().any(|e| matches!(e, Effect::Fetch { track_id, .. } if track_id == "solo")));
|
assert!(effects.iter().any(|e| matches!(e, Effect::Fetch { track, .. } if track.id == "solo")));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -909,7 +927,7 @@ mod tests {
|
|||||||
let mut p = playing(3, 0);
|
let mut p = playing(3, 0);
|
||||||
p.update(Msg::Prefetched { track_id: "1".into(), result: Ok(audio()) });
|
p.update(Msg::Prefetched { track_id: "1".into(), result: Ok(audio()) });
|
||||||
let effects = p.update(Msg::PlayNext(track("n", 5)));
|
let effects = p.update(Msg::PlayNext(track("n", 5)));
|
||||||
assert!(effects.contains(&Effect::Prefetch { track_id: "n".into() }), "{effects:?}");
|
assert!(effects.iter().any(|e| matches!(e, Effect::Prefetch { track } if track.id == "n")), "{effects:?}");
|
||||||
let generation = p.generation;
|
let generation = p.generation;
|
||||||
let effects = p.update(Msg::Engine(Event::Ended { generation }));
|
let effects = p.update(Msg::Engine(Event::Ended { generation }));
|
||||||
assert_eq!(p.track().unwrap().id, "n", "{effects:?}");
|
assert_eq!(p.track().unwrap().id, "n", "{effects:?}");
|
||||||
@@ -952,4 +970,57 @@ mod tests {
|
|||||||
assert!(!p.muted);
|
assert!(!p.muted);
|
||||||
assert_eq!(p.volume, 0.5);
|
assert_eq!(p.volume, 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn server_track(id: &str, secs: u64) -> Track {
|
||||||
|
let song = ym_api::SubsonicSong {
|
||||||
|
song_id: id.into(),
|
||||||
|
album_id: None,
|
||||||
|
album_title: None,
|
||||||
|
artist_id: None,
|
||||||
|
cover_art: None,
|
||||||
|
suffix: "mp3".into(),
|
||||||
|
bit_rate: 320,
|
||||||
|
};
|
||||||
|
Track::from_subsonic(format!("S{id}"), None, Duration::from_secs(secs), song)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn server_tracks_in_a_wave_report_to_their_server_only() {
|
||||||
|
let mut p = wave_with(3);
|
||||||
|
loaded(&mut p);
|
||||||
|
p.update(Msg::PlayNext(server_track("s1", 100)));
|
||||||
|
let effects = p.update(Msg::Next);
|
||||||
|
assert!(effects.iter().any(|e| matches!(e, Effect::Fetch { track, .. } if track.id == "sub-s1")), "{effects:?}");
|
||||||
|
let generation = p.generation;
|
||||||
|
p.update(Msg::Fetched { generation, result: Ok(audio()) });
|
||||||
|
let effects = loaded(&mut p);
|
||||||
|
assert!(effects.iter().any(|e| matches!(e, Effect::NowPlaying(t) if t.id == "sub-s1")), "{effects:?}");
|
||||||
|
assert!(!effects.iter().any(|e| matches!(e, Effect::WaveFeedback { .. })), "{effects:?}");
|
||||||
|
|
||||||
|
let generation = p.generation;
|
||||||
|
p.update(Msg::Engine(Event::Position { generation, position: Duration::from_secs(30) }));
|
||||||
|
let effects = p.update(Msg::Next);
|
||||||
|
assert!(
|
||||||
|
!effects.iter().any(|e| matches!(e, Effect::Report(_) | Effect::WaveFeedback { .. } | Effect::Scrobble(_))),
|
||||||
|
"30 of 100 seconds: nothing to report anywhere: {effects:?}"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn server_tracks_scrobble_after_half_or_four_minutes() {
|
||||||
|
let mut p = Player::default();
|
||||||
|
let tracks: Arc<[Track]> = vec![server_track("a", 100), server_track("b", 100)].into();
|
||||||
|
let effects = p.update(Msg::Play { tracks, start: 0, shuffle: None });
|
||||||
|
let generation = fetch_generation(&effects).unwrap();
|
||||||
|
p.update(Msg::Fetched { generation, result: Ok(audio()) });
|
||||||
|
loaded(&mut p);
|
||||||
|
p.update(Msg::Engine(Event::Position { generation, position: Duration::from_secs(60) }));
|
||||||
|
let effects = p.update(Msg::Next);
|
||||||
|
assert!(effects.iter().any(|e| matches!(e, Effect::Scrobble(t) if t.id == "sub-a")), "{effects:?}");
|
||||||
|
assert!(!effects.iter().any(|e| matches!(e, Effect::Report(_))));
|
||||||
|
|
||||||
|
assert!(counts_as_play(Duration::from_secs(240), Duration::from_secs(3600)));
|
||||||
|
assert!(!counts_as_play(Duration::from_secs(239), Duration::from_secs(3600)));
|
||||||
|
assert!(!counts_as_play(Duration::ZERO, Duration::ZERO));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -6,12 +6,26 @@ use ym_api::PlaylistId;
|
|||||||
|
|
||||||
use crate::ui::icons::Icon;
|
use crate::ui::icons::Icon;
|
||||||
|
|
||||||
|
/// A music-server id (album, artist, playlist) as a `Copy` handle, so routes
|
||||||
|
/// to server pages stay `Copy`. The server screen maps it back to the id.
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||||
|
pub struct Sid(pub u64);
|
||||||
|
|
||||||
|
impl Sid {
|
||||||
|
/// 64-bit FNV-1a of the id; equal ids give equal handles.
|
||||||
|
pub fn of(id: &str) -> Sid {
|
||||||
|
Sid(id.bytes().fold(0xcbf2_9ce4_8422_2325_u64, |h, b| (h ^ u64::from(b)).wrapping_mul(0x0100_0000_01b3)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||||
pub enum Route {
|
pub enum Route {
|
||||||
Home,
|
Home,
|
||||||
Wave,
|
Wave,
|
||||||
Search,
|
Search,
|
||||||
Collection,
|
Collection,
|
||||||
|
/// The user's own music server (Navidrome or another Subsonic server).
|
||||||
|
Server,
|
||||||
Podcasts,
|
Podcasts,
|
||||||
Settings,
|
Settings,
|
||||||
Album(i64),
|
Album(i64),
|
||||||
@@ -20,12 +34,15 @@ pub enum Route {
|
|||||||
Chart,
|
Chart,
|
||||||
/// Index into the app's flattened genre list.
|
/// Index into the app's flattened genre list.
|
||||||
Genre(usize),
|
Genre(usize),
|
||||||
|
ServerAlbum(Sid),
|
||||||
|
ServerArtist(Sid),
|
||||||
|
ServerPlaylist(Sid),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Route {
|
impl Route {
|
||||||
/// Sidebar order.
|
/// Sidebar order.
|
||||||
pub const NAV: [Route; 5] =
|
pub const NAV: [Route; 6] =
|
||||||
[Route::Home, Route::Wave, Route::Search, Route::Collection, Route::Podcasts];
|
[Route::Home, Route::Wave, Route::Search, Route::Collection, Route::Server, Route::Podcasts];
|
||||||
|
|
||||||
pub fn label(self) -> &'static str {
|
pub fn label(self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
@@ -33,27 +50,34 @@ impl Route {
|
|||||||
Route::Wave => tr("My Wave"),
|
Route::Wave => tr("My Wave"),
|
||||||
Route::Search => tr("Search"),
|
Route::Search => tr("Search"),
|
||||||
Route::Collection => tr("Collection"),
|
Route::Collection => tr("Collection"),
|
||||||
|
Route::Server => tr("My server"),
|
||||||
Route::Podcasts => tr("Podcasts"),
|
Route::Podcasts => tr("Podcasts"),
|
||||||
Route::Settings => tr("Settings"),
|
Route::Settings => tr("Settings"),
|
||||||
Route::Album(_) => tr("Album"),
|
Route::Album(_) | Route::ServerAlbum(_) => tr("Album"),
|
||||||
Route::Artist(_) => tr("Artist"),
|
Route::Artist(_) | Route::ServerArtist(_) => tr("Artist"),
|
||||||
Route::Playlist(_) => tr("Playlist"),
|
Route::Playlist(_) | Route::ServerPlaylist(_) => tr("Playlist"),
|
||||||
Route::Chart => tr("Chart"),
|
Route::Chart => tr("Chart"),
|
||||||
Route::Genre(_) => tr("Genre"),
|
Route::Genre(_) => tr("Genre"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// My server and its album, artist and playlist pages.
|
||||||
|
pub fn is_server(self) -> bool {
|
||||||
|
matches!(self, Route::Server | Route::ServerAlbum(_) | Route::ServerArtist(_) | Route::ServerPlaylist(_))
|
||||||
|
}
|
||||||
|
|
||||||
pub fn icon(self) -> Icon {
|
pub fn icon(self) -> Icon {
|
||||||
match self {
|
match self {
|
||||||
Route::Home => Icon::Home,
|
Route::Home => Icon::Home,
|
||||||
Route::Wave => Icon::Wave,
|
Route::Wave => Icon::Wave,
|
||||||
Route::Search => Icon::Search,
|
Route::Search => Icon::Search,
|
||||||
Route::Collection => Icon::Library,
|
Route::Collection => Icon::Library,
|
||||||
|
Route::Server => Icon::Server,
|
||||||
Route::Podcasts => Icon::Podcast,
|
Route::Podcasts => Icon::Podcast,
|
||||||
Route::Settings => Icon::Settings,
|
Route::Settings => Icon::Settings,
|
||||||
Route::Album(_) => Icon::Disc,
|
Route::Album(_) | Route::ServerAlbum(_) => Icon::Disc,
|
||||||
Route::Artist(_) => Icon::Wave,
|
Route::Artist(_) | Route::ServerArtist(_) => Icon::Wave,
|
||||||
Route::Playlist(_) => Icon::Queue,
|
Route::Playlist(_) | Route::ServerPlaylist(_) => Icon::Queue,
|
||||||
Route::Chart => Icon::Chart,
|
Route::Chart => Icon::Chart,
|
||||||
Route::Genre(_) => Icon::Library,
|
Route::Genre(_) => Icon::Library,
|
||||||
}
|
}
|
||||||
@@ -125,6 +149,14 @@ mod tests {
|
|||||||
assert!(!nav.can_go_back());
|
assert!(!nav.can_go_back());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn server_ids_become_stable_route_handles() {
|
||||||
|
assert_eq!(Sid::of("al-1"), Sid::of("al-1"));
|
||||||
|
assert_ne!(Sid::of("al-1"), Sid::of("al-2"));
|
||||||
|
assert_ne!(Route::ServerAlbum(Sid::of("x")), Route::ServerArtist(Sid::of("x")));
|
||||||
|
assert_eq!(Route::NAV[4], Route::Server, "My server sits after Collection");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn history_is_bounded() {
|
fn history_is_bounded() {
|
||||||
let mut nav = Navigator::new(Route::Home);
|
let mut nav = Navigator::new(Route::Home);
|
||||||
|
|||||||
@@ -88,18 +88,18 @@ fn not_found_or_retry<'a>(env: Env<'a>, e: &'a Error, what: What, route: Route)
|
|||||||
status(env.t, LoadState::Failed(e), what.retry, Message::Navigate(route))
|
status(env.t, LoadState::Failed(e), what.retry, Message::Navigate(route))
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Head<'a> {
|
pub(crate) struct Head<'a> {
|
||||||
cover: Option<String>,
|
pub cover: Option<String>,
|
||||||
hues: (f32, f32),
|
pub hues: (f32, f32),
|
||||||
round: bool,
|
pub round: bool,
|
||||||
kind: String,
|
pub kind: String,
|
||||||
title: String,
|
pub title: String,
|
||||||
by: Option<Element<'a, Message>>,
|
pub by: Option<Element<'a, Message>>,
|
||||||
meta: String,
|
pub meta: String,
|
||||||
actions: Vec<Element<'a, Message>>,
|
pub actions: Vec<Element<'a, Message>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn head<'a>(env: Env<'a>, h: Head<'a>) -> Element<'a, Message> {
|
pub(crate) fn head<'a>(env: Env<'a>, h: Head<'a>) -> Element<'a, Message> {
|
||||||
let t = env.t;
|
let t = env.t;
|
||||||
let size_px = 200.0;
|
let size_px = 200.0;
|
||||||
let corner = if h.round { size_px / 2.0 } else { theme::radius::COVER };
|
let corner = if h.round { size_px / 2.0 } else { theme::radius::COVER };
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ pub mod browse;
|
|||||||
pub mod collection;
|
pub mod collection;
|
||||||
pub mod detail;
|
pub mod detail;
|
||||||
pub mod search;
|
pub mod search;
|
||||||
|
pub mod server;
|
||||||
pub mod settings;
|
pub mod settings;
|
||||||
pub mod sign_in;
|
pub mod sign_in;
|
||||||
pub mod wave;
|
pub mod wave;
|
||||||
@@ -24,16 +25,17 @@ use crate::widgets::track_list::Env;
|
|||||||
use crate::i18n::{tr, trf};
|
use crate::i18n::{tr, trf};
|
||||||
|
|
||||||
/// Something fetched from the API: not asked for yet, on its way, here, or failed.
|
/// Something fetched from the API: not asked for yet, on its way, here, or failed.
|
||||||
|
/// `E` is the API's error type: Yandex's, or the music server's.
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
pub enum Loadable<T> {
|
pub enum Loadable<T, E = Error> {
|
||||||
#[default]
|
#[default]
|
||||||
NotLoaded,
|
NotLoaded,
|
||||||
Loading,
|
Loading,
|
||||||
Loaded(T),
|
Loaded(T),
|
||||||
Failed(Error),
|
Failed(E),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Loadable<T> {
|
impl<T, E> Loadable<T, E> {
|
||||||
pub fn get(&self) -> Option<&T> {
|
pub fn get(&self) -> Option<&T> {
|
||||||
match self {
|
match self {
|
||||||
Loadable::Loaded(v) => Some(v),
|
Loadable::Loaded(v) => Some(v),
|
||||||
@@ -46,19 +48,21 @@ impl<T> Loadable<T> {
|
|||||||
matches!(self, Loadable::NotLoaded | Loadable::Failed(_))
|
matches!(self, Loadable::NotLoaded | Loadable::Failed(_))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn from_result(result: Result<T, E>) -> Self {
|
||||||
|
match result {
|
||||||
|
Ok(v) => Loadable::Loaded(v),
|
||||||
|
Err(e) => Loadable::Failed(e),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> Loadable<T> {
|
||||||
pub fn state(&self) -> collection::LoadState<'_> {
|
pub fn state(&self) -> collection::LoadState<'_> {
|
||||||
match self {
|
match self {
|
||||||
Loadable::Failed(e) => collection::LoadState::Failed(e),
|
Loadable::Failed(e) => collection::LoadState::Failed(e),
|
||||||
_ => collection::LoadState::Loading,
|
_ => collection::LoadState::Loading,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_result(result: Result<T, Error>) -> Self {
|
|
||||||
match result {
|
|
||||||
Ok(v) => Loadable::Loaded(v),
|
|
||||||
Err(e) => Loadable::Failed(e),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Everything a routed screen may need from app state.
|
/// Everything a routed screen may need from app state.
|
||||||
@@ -75,10 +79,12 @@ pub struct Ctx<'a> {
|
|||||||
pub wave: &'a wave::WaveScreen,
|
pub wave: &'a wave::WaveScreen,
|
||||||
pub wave_phase: f32,
|
pub wave_phase: f32,
|
||||||
pub settings: &'a crate::store::Settings,
|
pub settings: &'a crate::store::Settings,
|
||||||
|
pub server: &'a server::ServerScreen,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn view<'a>(ctx: Ctx<'a>) -> Element<'a, Message> {
|
pub fn view<'a>(ctx: Ctx<'a>) -> Element<'a, Message> {
|
||||||
let Ctx { env, route, search, me, library, pages, discover, genre_playlists, player, wave, wave_phase, settings } = ctx;
|
let Ctx { env, route, search, me, library, pages, discover, genre_playlists, player, wave, wave_phase, settings, server } =
|
||||||
|
ctx;
|
||||||
let t = env.t;
|
let t = env.t;
|
||||||
let content: Column<'a, Message> = match route {
|
let content: Column<'a, Message> = match route {
|
||||||
Route::Home => {
|
Route::Home => {
|
||||||
@@ -102,8 +108,12 @@ pub fn view<'a>(ctx: Ctx<'a>) -> Element<'a, Message> {
|
|||||||
Route::Album(_) | Route::Artist(_) | Route::Playlist(_) => {
|
Route::Album(_) | Route::Artist(_) | Route::Playlist(_) => {
|
||||||
column![detail::view(env, route, pages.get(&route).unwrap_or(&Loadable::Loading))]
|
column![detail::view(env, route, pages.get(&route).unwrap_or(&Loadable::Loading))]
|
||||||
}
|
}
|
||||||
|
Route::Server => column![server::view(env, server)],
|
||||||
|
Route::ServerAlbum(_) | Route::ServerArtist(_) | Route::ServerPlaylist(_) => {
|
||||||
|
column![server::page(env, server, route)]
|
||||||
|
}
|
||||||
Route::Podcasts => column![browse::podcasts(env, discover, &library.albums)],
|
Route::Podcasts => column![browse::podcasts(env, discover, &library.albums)],
|
||||||
Route::Settings => column![settings::view(t, settings, account_card(t, me))],
|
Route::Settings => column![settings::view(t, settings, account_card(t, me), server::settings_section(t, server))],
|
||||||
};
|
};
|
||||||
|
|
||||||
content
|
content
|
||||||
|
|||||||
File diff suppressed because it is too large.
Load diff
@@ -9,7 +9,12 @@ use crate::ui::theme::{self, Tokens, size};
|
|||||||
use crate::ui::{line, para};
|
use crate::ui::{line, para};
|
||||||
use crate::i18n::{tr, trf};
|
use crate::i18n::{tr, trf};
|
||||||
|
|
||||||
pub fn view<'a>(t: &'static Tokens, settings: &Settings, account: Element<'a, Message>) -> Element<'a, Message> {
|
pub fn view<'a>(
|
||||||
|
t: &'static Tokens,
|
||||||
|
settings: &Settings,
|
||||||
|
account: Element<'a, Message>,
|
||||||
|
server: Element<'a, Message>,
|
||||||
|
) -> Element<'a, Message> {
|
||||||
let quality = Row::with_children(Quality::ALL.map(|q| chip(t, q.label(), q == settings.quality, Message::SetQuality(q))))
|
let quality = Row::with_children(Quality::ALL.map(|q| chip(t, q.label(), q == settings.quality, Message::SetQuality(q))))
|
||||||
.spacing(6);
|
.spacing(6);
|
||||||
let appearance =
|
let appearance =
|
||||||
@@ -23,6 +28,7 @@ pub fn view<'a>(t: &'static Tokens, settings: &Settings, account: Element<'a, Me
|
|||||||
line(tr("Settings"), theme::DISPLAY, size::DISPLAY_S, t.fg),
|
line(tr("Settings"), theme::DISPLAY, size::DISPLAY_S, t.fg),
|
||||||
account,
|
account,
|
||||||
section(t, tr("Streaming quality"), column![quality, para(settings.quality.detail(), size::META, t.muted)].spacing(10).into()),
|
section(t, tr("Streaming quality"), column![quality, para(settings.quality.detail(), size::META, t.muted)].spacing(10).into()),
|
||||||
|
section(t, tr("My server"), server),
|
||||||
section(t, tr("Appearance"), appearance.into()),
|
section(t, tr("Appearance"), appearance.into()),
|
||||||
section(t, tr("Language"), language.into()),
|
section(t, tr("Language"), language.into()),
|
||||||
section(
|
section(
|
||||||
|
|||||||
@@ -273,8 +273,9 @@ impl SignIn {
|
|||||||
|
|
||||||
let copied = w.copied_at.is_some_and(|at| w.now.duration_since(at) < Duration::from_secs(2));
|
let copied = w.copied_at.is_some_and(|at| w.now.duration_since(at) < Duration::from_secs(2));
|
||||||
let code_box = row![
|
let code_box = row![
|
||||||
container(line(spaced(&w.code.user_code), theme::DISPLAY, 30.0, t.fg))
|
// Taller line so descenders (j, g, y) aren't clipped; padding shrinks to keep the card size.
|
||||||
.padding([14, 18])
|
container(line(spaced(&w.code.user_code), theme::DISPLAY, size::DISPLAY_S, t.fg).line_height(1.5))
|
||||||
|
.padding([11, 18])
|
||||||
.style(theme::card),
|
.style(theme::card),
|
||||||
ghost(t, Icon::Copy, if copied { tr("Copied") } else { tr("Copy code") }, Msg::CopyCode),
|
ghost(t, Icon::Copy, if copied { tr("Copied") } else { tr("Copy code") }, Msg::CopyCode),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -109,3 +109,45 @@ async fn forget(reason: Error) -> Restored {
|
|||||||
}
|
}
|
||||||
Restored::SignedOut
|
Restored::SignedOut
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The music server's address and sign-in, kept in the keychain next to the
|
||||||
|
/// Yandex credentials (the password is a secret like the token).
|
||||||
|
pub mod server {
|
||||||
|
use subsonic_api::Config;
|
||||||
|
|
||||||
|
use super::blocking;
|
||||||
|
|
||||||
|
const ACCOUNT: &str = "subsonic";
|
||||||
|
|
||||||
|
fn entry() -> Result<keyring::Entry, String> {
|
||||||
|
keyring::Entry::new(super::SERVICE, ACCOUNT).map_err(|e| e.to_string())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn load() -> Result<Option<Config>, String> {
|
||||||
|
blocking(|| {
|
||||||
|
let raw = match entry()?.get_password() {
|
||||||
|
Ok(raw) => raw,
|
||||||
|
Err(keyring::Error::NoEntry) => return Ok(None),
|
||||||
|
Err(e) => return Err(e.to_string()),
|
||||||
|
};
|
||||||
|
Ok(serde_json::from_str(&raw).ok())
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn save(config: Config) -> Result<(), String> {
|
||||||
|
blocking(move || {
|
||||||
|
let json = serde_json::to_string(&config).map_err(|e| e.to_string())?;
|
||||||
|
entry()?.set_password(&json).map_err(|e| e.to_string())
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn clear() -> Result<(), String> {
|
||||||
|
blocking(|| match entry()?.delete_credential() {
|
||||||
|
Ok(()) | Err(keyring::Error::NoEntry) => Ok(()),
|
||||||
|
Err(e) => Err(e.to_string()),
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -97,7 +97,7 @@ pub fn from_key(key: &Key, physical: Physical, mods: Modifiers, repeat: bool) ->
|
|||||||
'p' => S::NowPlaying,
|
'p' => S::NowPlaying,
|
||||||
'[' => S::Back,
|
'[' => S::Back,
|
||||||
',' => S::Go(Route::Settings),
|
',' => S::Go(Route::Settings),
|
||||||
'1'..='5' => S::Go(Route::NAV[c as usize - '1' as usize]),
|
'1'..='6' => S::Go(Route::NAV[c as usize - '1' as usize]),
|
||||||
_ => return None,
|
_ => return None,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -134,7 +134,7 @@ pub fn help() -> Vec<(&'static str, Vec<String>)> {
|
|||||||
(tr("Search"), vec![with(cmd, "F"), "/".to_owned()]),
|
(tr("Search"), vec![with(cmd, "F"), "/".to_owned()]),
|
||||||
(tr("Go back"), vec![with(cmd, "["), with(alt, "←")]),
|
(tr("Go back"), vec![with(cmd, "["), with(alt, "←")]),
|
||||||
(tr("Close a menu or panel"), vec!["Esc".to_owned()]),
|
(tr("Close a menu or panel"), vec!["Esc".to_owned()]),
|
||||||
(tr("Home, My Wave, Search, Collection, Podcasts"), vec![format!("{cmd}1 … {cmd}5")]),
|
(tr("Home, My Wave, Search, Collection, My server, Podcasts"), vec![format!("{cmd}1 … {cmd}6")]),
|
||||||
(tr("Settings"), vec![with(cmd, ",")]),
|
(tr("Settings"), vec![with(cmd, ",")]),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -198,8 +198,9 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn number_keys_open_the_sidebar_sections() {
|
fn number_keys_open_the_sidebar_sections() {
|
||||||
assert_eq!(press(ch("1"), Code::Digit1, Modifiers::COMMAND), Some(Shortcut::Go(Route::Home)));
|
assert_eq!(press(ch("1"), Code::Digit1, Modifiers::COMMAND), Some(Shortcut::Go(Route::Home)));
|
||||||
assert_eq!(press(ch("5"), Code::Digit5, Modifiers::COMMAND), Some(Shortcut::Go(Route::Podcasts)));
|
assert_eq!(press(ch("5"), Code::Digit5, Modifiers::COMMAND), Some(Shortcut::Go(Route::Server)));
|
||||||
assert_eq!(press(ch("6"), Code::Digit6, Modifiers::COMMAND), None);
|
assert_eq!(press(ch("6"), Code::Digit6, Modifiers::COMMAND), Some(Shortcut::Go(Route::Podcasts)));
|
||||||
|
assert_eq!(press(ch("7"), Code::Digit7, Modifiers::COMMAND), None);
|
||||||
assert_eq!(press(ch(","), Code::Comma, Modifiers::COMMAND), Some(Shortcut::Go(Route::Settings)));
|
assert_eq!(press(ch(","), Code::Comma, Modifiers::COMMAND), Some(Shortcut::Go(Route::Settings)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ impl Config {
|
|||||||
"wave" => Route::Wave,
|
"wave" => Route::Wave,
|
||||||
"search" => Route::Search,
|
"search" => Route::Search,
|
||||||
"collection" => Route::Collection,
|
"collection" => Route::Collection,
|
||||||
|
"server" => Route::Server,
|
||||||
"podcasts" => Route::Podcasts,
|
"podcasts" => Route::Podcasts,
|
||||||
"settings" => Route::Settings,
|
"settings" => Route::Settings,
|
||||||
"album" => Route::Album(1),
|
"album" => Route::Album(1),
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ icons! {
|
|||||||
Wave => "audio-lines",
|
Wave => "audio-lines",
|
||||||
Search => "search",
|
Search => "search",
|
||||||
Library => "library",
|
Library => "library",
|
||||||
|
Server => "server",
|
||||||
Podcast => "podcast",
|
Podcast => "podcast",
|
||||||
Plus => "plus",
|
Plus => "plus",
|
||||||
LogOut => "log-out",
|
LogOut => "log-out",
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use ym_api::{AlbumSummary, ArtistSummary, PlaylistId, PlaylistSummary, Track};
|
|||||||
|
|
||||||
use crate::app::Message;
|
use crate::app::Message;
|
||||||
use crate::i18n::{tr, trf};
|
use crate::i18n::{tr, trf};
|
||||||
use crate::route::Route;
|
use crate::route::{Route, Sid};
|
||||||
use crate::ui::icons::{Icon, icon};
|
use crate::ui::icons::{Icon, icon};
|
||||||
use crate::ui::line;
|
use crate::ui::line;
|
||||||
use crate::ui::theme::{self, Tokens, radius, size};
|
use crate::ui::theme::{self, Tokens, radius, size};
|
||||||
@@ -138,6 +138,9 @@ pub fn groups(target: &Target, ctx: &Ctx<'_>) -> Vec<Vec<Entry>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn track_groups(track: &Track, from: Source, ctx: &Ctx<'_>) -> Vec<Vec<Entry>> {
|
fn track_groups(track: &Track, from: Source, ctx: &Ctx<'_>) -> Vec<Vec<Entry>> {
|
||||||
|
if let Some(song) = track.subsonic() {
|
||||||
|
return server_track_groups(track, song, from, ctx);
|
||||||
|
}
|
||||||
let playable = |e: Entry| if track.available { e } else { Entry { action: Action::Disabled, ..e } };
|
let playable = |e: Entry| if track.available { e } else { Entry { action: Action::Disabled, ..e } };
|
||||||
let queue_group = match from {
|
let queue_group = match from {
|
||||||
Source::Queue { pos } => vec![
|
Source::Queue { pos } => vec![
|
||||||
@@ -193,6 +196,37 @@ fn track_groups(track: &Track, from: Source, ctx: &Ctx<'_>) -> Vec<Vec<Entry>> {
|
|||||||
groups
|
groups
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A song from the music server: queueing and its album and artist there.
|
||||||
|
/// Likes, playlists and recommendations are Yandex's and don't apply.
|
||||||
|
fn server_track_groups(track: &Track, song: &ym_api::SubsonicSong, from: Source, ctx: &Ctx<'_>) -> Vec<Vec<Entry>> {
|
||||||
|
let queue_group = match from {
|
||||||
|
Source::Queue { pos } => vec![
|
||||||
|
entry(Icon::Play, tr("Play now"), Message::Player(crate::player::Msg::JumpTo(pos))),
|
||||||
|
entry(Icon::Next, tr("Play next"), Message::PlayNext(track.clone())),
|
||||||
|
entry(Icon::Close, tr("Remove from queue"), Message::Player(crate::player::Msg::Remove { pos, id: track.id.clone() })),
|
||||||
|
],
|
||||||
|
_ => vec![
|
||||||
|
if ctx.playing {
|
||||||
|
entry(Icon::Next, tr("Next track"), Message::SkipFromMenu)
|
||||||
|
} else {
|
||||||
|
entry(Icon::Next, tr("Play next"), Message::PlayNext(track.clone()))
|
||||||
|
},
|
||||||
|
entry(Icon::Queue, tr("Add to queue"), Message::AddToQueue(track.clone())),
|
||||||
|
],
|
||||||
|
};
|
||||||
|
let mut go = Vec::new();
|
||||||
|
if let Some(album) = &song.album_id {
|
||||||
|
go.push(entry(Icon::Disc, tr("Go to album"), Message::Navigate(Route::ServerAlbum(Sid::of(album)))));
|
||||||
|
}
|
||||||
|
if let (Some(artist), Some(name)) = (&song.artist_id, track.artists.first()) {
|
||||||
|
let label = trf("Go to {}", &[&shorten(&name.name)]);
|
||||||
|
go.push(entry(Icon::Artist, label, Message::Navigate(Route::ServerArtist(Sid::of(artist)))));
|
||||||
|
}
|
||||||
|
let mut groups = vec![queue_group, go];
|
||||||
|
groups.retain(|g| !g.is_empty());
|
||||||
|
groups
|
||||||
|
}
|
||||||
|
|
||||||
fn play_group(route: Route) -> Vec<Entry> {
|
fn play_group(route: Route) -> Vec<Entry> {
|
||||||
vec![
|
vec![
|
||||||
entry(Icon::Play, tr("Play"), Message::PlayRoute { route, shuffle: false }),
|
entry(Icon::Play, tr("Play"), Message::PlayRoute { route, shuffle: false }),
|
||||||
@@ -466,6 +500,24 @@ mod tests {
|
|||||||
groups(&Target::Track { track: track(r#","available":false"#), from: Source::List { playlist: None } }, &ctx())
|
groups(&Target::Track { track: track(r#","available":false"#), from: Source::List { playlist: None } }, &ctx())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn server_tracks_only_queue_and_link_to_their_server_pages() {
|
||||||
|
let song = ym_api::SubsonicSong {
|
||||||
|
song_id: "s1".into(),
|
||||||
|
album_id: Some("al1".into()),
|
||||||
|
album_title: Some("A".into()),
|
||||||
|
artist_id: Some("ar1".into()),
|
||||||
|
cover_art: None,
|
||||||
|
suffix: "mp3".into(),
|
||||||
|
bit_rate: 320,
|
||||||
|
};
|
||||||
|
let t = Track::from_subsonic("T".into(), Some("Kino".into()), std::time::Duration::from_secs(60), song);
|
||||||
|
let groups = groups(&Target::Track { track: t, from: Source::List { playlist: None } }, &ctx());
|
||||||
|
assert_eq!(labels(&groups), [vec!["Play next", "Add to queue"], vec!["Go to album", "Go to Kino"]]);
|
||||||
|
assert!(matches!(&groups[1][0].action,
|
||||||
|
Action::Send(m) if matches!(&**m, Message::Navigate(Route::ServerAlbum(sid)) if *sid == Sid::of("al1"))));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn long_artist_names_are_shortened_and_at_most_three_listed() {
|
fn long_artist_names_are_shortened_and_at_most_three_listed() {
|
||||||
let names: Vec<String> = (0..5).map(|i| format!(r#"{{"id":{i},"name":"Очень длинное имя исполнителя номер {i}"}}"#)).collect();
|
let names: Vec<String> = (0..5).map(|i| format!(r#"{{"id":{i},"name":"Очень длинное имя исполнителя номер {i}"}}"#)).collect();
|
||||||
|
|||||||
@@ -113,8 +113,8 @@ fn info<'a>(
|
|||||||
info = info
|
info = info
|
||||||
.push(text(track.full_title()).font(theme::DISPLAY).size(size::DISPLAY_M).color(t.fg).line_height(1.2))
|
.push(text(track.full_title()).font(theme::DISPLAY).size(size::DISPLAY_M).color(t.fg).line_height(1.2))
|
||||||
.push(line(track.artist_line(), theme::SEMIBOLD, size::SECTION, t.fg));
|
.push(line(track.artist_line(), theme::SEMIBOLD, size::SECTION, t.fg));
|
||||||
if let Some(album) = track.album.as_ref().filter(|a| !a.title.is_empty()) {
|
if let Some(album) = track.album_title() {
|
||||||
info = info.push(line(album.title.as_str(), theme::BODY, size::BODY, t.muted));
|
info = info.push(line(album, theme::BODY, size::BODY, t.muted));
|
||||||
}
|
}
|
||||||
if let Some(notice) = &p.notice
|
if let Some(notice) = &p.notice
|
||||||
&& matches!(p.status(), Status::Loading | Status::Paused)
|
&& matches!(p.status(), Status::Loading | Status::Paused)
|
||||||
@@ -207,13 +207,13 @@ fn controls<'a>(
|
|||||||
.spacing(10)
|
.spacing(10)
|
||||||
.align_y(Alignment::Center);
|
.align_y(Alignment::Center);
|
||||||
|
|
||||||
let heart = button(icon(
|
// Only Yandex tracks can be liked.
|
||||||
if liked { Icon::HeartFilled } else { Icon::Heart },
|
let heart = track.is_yandex().then(|| {
|
||||||
if liked { t.like } else { t.muted },
|
button(icon(if liked { Icon::HeartFilled } else { Icon::Heart }, if liked { t.like } else { t.muted }))
|
||||||
))
|
|
||||||
.padding(8)
|
.padding(8)
|
||||||
.style(theme::icon_button(None))
|
.style(theme::icon_button(None))
|
||||||
.on_press(Message::LikeTrack(track.clone(), !liked));
|
.on_press(Message::LikeTrack(track.clone(), !liked))
|
||||||
|
});
|
||||||
|
|
||||||
// The anchor takes the click and reports where the button is, so the menu hangs under it.
|
// The anchor takes the click and reports where the button is, so the menu hangs under it.
|
||||||
let target = Target::Track { track: track.clone(), from: Source::PlayerBar };
|
let target = Target::Track { track: track.clone(), from: Source::PlayerBar };
|
||||||
@@ -238,22 +238,23 @@ fn controls<'a>(
|
|||||||
};
|
};
|
||||||
|
|
||||||
let volume = if p.muted { 0.0 } else { p.volume };
|
let volume = if p.muted { 0.0 } else { p.volume };
|
||||||
row![
|
row![transport, space().width(Fill)]
|
||||||
transport,
|
.push(heart)
|
||||||
space().width(Fill),
|
.push(more)
|
||||||
heart,
|
.push(pill(Icon::Queue, Panel::Queue, tr("Queue")))
|
||||||
more,
|
.push(pill(Icon::Lyrics, Panel::Lyrics, tr("Lyrics")))
|
||||||
pill(Icon::Queue, Panel::Queue, tr("Queue")),
|
.push(
|
||||||
pill(Icon::Lyrics, Panel::Lyrics, tr("Lyrics")),
|
|
||||||
button(icon(if p.muted { Icon::Muted } else { Icon::Volume }, t.muted))
|
button(icon(if p.muted { Icon::Muted } else { Icon::Volume }, t.muted))
|
||||||
.padding(8)
|
.padding(8)
|
||||||
.style(theme::icon_button(None))
|
.style(theme::icon_button(None))
|
||||||
.on_press(send(Msg::ToggleMute)),
|
.on_press(send(Msg::ToggleMute)),
|
||||||
|
)
|
||||||
|
.push(
|
||||||
slider(0.0..=1.0, volume, |v| Message::Player(Msg::SetVolume(v)))
|
slider(0.0..=1.0, volume, |v| Message::Player(Msg::SetVolume(v)))
|
||||||
.step(0.01_f32)
|
.step(0.01_f32)
|
||||||
.width(if narrow { 72 } else { 110 })
|
.width(if narrow { 72 } else { 110 })
|
||||||
.style(theme::volume_bar),
|
.style(theme::volume_bar),
|
||||||
]
|
)
|
||||||
.spacing(8)
|
.spacing(8)
|
||||||
.align_y(Alignment::Center)
|
.align_y(Alignment::Center)
|
||||||
.into()
|
.into()
|
||||||
|
|||||||
@@ -88,20 +88,21 @@ fn now_playing<'a>(t: &'static Tokens, p: &'a Player, liked: bool, covers: &Cove
|
|||||||
.on_press(|_| Message::ShowNowPlaying(true))
|
.on_press(|_| Message::ShowNowPlaying(true))
|
||||||
.on_right_press(move |at| Message::OpenMenu(Box::new(Menu::new(target.clone(), Anchor::Point(at)))));
|
.on_right_press(move |at| Message::OpenMenu(Box::new(Menu::new(target.clone(), Anchor::Point(at)))));
|
||||||
|
|
||||||
row![
|
// Likes and dislikes are Yandex's; tracks from the music server have neither.
|
||||||
about,
|
let yandex = track.is_yandex();
|
||||||
button(icon(
|
row![about]
|
||||||
if liked { Icon::HeartFilled } else { Icon::Heart },
|
.push(yandex.then(|| {
|
||||||
if liked { t.like } else { t.muted },
|
button(icon(if liked { Icon::HeartFilled } else { Icon::Heart }, if liked { t.like } else { t.muted }))
|
||||||
))
|
|
||||||
.padding(8)
|
.padding(8)
|
||||||
.style(theme::icon_button(None))
|
.style(theme::icon_button(None))
|
||||||
.on_press(Message::LikeTrack(track.clone(), !liked)),
|
.on_press(Message::LikeTrack(track.clone(), !liked))
|
||||||
|
}))
|
||||||
|
.push(yandex.then(|| {
|
||||||
button(icon(Icon::Dislike, t.muted))
|
button(icon(Icon::Dislike, t.muted))
|
||||||
.padding(8)
|
.padding(8)
|
||||||
.style(theme::icon_button(None))
|
.style(theme::icon_button(None))
|
||||||
.on_press(Message::DislikeTrack(track.clone(), true)),
|
.on_press(Message::DislikeTrack(track.clone(), true))
|
||||||
]
|
}))
|
||||||
.spacing(12)
|
.spacing(12)
|
||||||
.align_y(Alignment::Center)
|
.align_y(Alignment::Center)
|
||||||
.clip(true)
|
.clip(true)
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ impl Columns {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const GRIP: f32 = 20.0;
|
const GRIP: f32 = 20.0;
|
||||||
|
/// The heart button's width: an icon and its padding.
|
||||||
|
const LIKE_SLOT: f32 = theme::shell::ICON + 16.0;
|
||||||
|
|
||||||
pub struct Row<'a> {
|
pub struct Row<'a> {
|
||||||
pub index: usize,
|
pub index: usize,
|
||||||
@@ -102,7 +104,7 @@ pub fn view(t: &'static Tokens, r: Row<'_>) -> Element<'static, Message> {
|
|||||||
if r.columns.album {
|
if r.columns.album {
|
||||||
content = content.push(
|
content = content.push(
|
||||||
container(line(
|
container(line(
|
||||||
track.album.as_ref().map(|a| a.title.clone()).unwrap_or_default(),
|
track.album_title().unwrap_or_default().to_owned(),
|
||||||
theme::BODY,
|
theme::BODY,
|
||||||
size::META,
|
size::META,
|
||||||
t.muted,
|
t.muted,
|
||||||
@@ -111,16 +113,21 @@ pub fn view(t: &'static Tokens, r: Row<'_>) -> Element<'static, Message> {
|
|||||||
.clip(true),
|
.clip(true),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
content = content
|
// Server tracks can't be liked; an empty slot keeps the columns lined up.
|
||||||
.push(
|
let heart: Element<'static, Message> = if track.is_yandex() {
|
||||||
button(icon(
|
button(icon(
|
||||||
if r.liked { Icon::HeartFilled } else { Icon::Heart },
|
if r.liked { Icon::HeartFilled } else { Icon::Heart },
|
||||||
if r.liked { t.like } else { t.muted.scale_alpha(0.35) },
|
if r.liked { t.like } else { t.muted.scale_alpha(0.35) },
|
||||||
))
|
))
|
||||||
.padding(8)
|
.padding(8)
|
||||||
.style(theme::icon_button(None))
|
.style(theme::icon_button(None))
|
||||||
.on_press(r.on_like),
|
.on_press(r.on_like)
|
||||||
)
|
.into()
|
||||||
|
} else {
|
||||||
|
space().width(LIKE_SLOT).into()
|
||||||
|
};
|
||||||
|
content = content
|
||||||
|
.push(heart)
|
||||||
.push(
|
.push(
|
||||||
container(line(clock(track.duration.as_secs_f32()), theme::BODY, size::META, t.muted))
|
container(line(clock(track.duration.as_secs_f32()), theme::BODY, size::META, t.muted))
|
||||||
.width(52)
|
.width(52)
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
[package]
|
||||||
|
name = "subsonic-api"
|
||||||
|
description = "Client for Subsonic-compatible music servers such as Navidrome"
|
||||||
|
version.workspace = true
|
||||||
|
edition.workspace = true
|
||||||
|
license.workspace = true
|
||||||
|
publish.workspace = true
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls"] }
|
||||||
|
serde = { version = "1", features = ["derive"] }
|
||||||
|
serde_json = "1"
|
||||||
|
thiserror = "2"
|
||||||
|
md-5 = "0.10"
|
||||||
|
rand = "0.9"
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
@@ -0,0 +1,584 @@
|
|||||||
|
//! Requests, authentication and the `subsonic-response` envelope.
|
||||||
|
|
||||||
|
use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
||||||
|
|
||||||
|
use md5::{Digest, Md5};
|
||||||
|
use rand::Rng;
|
||||||
|
use rand::distr::Alphanumeric;
|
||||||
|
use reqwest::Url;
|
||||||
|
use serde::de::DeserializeOwned;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use crate::models::{
|
||||||
|
self, Album, AlbumSummary, Artist, ArtistSummary, Playlist, PlaylistSummary, RawAlbum, RawArtist,
|
||||||
|
RawIndex, RawMixed, RawPlaylist, SearchResults, Song,
|
||||||
|
};
|
||||||
|
use crate::{Error, Result};
|
||||||
|
|
||||||
|
/// The REST version Musyx speaks. 1.13 added token auth; 1.16.1 is what Navidrome reports.
|
||||||
|
const API_VERSION: &str = "1.16.1";
|
||||||
|
const CLIENT_NAME: &str = "musyx";
|
||||||
|
const API_TIMEOUT: Duration = Duration::from_secs(30);
|
||||||
|
/// Whole files are downloaded before playback; a long FLAC on a slow link takes a while.
|
||||||
|
const STREAM_TIMEOUT: Duration = Duration::from_secs(300);
|
||||||
|
|
||||||
|
/// What the user types to connect. Stored in the system keychain as JSON.
|
||||||
|
#[derive(Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
|
pub struct Config {
|
||||||
|
pub url: String,
|
||||||
|
pub username: String,
|
||||||
|
pub password: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The password stays out of logs.
|
||||||
|
impl std::fmt::Debug for Config {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
f.debug_struct("Config").field("url", &self.url).field("username", &self.username).finish_non_exhaustive()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Config {
|
||||||
|
/// The server's `/rest/` base. Accepts what people paste: no scheme
|
||||||
|
/// (`music.example.com` means https), trailing slashes, or the web UI's
|
||||||
|
/// own address (`…/app/#/album/…`).
|
||||||
|
pub fn rest_base(&self) -> Result<Url> {
|
||||||
|
let raw = self.url.trim();
|
||||||
|
if raw.is_empty() {
|
||||||
|
return Err(Error::InvalidUrl("empty".into()));
|
||||||
|
}
|
||||||
|
let with_scheme = if raw.contains("://") { raw.to_owned() } else { format!("https://{raw}") };
|
||||||
|
let mut url = Url::parse(&with_scheme).map_err(|e| Error::InvalidUrl(e.to_string()))?;
|
||||||
|
if !matches!(url.scheme(), "http" | "https") || url.host_str().is_none() {
|
||||||
|
return Err(Error::InvalidUrl(format!("unsupported address {raw}")));
|
||||||
|
}
|
||||||
|
url.set_query(None);
|
||||||
|
url.set_fragment(None);
|
||||||
|
let mut path = format!("{}/", url.path().trim_end_matches('/'));
|
||||||
|
// Everything from a pasted API path (`/rest/ping`) or the web UI (`/app/`) on.
|
||||||
|
for marker in ["/rest/", "/app/"] {
|
||||||
|
if let Some(i) = path.find(marker) {
|
||||||
|
path.truncate(i + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let path = path.trim_end_matches('/');
|
||||||
|
url.set_path(&format!("{path}/rest/"));
|
||||||
|
Ok(url)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// How to ask for a song's audio: the file as stored, when the player decodes
|
||||||
|
/// it and it fits the quality cap, or an MP3 the server transcodes.
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
|
pub struct StreamPlan {
|
||||||
|
pub transcode: bool,
|
||||||
|
/// The cap sent as `maxBitRate`; also the label's bitrate when transcoding.
|
||||||
|
pub max_kbps: Option<u32>,
|
||||||
|
/// "mp3", "flac" or "aac-mp4", the codec names the player's decoder expects.
|
||||||
|
pub codec: &'static str,
|
||||||
|
pub bitrate_kbps: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl StreamPlan {
|
||||||
|
/// `max_kbps: None` means no cap; `lossless` lets FLAC through untouched.
|
||||||
|
pub fn for_song(suffix: &str, bit_rate: u32, max_kbps: Option<u32>, lossless: bool) -> Self {
|
||||||
|
// Unknown bitrates only pass when there's no cap to break.
|
||||||
|
let fits = max_kbps.is_none_or(|cap| bit_rate != 0 && bit_rate <= cap);
|
||||||
|
let raw = |codec, bitrate_kbps| StreamPlan { transcode: false, max_kbps: None, codec, bitrate_kbps };
|
||||||
|
match suffix {
|
||||||
|
"flac" if lossless => raw("flac", 0),
|
||||||
|
"mp3" if fits => raw("mp3", bit_rate),
|
||||||
|
"m4a" | "mp4" if fits => raw("aac-mp4", bit_rate),
|
||||||
|
_ => {
|
||||||
|
let cap = max_kbps.unwrap_or(320).min(320);
|
||||||
|
StreamPlan { transcode: true, max_kbps: Some(cap), codec: "mp3", bitrate_kbps: cap }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A downloaded song, ready for the decoder.
|
||||||
|
#[derive(Clone)]
|
||||||
|
pub struct Audio {
|
||||||
|
pub bytes: Vec<u8>,
|
||||||
|
pub codec: &'static str,
|
||||||
|
pub bitrate_kbps: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::fmt::Debug for Audio {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
f.debug_struct("Audio")
|
||||||
|
.field("codec", &self.codec)
|
||||||
|
.field("bitrate_kbps", &self.bitrate_kbps)
|
||||||
|
.field("bytes", &self.bytes.len())
|
||||||
|
.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
|
||||||
|
pub enum AlbumSort {
|
||||||
|
/// Recently added to the library.
|
||||||
|
#[default]
|
||||||
|
Newest,
|
||||||
|
AlphabeticalByName,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl AlbumSort {
|
||||||
|
fn param(self) -> &'static str {
|
||||||
|
match self {
|
||||||
|
AlbumSort::Newest => "newest",
|
||||||
|
AlbumSort::AlphabeticalByName => "alphabeticalByName",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A signed-in connection. Cheap to clone: the HTTP pool is shared.
|
||||||
|
#[derive(Clone)]
|
||||||
|
pub struct Client {
|
||||||
|
http: reqwest::Client,
|
||||||
|
base: Url,
|
||||||
|
username: String,
|
||||||
|
password: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::fmt::Debug for Client {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
f.debug_struct("Client").field("base", &self.base.as_str()).field("username", &self.username).finish_non_exhaustive()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PartialEq for Client {
|
||||||
|
fn eq(&self, other: &Self) -> bool {
|
||||||
|
self.base == other.base && self.username == other.username && self.password == other.password
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Client {
|
||||||
|
/// Builds the client; nothing is sent until the first call (see [`Client::ping`]).
|
||||||
|
pub fn new(config: &Config) -> Result<Self> {
|
||||||
|
let base = config.rest_base()?;
|
||||||
|
let http = reqwest::Client::builder()
|
||||||
|
.connect_timeout(Duration::from_secs(10))
|
||||||
|
.user_agent(concat!("musyx/", env!("CARGO_PKG_VERSION")))
|
||||||
|
.build()
|
||||||
|
.map_err(|e| Error::Network(e.to_string()))?;
|
||||||
|
Ok(Self { http, base, username: config.username.trim().to_owned(), password: config.password.clone() })
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn username(&self) -> &str {
|
||||||
|
&self.username
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `music.example.com` or `10.0.0.2:4533`, for display.
|
||||||
|
pub fn host(&self) -> String {
|
||||||
|
let host = self.base.host_str().unwrap_or_default();
|
||||||
|
match self.base.port() {
|
||||||
|
Some(port) => format!("{host}:{port}"),
|
||||||
|
None => host.to_owned(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn url(&self, method: &str, params: &[(&str, &str)]) -> Url {
|
||||||
|
let salt: String = rand::rng().sample_iter(Alphanumeric).take(12).map(char::from).collect();
|
||||||
|
self.url_with_salt(method, params, &salt)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Token auth: `t = md5(password + salt)`, so the password never travels.
|
||||||
|
fn url_with_salt(&self, method: &str, params: &[(&str, &str)], salt: &str) -> Url {
|
||||||
|
let mut url = self.base.join(method).expect("method names are plain path segments");
|
||||||
|
url.query_pairs_mut()
|
||||||
|
.append_pair("u", &self.username)
|
||||||
|
.append_pair("t", &token(&self.password, salt))
|
||||||
|
.append_pair("s", salt)
|
||||||
|
.append_pair("v", API_VERSION)
|
||||||
|
.append_pair("c", CLIENT_NAME)
|
||||||
|
.append_pair("f", "json")
|
||||||
|
.extend_pairs(params);
|
||||||
|
url
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn call<T: DeserializeOwned>(&self, method: &str, params: &[(&str, &str)]) -> Result<T> {
|
||||||
|
let body = self
|
||||||
|
.http
|
||||||
|
.get(self.url(method, params))
|
||||||
|
.timeout(API_TIMEOUT)
|
||||||
|
.send()
|
||||||
|
.await?
|
||||||
|
.error_for_status()?
|
||||||
|
.text()
|
||||||
|
.await?;
|
||||||
|
unwrap_envelope(&body)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Endpoints that answer with a file, or with an error envelope.
|
||||||
|
async fn bytes(&self, method: &str, params: &[(&str, &str)], timeout: Duration) -> Result<Vec<u8>> {
|
||||||
|
let reply = self.http.get(self.url(method, params)).timeout(timeout).send().await?.error_for_status()?;
|
||||||
|
let is_envelope = reply
|
||||||
|
.headers()
|
||||||
|
.get(reqwest::header::CONTENT_TYPE)
|
||||||
|
.and_then(|v| v.to_str().ok())
|
||||||
|
.is_some_and(|ct| ct.contains("json") || ct.contains("xml"));
|
||||||
|
let body = reply.bytes().await?;
|
||||||
|
if is_envelope {
|
||||||
|
let text = String::from_utf8_lossy(&body);
|
||||||
|
unwrap_envelope::<serde_json::Value>(&text)?;
|
||||||
|
return Err(Error::Api(format!("{method} answered with a message instead of a file")));
|
||||||
|
}
|
||||||
|
Ok(body.to_vec())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Checks the address and the credentials.
|
||||||
|
pub async fn ping(&self) -> Result<()> {
|
||||||
|
self.call::<serde_json::Value>("ping", &[]).await.map(drop)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn albums(&self, sort: AlbumSort, offset: usize, size: usize) -> Result<Vec<AlbumSummary>> {
|
||||||
|
let (offset, size) = (offset.to_string(), size.to_string());
|
||||||
|
let reply: AlbumListReply = self
|
||||||
|
.call("getAlbumList2", &[("type", sort.param()), ("offset", &offset), ("size", &size)])
|
||||||
|
.await?;
|
||||||
|
Ok(reply.resolve())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn album(&self, id: &str) -> Result<Album> {
|
||||||
|
let reply: AlbumReply = self.call("getAlbum", &[("id", id)]).await?;
|
||||||
|
reply.resolve()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn artists(&self) -> Result<Vec<ArtistSummary>> {
|
||||||
|
let reply: ArtistsReply = self.call("getArtists", &[]).await?;
|
||||||
|
Ok(reply.resolve())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn artist(&self, id: &str) -> Result<Artist> {
|
||||||
|
let reply: ArtistReply = self.call("getArtist", &[("id", id)]).await?;
|
||||||
|
reply.resolve()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn playlists(&self) -> Result<Vec<PlaylistSummary>> {
|
||||||
|
let reply: PlaylistsReply = self.call("getPlaylists", &[]).await?;
|
||||||
|
Ok(reply.resolve())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn playlist(&self, id: &str) -> Result<Playlist> {
|
||||||
|
let reply: PlaylistReply = self.call("getPlaylist", &[("id", id)]).await?;
|
||||||
|
reply.resolve()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Starred songs, newest first as the server orders them.
|
||||||
|
pub async fn starred(&self) -> Result<Vec<Song>> {
|
||||||
|
let reply: StarredReply = self.call("getStarred2", &[]).await?;
|
||||||
|
Ok(reply.starred.resolve().songs)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn search(&self, query: &str) -> Result<SearchResults> {
|
||||||
|
let reply: SearchReply = self
|
||||||
|
.call(
|
||||||
|
"search3",
|
||||||
|
&[("query", query.trim()), ("artistCount", "12"), ("albumCount", "24"), ("songCount", "60")],
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
Ok(reply.result.resolve())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Cover image bytes at about `size` pixels square.
|
||||||
|
pub async fn cover_art(&self, id: &str, size: u32) -> Result<Vec<u8>> {
|
||||||
|
self.bytes("getCoverArt", &[("id", id), ("size", &size.to_string())], API_TIMEOUT).await
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Downloads a whole song as `plan` says.
|
||||||
|
pub async fn stream(&self, song_id: &str, plan: StreamPlan) -> Result<Audio> {
|
||||||
|
let cap = plan.max_kbps.map(|k| k.to_string());
|
||||||
|
let mut params = vec![("id", song_id), ("format", if plan.transcode { "mp3" } else { "raw" })];
|
||||||
|
if let Some(cap) = &cap {
|
||||||
|
params.push(("maxBitRate", cap));
|
||||||
|
}
|
||||||
|
let bytes = self.bytes("stream", ¶ms, STREAM_TIMEOUT).await?;
|
||||||
|
if bytes.is_empty() {
|
||||||
|
return Err(Error::Api("empty stream".into()));
|
||||||
|
}
|
||||||
|
Ok(Audio { bytes, codec: plan.codec, bitrate_kbps: plan.bitrate_kbps })
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `submission: false` sets "now playing"; `true` records a play.
|
||||||
|
pub async fn scrobble(&self, song_id: &str, submission: bool) -> Result<()> {
|
||||||
|
let now = SystemTime::now().duration_since(UNIX_EPOCH).map_or(0, |d| d.as_millis()).to_string();
|
||||||
|
let mut params = vec![("id", song_id), ("submission", if submission { "true" } else { "false" })];
|
||||||
|
if submission {
|
||||||
|
params.push(("time", &now));
|
||||||
|
}
|
||||||
|
self.call::<serde_json::Value>("scrobble", ¶ms).await.map(drop)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn token(password: &str, salt: &str) -> String {
|
||||||
|
format!("{:x}", Md5::digest(format!("{password}{salt}").as_bytes()))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
struct Envelope {
|
||||||
|
#[serde(rename = "subsonic-response")]
|
||||||
|
response: serde_json::Value,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Opens `{"subsonic-response": {...}}`, turning `"status": "failed"` into an error.
|
||||||
|
fn unwrap_envelope<T: DeserializeOwned>(body: &str) -> Result<T> {
|
||||||
|
let Ok(Envelope { response }) = serde_json::from_str(body) else {
|
||||||
|
return Err(Error::Api("not a Subsonic server reply".into()));
|
||||||
|
};
|
||||||
|
if response.get("status").and_then(serde_json::Value::as_str) != Some("ok") {
|
||||||
|
let error = response.get("error");
|
||||||
|
let code = error.and_then(|e| e.get("code")).and_then(serde_json::Value::as_i64).unwrap_or(0);
|
||||||
|
let message =
|
||||||
|
error.and_then(|e| e.get("message")).and_then(serde_json::Value::as_str).unwrap_or("failed").to_owned();
|
||||||
|
return Err(Error::from_code(code, message));
|
||||||
|
}
|
||||||
|
serde_json::from_value(response).map_err(|e| Error::Api(e.to_string()))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Deserialize)]
|
||||||
|
#[serde(default)]
|
||||||
|
struct AlbumList {
|
||||||
|
album: Vec<RawAlbum>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
struct AlbumListReply {
|
||||||
|
#[serde(rename = "albumList2", default)]
|
||||||
|
list: AlbumList,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl AlbumListReply {
|
||||||
|
fn resolve(self) -> Vec<AlbumSummary> {
|
||||||
|
models::albums(self.list.album)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
struct AlbumReply {
|
||||||
|
album: RawAlbum,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl AlbumReply {
|
||||||
|
fn resolve(self) -> Result<Album> {
|
||||||
|
self.album.resolve().ok_or_else(|| Error::Api("album without id".into()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Deserialize)]
|
||||||
|
#[serde(default)]
|
||||||
|
struct ArtistIndex {
|
||||||
|
index: Vec<RawIndex>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
struct ArtistsReply {
|
||||||
|
#[serde(default)]
|
||||||
|
artists: ArtistIndex,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ArtistsReply {
|
||||||
|
fn resolve(self) -> Vec<ArtistSummary> {
|
||||||
|
models::artists(self.artists.index.into_iter().flat_map(|i| i.artist).collect())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
struct ArtistReply {
|
||||||
|
artist: RawArtist,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ArtistReply {
|
||||||
|
fn resolve(self) -> Result<Artist> {
|
||||||
|
self.artist.resolve().ok_or_else(|| Error::Api("artist without id".into()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Deserialize)]
|
||||||
|
#[serde(default)]
|
||||||
|
struct PlaylistList {
|
||||||
|
playlist: Vec<RawPlaylist>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
struct PlaylistsReply {
|
||||||
|
#[serde(default)]
|
||||||
|
playlists: PlaylistList,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PlaylistsReply {
|
||||||
|
fn resolve(self) -> Vec<PlaylistSummary> {
|
||||||
|
models::playlists(self.playlists.playlist)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
struct PlaylistReply {
|
||||||
|
playlist: RawPlaylist,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PlaylistReply {
|
||||||
|
fn resolve(self) -> Result<Playlist> {
|
||||||
|
self.playlist.resolve().ok_or_else(|| Error::Api("playlist without id".into()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
struct StarredReply {
|
||||||
|
#[serde(rename = "starred2", default)]
|
||||||
|
starred: RawMixed,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
struct SearchReply {
|
||||||
|
#[serde(rename = "searchResult3", default)]
|
||||||
|
result: RawMixed,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
fn config(url: &str) -> Config {
|
||||||
|
Config { url: url.into(), username: "yp".into(), password: "sesame".into() }
|
||||||
|
}
|
||||||
|
|
||||||
|
fn ok(body: &str) -> String {
|
||||||
|
format!(r#"{{"subsonic-response":{{"status":"ok","version":"1.16.1",{body}}}}}"#)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn token_matches_the_subsonic_docs_example() {
|
||||||
|
assert_eq!(token("sesame", "c19b2d"), "26719a1196d2a940705a59634eb18eab");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn urls_carry_a_token_never_the_password() {
|
||||||
|
let client = Client::new(&config("https://music.example.com")).unwrap();
|
||||||
|
let url = client.url_with_salt("getAlbum", &[("id", "al 1")], "c19b2d");
|
||||||
|
assert_eq!(
|
||||||
|
url.as_str(),
|
||||||
|
"https://music.example.com/rest/getAlbum?u=yp&t=26719a1196d2a940705a59634eb18eab&s=c19b2d&v=1.16.1&c=musyx&f=json&id=al+1"
|
||||||
|
);
|
||||||
|
let fresh = client.url("ping", &[]);
|
||||||
|
assert!(!fresh.as_str().contains("sesame"));
|
||||||
|
assert!(!format!("{client:?}{:?}", config("x")).contains("sesame"), "password leaked into Debug");
|
||||||
|
assert_ne!(client.url("ping", &[]), fresh, "every request gets a new salt");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn pasted_addresses_become_rest_bases() {
|
||||||
|
let base = |u: &str| config(u).rest_base().map(|u| u.to_string());
|
||||||
|
assert_eq!(base("music.example.com/").unwrap(), "https://music.example.com/rest/");
|
||||||
|
assert_eq!(base(" http://10.0.0.2:4533 ").unwrap(), "http://10.0.0.2:4533/rest/");
|
||||||
|
assert_eq!(base("https://example.com/music/app/#/album/1").unwrap(), "https://example.com/music/rest/");
|
||||||
|
assert_eq!(base("https://example.com/rest/ping?u=x").unwrap(), "https://example.com/rest/");
|
||||||
|
assert!(matches!(base(""), Err(Error::InvalidUrl(_))));
|
||||||
|
assert!(matches!(base("ftp://example.com"), Err(Error::InvalidUrl(_))));
|
||||||
|
let client = Client::new(&config("http://10.0.0.2:4533")).unwrap();
|
||||||
|
assert_eq!(client.host(), "10.0.0.2:4533");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn failed_envelopes_become_errors() {
|
||||||
|
let failed = r#"{"subsonic-response":{"status":"failed","version":"1.16.1",
|
||||||
|
"error":{"code":40,"message":"Wrong username or password"}}}"#;
|
||||||
|
assert_eq!(
|
||||||
|
unwrap_envelope::<serde_json::Value>(failed),
|
||||||
|
Err(Error::Unauthorized("Wrong username or password".into()))
|
||||||
|
);
|
||||||
|
assert!(matches!(unwrap_envelope::<serde_json::Value>("<html>Nginx</html>"), Err(Error::Api(_))));
|
||||||
|
assert!(unwrap_envelope::<serde_json::Value>(&ok(r#""type":"navidrome""#)).is_ok());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn album_lists_and_albums_parse() {
|
||||||
|
let list: AlbumListReply = unwrap_envelope(&ok(
|
||||||
|
r#""albumList2":{"album":[{"id":"a1","name":"One","artist":"X","coverArt":"al-a1","songCount":2},
|
||||||
|
{"id":"a2","name":"Two"}]}"#,
|
||||||
|
))
|
||||||
|
.unwrap();
|
||||||
|
let list = list.resolve();
|
||||||
|
assert_eq!(list.iter().map(|a| a.id.as_str()).collect::<Vec<_>>(), ["a1", "a2"]);
|
||||||
|
assert_eq!(list[0].cover_art.as_deref(), Some("al-a1"));
|
||||||
|
let empty: AlbumListReply = unwrap_envelope(&ok(r#""albumList2":{}"#)).unwrap();
|
||||||
|
assert!(empty.resolve().is_empty(), "Navidrome omits empty arrays");
|
||||||
|
|
||||||
|
let album: AlbumReply = unwrap_envelope(&ok(
|
||||||
|
r#""album":{"id":"a1","name":"One","artist":"X","artistId":"ar1","year":2001,"duration":400,
|
||||||
|
"song":[{"id":"s1","title":"First","track":1,"duration":200,"suffix":"mp3","bitRate":320},
|
||||||
|
{"id":"s2","title":"Second","track":2,"duration":200,"suffix":"opus"}]}"#,
|
||||||
|
))
|
||||||
|
.unwrap();
|
||||||
|
let album = album.resolve().unwrap();
|
||||||
|
assert_eq!(album.info.subtitle(), "X · 2001");
|
||||||
|
assert_eq!(album.songs.len(), 2);
|
||||||
|
assert_eq!(album.songs[1].suffix, "opus");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn artists_flatten_the_index_and_artist_pages_list_albums() {
|
||||||
|
let artists: ArtistsReply = unwrap_envelope(&ok(
|
||||||
|
r#""artists":{"ignoredArticles":"The","index":[
|
||||||
|
{"name":"A","artist":[{"id":"ar1","name":"Aquarium","albumCount":3,"coverArt":"ar-ar1"}]},
|
||||||
|
{"name":"K","artist":[{"id":"ar2","name":"Kino"}]}]}"#,
|
||||||
|
))
|
||||||
|
.unwrap();
|
||||||
|
let artists = artists.resolve();
|
||||||
|
assert_eq!(artists.iter().map(|a| a.name.as_str()).collect::<Vec<_>>(), ["Aquarium", "Kino"]);
|
||||||
|
assert_eq!(artists[0].album_count, 3);
|
||||||
|
|
||||||
|
let artist: ArtistReply = unwrap_envelope(&ok(
|
||||||
|
r#""artist":{"id":"ar2","name":"Kino","album":[{"id":"a1","name":"45"},{"id":"a2","name":"Nachalnik Kamchatki"}]}"#,
|
||||||
|
))
|
||||||
|
.unwrap();
|
||||||
|
let artist = artist.resolve().unwrap();
|
||||||
|
assert_eq!(artist.info.name, "Kino");
|
||||||
|
assert_eq!(artist.albums.len(), 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn playlists_starred_and_search_parse() {
|
||||||
|
let lists: PlaylistsReply = unwrap_envelope(&ok(
|
||||||
|
r#""playlists":{"playlist":[{"id":"p1","name":"Road","owner":"yp","songCount":12,"duration":3000}]}"#,
|
||||||
|
))
|
||||||
|
.unwrap();
|
||||||
|
let lists = lists.resolve();
|
||||||
|
assert_eq!((lists[0].name.as_str(), lists[0].song_count), ("Road", 12));
|
||||||
|
|
||||||
|
let list: PlaylistReply = unwrap_envelope(&ok(
|
||||||
|
r#""playlist":{"id":"p1","name":"Road","entry":[{"id":"s1","title":"A"},{"id":"s2","title":"B"}]}"#,
|
||||||
|
))
|
||||||
|
.unwrap();
|
||||||
|
assert_eq!(list.resolve().unwrap().songs.len(), 2);
|
||||||
|
|
||||||
|
let starred: StarredReply =
|
||||||
|
unwrap_envelope(&ok(r#""starred2":{"song":[{"id":"s9","title":"Fav","starred":"2026-01-01T00:00:00Z"}]}"#))
|
||||||
|
.unwrap();
|
||||||
|
assert_eq!(starred.starred.resolve().songs[0].id, "s9");
|
||||||
|
|
||||||
|
let found: SearchReply = unwrap_envelope(&ok(
|
||||||
|
r#""searchResult3":{"artist":[{"id":"ar1","name":"Kino"}],"song":[{"id":"s1","title":"Kukushka"}]}"#,
|
||||||
|
))
|
||||||
|
.unwrap();
|
||||||
|
let found = found.result.resolve();
|
||||||
|
assert_eq!((found.artists.len(), found.albums.len(), found.songs.len()), (1, 0, 1));
|
||||||
|
let nothing: SearchReply = unwrap_envelope(&ok(r#""searchResult3":{}"#)).unwrap();
|
||||||
|
assert!(nothing.result.resolve().is_empty());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn stream_plans_keep_files_the_player_decodes_within_the_cap() {
|
||||||
|
let plan = StreamPlan::for_song;
|
||||||
|
assert_eq!(plan("mp3", 320, None, false), StreamPlan { transcode: false, max_kbps: None, codec: "mp3", bitrate_kbps: 320 });
|
||||||
|
assert_eq!(plan("m4a", 256, None, false).codec, "aac-mp4");
|
||||||
|
assert_eq!(plan("flac", 1000, None, true), StreamPlan { transcode: false, max_kbps: None, codec: "flac", bitrate_kbps: 0 });
|
||||||
|
// FLAC without the Lossless setting, formats the player can't decode, and
|
||||||
|
// files over the cap all become server-side MP3s.
|
||||||
|
assert_eq!(plan("flac", 1000, None, false), StreamPlan { transcode: true, max_kbps: Some(320), codec: "mp3", bitrate_kbps: 320 });
|
||||||
|
assert_eq!(plan("opus", 128, None, true).max_kbps, Some(320));
|
||||||
|
assert_eq!(plan("ogg", 160, Some(128), false).max_kbps, Some(128));
|
||||||
|
assert_eq!(plan("mp3", 320, Some(192), false), StreamPlan { transcode: true, max_kbps: Some(192), codec: "mp3", bitrate_kbps: 192 });
|
||||||
|
assert!(!plan("mp3", 128, Some(192), false).transcode);
|
||||||
|
assert!(plan("mp3", 0, Some(192), false).transcode, "unknown bitrate under a cap");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
/// Errors the app can act on. Messages are for logs, not for display.
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
|
||||||
|
pub enum Error {
|
||||||
|
/// Wrong username or password, or the server refuses token sign-in.
|
||||||
|
#[error("unauthorized: {0}")]
|
||||||
|
Unauthorized(String),
|
||||||
|
/// The address isn't a usable http(s) URL.
|
||||||
|
#[error("invalid server address: {0}")]
|
||||||
|
InvalidUrl(String),
|
||||||
|
/// The album, artist or playlist doesn't exist (any more).
|
||||||
|
#[error("not found: {0}")]
|
||||||
|
NotFound(String),
|
||||||
|
/// No connection, DNS failure, timeout: worth retrying.
|
||||||
|
#[error("network: {0}")]
|
||||||
|
Network(String),
|
||||||
|
/// Anything else the server rejected, or a reply that isn't Subsonic.
|
||||||
|
#[error("api: {0}")]
|
||||||
|
Api(String),
|
||||||
|
}
|
||||||
|
|
||||||
|
pub type Result<T> = std::result::Result<T, Error>;
|
||||||
|
|
||||||
|
impl Error {
|
||||||
|
/// Subsonic error codes: 40 wrong credentials, 41 token auth unsupported
|
||||||
|
/// (LDAP users), 70 not found.
|
||||||
|
pub(crate) fn from_code(code: i64, message: String) -> Self {
|
||||||
|
match code {
|
||||||
|
40 | 41 => Error::Unauthorized(message),
|
||||||
|
70 => Error::NotFound(message),
|
||||||
|
_ => Error::Api(format!("{code}: {message}")),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<reqwest::Error> for Error {
|
||||||
|
fn from(e: reqwest::Error) -> Self {
|
||||||
|
if e.is_decode() {
|
||||||
|
Error::Api(e.to_string())
|
||||||
|
} else if e.status() == Some(reqwest::StatusCode::UNAUTHORIZED) {
|
||||||
|
Error::Unauthorized(e.to_string())
|
||||||
|
} else if e.status() == Some(reqwest::StatusCode::NOT_FOUND) {
|
||||||
|
// Usually a wrong address: the host answers, but has no /rest.
|
||||||
|
Error::Api(e.to_string())
|
||||||
|
} else {
|
||||||
|
Error::Network(e.to_string())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn subsonic_codes_map_to_actionable_errors() {
|
||||||
|
assert!(matches!(Error::from_code(40, "Wrong username or password".into()), Error::Unauthorized(_)));
|
||||||
|
assert!(matches!(Error::from_code(41, String::new()), Error::Unauthorized(_)));
|
||||||
|
assert!(matches!(Error::from_code(70, "Album not found".into()), Error::NotFound(_)));
|
||||||
|
assert_eq!(Error::from_code(0, "boom".into()), Error::Api("0: boom".into()));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
//! Client for Subsonic-compatible music servers (Navidrome, Gonic, Airsonic).
|
||||||
|
//!
|
||||||
|
//! Like `ym-api`, it hands the app its own resolved types and keeps the wire
|
||||||
|
//! format, authentication and error codes in here.
|
||||||
|
|
||||||
|
mod client;
|
||||||
|
mod error;
|
||||||
|
mod models;
|
||||||
|
|
||||||
|
pub use client::{AlbumSort, Audio, Client, Config, StreamPlan};
|
||||||
|
pub use error::{Error, Result};
|
||||||
|
pub use models::{
|
||||||
|
Album, AlbumSummary, Artist, ArtistSummary, Playlist, PlaylistSummary, SearchResults, Song,
|
||||||
|
};
|
||||||
@@ -0,0 +1,348 @@
|
|||||||
|
//! The app-facing shapes of Subsonic objects, converted from the wire format
|
||||||
|
//! with every `Option` the UI doesn't care about resolved here.
|
||||||
|
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
|
use serde::Deserialize;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
|
pub struct Song {
|
||||||
|
pub id: String,
|
||||||
|
pub title: String,
|
||||||
|
pub artist: Option<String>,
|
||||||
|
pub artist_id: Option<String>,
|
||||||
|
pub album: Option<String>,
|
||||||
|
pub album_id: Option<String>,
|
||||||
|
pub duration: Duration,
|
||||||
|
pub track: Option<u32>,
|
||||||
|
pub disc: Option<u32>,
|
||||||
|
/// Id for `getCoverArt`.
|
||||||
|
pub cover_art: Option<String>,
|
||||||
|
/// File extension on the server: "mp3", "flac", "m4a", "opus"…
|
||||||
|
pub suffix: String,
|
||||||
|
/// Kbps of the stored file; 0 when the server doesn't say.
|
||||||
|
pub bit_rate: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
|
pub struct AlbumSummary {
|
||||||
|
pub id: String,
|
||||||
|
pub name: String,
|
||||||
|
pub artist: Option<String>,
|
||||||
|
pub artist_id: Option<String>,
|
||||||
|
pub cover_art: Option<String>,
|
||||||
|
pub song_count: u32,
|
||||||
|
pub duration: Duration,
|
||||||
|
pub year: Option<u32>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl AlbumSummary {
|
||||||
|
/// "Artist · 2019", or whichever half is known.
|
||||||
|
pub fn subtitle(&self) -> String {
|
||||||
|
match (&self.artist, self.year) {
|
||||||
|
(Some(a), Some(y)) => format!("{a} · {y}"),
|
||||||
|
(Some(a), None) => a.clone(),
|
||||||
|
(None, Some(y)) => y.to_string(),
|
||||||
|
(None, None) => String::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
|
pub struct Album {
|
||||||
|
pub info: AlbumSummary,
|
||||||
|
pub songs: Vec<Song>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
|
pub struct ArtistSummary {
|
||||||
|
pub id: String,
|
||||||
|
pub name: String,
|
||||||
|
pub cover_art: Option<String>,
|
||||||
|
pub album_count: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
|
pub struct Artist {
|
||||||
|
pub info: ArtistSummary,
|
||||||
|
pub albums: Vec<AlbumSummary>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
|
pub struct PlaylistSummary {
|
||||||
|
pub id: String,
|
||||||
|
pub name: String,
|
||||||
|
pub owner: Option<String>,
|
||||||
|
pub cover_art: Option<String>,
|
||||||
|
pub song_count: u32,
|
||||||
|
pub duration: Duration,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
|
pub struct Playlist {
|
||||||
|
pub info: PlaylistSummary,
|
||||||
|
pub songs: Vec<Song>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Default, PartialEq, Eq)]
|
||||||
|
pub struct SearchResults {
|
||||||
|
pub artists: Vec<ArtistSummary>,
|
||||||
|
pub albums: Vec<AlbumSummary>,
|
||||||
|
pub songs: Vec<Song>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl SearchResults {
|
||||||
|
pub fn is_empty(&self) -> bool {
|
||||||
|
self.artists.is_empty() && self.albums.is_empty() && self.songs.is_empty()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- Wire format ----------------------------------------------------------
|
||||||
|
|
||||||
|
/// Ids are strings in Navidrome, numbers in some older servers.
|
||||||
|
#[derive(Debug, Deserialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub(crate) enum Id {
|
||||||
|
Text(String),
|
||||||
|
Number(i64),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Id {
|
||||||
|
fn into_string(self) -> Option<String> {
|
||||||
|
match self {
|
||||||
|
Id::Text(s) if s.is_empty() => None,
|
||||||
|
Id::Text(s) => Some(s),
|
||||||
|
Id::Number(n) => Some(n.to_string()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn id(raw: Option<Id>) -> Option<String> {
|
||||||
|
raw.and_then(Id::into_string)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn non_empty(s: Option<String>) -> Option<String> {
|
||||||
|
s.filter(|s| !s.trim().is_empty())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn count(n: Option<i64>) -> u32 {
|
||||||
|
n.unwrap_or(0).clamp(0, i64::from(u32::MAX)) as u32
|
||||||
|
}
|
||||||
|
|
||||||
|
fn secs(n: Option<i64>) -> Duration {
|
||||||
|
Duration::from_secs(n.unwrap_or(0).max(0) as u64)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Default, Deserialize)]
|
||||||
|
#[serde(rename_all = "camelCase", default)]
|
||||||
|
pub(crate) struct RawSong {
|
||||||
|
id: Option<Id>,
|
||||||
|
title: Option<String>,
|
||||||
|
artist: Option<String>,
|
||||||
|
artist_id: Option<Id>,
|
||||||
|
album: Option<String>,
|
||||||
|
album_id: Option<Id>,
|
||||||
|
duration: Option<i64>,
|
||||||
|
track: Option<i64>,
|
||||||
|
disc_number: Option<i64>,
|
||||||
|
cover_art: Option<Id>,
|
||||||
|
suffix: Option<String>,
|
||||||
|
bit_rate: Option<i64>,
|
||||||
|
is_dir: Option<bool>,
|
||||||
|
is_video: Option<bool>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RawSong {
|
||||||
|
pub(crate) fn resolve(self) -> Option<Song> {
|
||||||
|
if self.is_dir == Some(true) || self.is_video == Some(true) {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
let positive = |n: Option<i64>| n.filter(|&n| n > 0).map(|n| n as u32);
|
||||||
|
Some(Song {
|
||||||
|
id: id(self.id)?,
|
||||||
|
title: non_empty(self.title).unwrap_or_else(|| "Untitled".into()),
|
||||||
|
artist: non_empty(self.artist),
|
||||||
|
artist_id: id(self.artist_id),
|
||||||
|
album: non_empty(self.album),
|
||||||
|
album_id: id(self.album_id),
|
||||||
|
duration: secs(self.duration),
|
||||||
|
track: positive(self.track),
|
||||||
|
disc: positive(self.disc_number),
|
||||||
|
cover_art: id(self.cover_art),
|
||||||
|
suffix: self.suffix.unwrap_or_default().to_ascii_lowercase(),
|
||||||
|
bit_rate: count(self.bit_rate),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn songs(raw: Vec<RawSong>) -> Vec<Song> {
|
||||||
|
raw.into_iter().filter_map(RawSong::resolve).collect()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Default, Deserialize)]
|
||||||
|
#[serde(rename_all = "camelCase", default)]
|
||||||
|
pub(crate) struct RawAlbum {
|
||||||
|
id: Option<Id>,
|
||||||
|
name: Option<String>,
|
||||||
|
/// Older servers send `title` instead of `name`.
|
||||||
|
title: Option<String>,
|
||||||
|
artist: Option<String>,
|
||||||
|
artist_id: Option<Id>,
|
||||||
|
cover_art: Option<Id>,
|
||||||
|
song_count: Option<i64>,
|
||||||
|
duration: Option<i64>,
|
||||||
|
year: Option<i64>,
|
||||||
|
pub(crate) song: Vec<RawSong>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RawAlbum {
|
||||||
|
pub(crate) fn summary(&mut self) -> Option<AlbumSummary> {
|
||||||
|
Some(AlbumSummary {
|
||||||
|
id: id(self.id.take())?,
|
||||||
|
name: non_empty(self.name.take().or(self.title.take())).unwrap_or_else(|| "Untitled".into()),
|
||||||
|
artist: non_empty(self.artist.take()),
|
||||||
|
artist_id: id(self.artist_id.take()),
|
||||||
|
cover_art: id(self.cover_art.take()),
|
||||||
|
song_count: count(self.song_count),
|
||||||
|
duration: secs(self.duration),
|
||||||
|
year: self.year.filter(|&y| y > 0).map(|y| y as u32),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn resolve(mut self) -> Option<Album> {
|
||||||
|
let info = self.summary()?;
|
||||||
|
Some(Album { info, songs: songs(self.song) })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn albums(raw: Vec<RawAlbum>) -> Vec<AlbumSummary> {
|
||||||
|
raw.into_iter().filter_map(|mut a| a.summary()).collect()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Default, Deserialize)]
|
||||||
|
#[serde(rename_all = "camelCase", default)]
|
||||||
|
pub(crate) struct RawArtist {
|
||||||
|
id: Option<Id>,
|
||||||
|
name: Option<String>,
|
||||||
|
cover_art: Option<Id>,
|
||||||
|
album_count: Option<i64>,
|
||||||
|
pub(crate) album: Vec<RawAlbum>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RawArtist {
|
||||||
|
pub(crate) fn summary(&mut self) -> Option<ArtistSummary> {
|
||||||
|
Some(ArtistSummary {
|
||||||
|
id: id(self.id.take())?,
|
||||||
|
name: non_empty(self.name.take()).unwrap_or_else(|| "Unknown artist".into()),
|
||||||
|
cover_art: id(self.cover_art.take()),
|
||||||
|
album_count: count(self.album_count),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn resolve(mut self) -> Option<Artist> {
|
||||||
|
let info = self.summary()?;
|
||||||
|
Some(Artist { info, albums: albums(self.album) })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn artists(raw: Vec<RawArtist>) -> Vec<ArtistSummary> {
|
||||||
|
raw.into_iter().filter_map(|mut a| a.summary()).collect()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Default, Deserialize)]
|
||||||
|
#[serde(rename_all = "camelCase", default)]
|
||||||
|
pub(crate) struct RawPlaylist {
|
||||||
|
id: Option<Id>,
|
||||||
|
name: Option<String>,
|
||||||
|
owner: Option<String>,
|
||||||
|
cover_art: Option<Id>,
|
||||||
|
song_count: Option<i64>,
|
||||||
|
duration: Option<i64>,
|
||||||
|
pub(crate) entry: Vec<RawSong>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RawPlaylist {
|
||||||
|
pub(crate) fn summary(&mut self) -> Option<PlaylistSummary> {
|
||||||
|
Some(PlaylistSummary {
|
||||||
|
id: id(self.id.take())?,
|
||||||
|
name: non_empty(self.name.take()).unwrap_or_else(|| "Untitled".into()),
|
||||||
|
owner: non_empty(self.owner.take()),
|
||||||
|
cover_art: id(self.cover_art.take()),
|
||||||
|
song_count: count(self.song_count),
|
||||||
|
duration: secs(self.duration),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn resolve(mut self) -> Option<Playlist> {
|
||||||
|
let info = self.summary()?;
|
||||||
|
Some(Playlist { info, songs: songs(self.entry) })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn playlists(raw: Vec<RawPlaylist>) -> Vec<PlaylistSummary> {
|
||||||
|
raw.into_iter().filter_map(|mut p| p.summary()).collect()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `search3` and `getStarred2` share this shape.
|
||||||
|
#[derive(Debug, Default, Deserialize)]
|
||||||
|
#[serde(default)]
|
||||||
|
pub(crate) struct RawMixed {
|
||||||
|
artist: Vec<RawArtist>,
|
||||||
|
album: Vec<RawAlbum>,
|
||||||
|
song: Vec<RawSong>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RawMixed {
|
||||||
|
pub(crate) fn resolve(self) -> SearchResults {
|
||||||
|
SearchResults { artists: artists(self.artist), albums: albums(self.album), songs: songs(self.song) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Default, Deserialize)]
|
||||||
|
#[serde(default)]
|
||||||
|
pub(crate) struct RawIndex {
|
||||||
|
pub(crate) artist: Vec<RawArtist>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn songs_resolve_and_skip_folders_and_videos() {
|
||||||
|
let raw: Vec<RawSong> = serde_json::from_str(
|
||||||
|
r#"[{"id":"s1","title":"Kukushka","artist":"Kino","artistId":"ar1","album":"Chorny Albom",
|
||||||
|
"albumId":"al1","duration":402,"track":3,"discNumber":1,"coverArt":"al-al1",
|
||||||
|
"suffix":"FLAC","bitRate":1011},
|
||||||
|
{"id":"d1","title":"Folder","isDir":true},
|
||||||
|
{"id":"v1","title":"Clip","isVideo":true},
|
||||||
|
{"id":7,"title":"","suffix":"mp3","track":0},
|
||||||
|
{"title":"no id"}]"#,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
let s = songs(raw);
|
||||||
|
assert_eq!(s.len(), 2);
|
||||||
|
assert_eq!(s[0].id, "s1");
|
||||||
|
assert_eq!(s[0].duration, Duration::from_secs(402));
|
||||||
|
assert_eq!((s[0].track, s[0].disc), (Some(3), Some(1)));
|
||||||
|
assert_eq!(s[0].suffix, "flac", "suffix is lowercased");
|
||||||
|
assert_eq!(s[0].cover_art.as_deref(), Some("al-al1"));
|
||||||
|
assert_eq!(s[1].id, "7", "numeric ids become strings");
|
||||||
|
assert_eq!(s[1].title, "Untitled");
|
||||||
|
assert_eq!(s[1].track, None);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn albums_take_name_or_title_and_build_subtitles() {
|
||||||
|
let mut a: RawAlbum =
|
||||||
|
serde_json::from_str(r#"{"id":"al1","name":"Gruppa krovi","artist":"Kino","year":1988,"songCount":11}"#)
|
||||||
|
.unwrap();
|
||||||
|
let a = a.summary().unwrap();
|
||||||
|
assert_eq!(a.subtitle(), "Kino · 1988");
|
||||||
|
assert_eq!(a.song_count, 11);
|
||||||
|
let mut old: RawAlbum = serde_json::from_str(r#"{"id":5,"title":"Old","year":0}"#).unwrap();
|
||||||
|
let old = old.summary().unwrap();
|
||||||
|
assert_eq!((old.id.as_str(), old.name.as_str(), old.year), ("5", "Old", None));
|
||||||
|
assert_eq!(old.subtitle(), "");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
//! Talks to a real server. Run with
|
||||||
|
//! `SUBSONIC_URL=… SUBSONIC_USER=… SUBSONIC_PASSWORD=… cargo test -p subsonic-api -- --ignored`.
|
||||||
|
|
||||||
|
use subsonic_api::{AlbumSort, Client, Config, StreamPlan};
|
||||||
|
|
||||||
|
fn client() -> Client {
|
||||||
|
let var = |name: &str| std::env::var(name).unwrap_or_else(|_| panic!("set {name}"));
|
||||||
|
Client::new(&Config { url: var("SUBSONIC_URL"), username: var("SUBSONIC_USER"), password: var("SUBSONIC_PASSWORD") })
|
||||||
|
.expect("server address")
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
#[ignore = "network"]
|
||||||
|
async fn browses_and_streams_the_first_album() {
|
||||||
|
let client = client();
|
||||||
|
client.ping().await.expect("ping");
|
||||||
|
let albums = client.albums(AlbumSort::Newest, 0, 5).await.expect("albums");
|
||||||
|
let first = albums.first().expect("the library has an album");
|
||||||
|
let album = client.album(&first.id).await.expect("album");
|
||||||
|
let song = album.songs.first().expect("the album has a song");
|
||||||
|
let plan = StreamPlan::for_song(&song.suffix, song.bit_rate, Some(128), false);
|
||||||
|
let audio = client.stream(&song.id, plan).await.expect("stream");
|
||||||
|
assert!(audio.bytes.len() > 10_000);
|
||||||
|
if let Some(cover) = &first.cover_art {
|
||||||
|
assert!(!client.cover_art(cover, 100).await.expect("cover").is_empty());
|
||||||
|
}
|
||||||
|
client.artists().await.expect("artists");
|
||||||
|
client.playlists().await.expect("playlists");
|
||||||
|
client.starred().await.expect("starred");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
#[ignore = "network"]
|
||||||
|
async fn wrong_password_is_unauthorized() {
|
||||||
|
let url = std::env::var("SUBSONIC_URL").expect("set SUBSONIC_URL");
|
||||||
|
let client = Client::new(&Config { url, username: "musyx-nobody".into(), password: "wrong".into() }).unwrap();
|
||||||
|
assert!(matches!(client.ping().await, Err(subsonic_api::Error::Unauthorized(_))));
|
||||||
|
}
|
||||||
@@ -426,11 +426,16 @@ impl YmClient {
|
|||||||
.unwrap_or_default())
|
.unwrap_or_default())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// `settings3` takes JSON only: yamuse's form body gets `415 unsupported-media-type`.
|
||||||
pub async fn set_wave_settings(&self, station: &str, settings: WaveSettings) -> Result<()> {
|
pub async fn set_wave_settings(&self, station: &str, settings: WaveSettings) -> Result<()> {
|
||||||
let (mood, diversity, language) = settings.to_yamuse();
|
let (mood, diversity, language) = settings.to_yamuse();
|
||||||
self.inner
|
let body = serde_json::json!({
|
||||||
.rotor_set_station_settings(station, mood, diversity, language, yamuse::StationType::Rotor)
|
"moodEnergy": mood.as_str(),
|
||||||
.await?;
|
"diversity": diversity.as_str(),
|
||||||
|
"language": language.as_str(),
|
||||||
|
"type": yamuse::StationType::Rotor.as_str(),
|
||||||
|
});
|
||||||
|
self.post_json(&format!("/rotor/station/{station}/settings3"), &body).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -696,9 +701,12 @@ impl YmClient {
|
|||||||
// ---- Lyrics ----
|
// ---- Lyrics ----
|
||||||
|
|
||||||
/// Synced lyrics when Yandex has them, else plain text, else whatever LRCLIB
|
/// Synced lyrics when Yandex has them, else plain text, else whatever LRCLIB
|
||||||
/// has; `None` when neither has any.
|
/// has; `None` when neither has any. Non-Yandex tracks go straight to LRCLIB.
|
||||||
pub async fn lyrics(&self, track: &Track) -> Result<Option<Lyrics>> {
|
pub async fn lyrics(&self, track: &Track) -> Result<Option<Lyrics>> {
|
||||||
if let Some(lyrics) = self.yandex_lyrics(&track.id).await? {
|
// Tracks from other libraries have no Yandex id to ask about.
|
||||||
|
if track.is_yandex()
|
||||||
|
&& let Some(lyrics) = self.yandex_lyrics(&track.id).await?
|
||||||
|
{
|
||||||
return Ok(Some(lyrics));
|
return Ok(Some(lyrics));
|
||||||
}
|
}
|
||||||
crate::lrclib::lyrics(self.inner.transport().http(), track).await
|
crate::lrclib::lyrics(self.inner.transport().http(), track).await
|
||||||
|
|||||||
@@ -20,7 +20,10 @@ pub use library::{
|
|||||||
AlbumKind, AlbumPage, AlbumSummary, ArtistPage, ArtistSummary, LibraryPlaylists, PlaylistId,
|
AlbumKind, AlbumPage, AlbumSummary, ArtistPage, ArtistSummary, LibraryPlaylists, PlaylistId,
|
||||||
PlaylistPage, PlaylistSummary,
|
PlaylistPage, PlaylistSummary,
|
||||||
};
|
};
|
||||||
pub use models::{AlbumRef, ArtistRef, Stream, Track};
|
pub use models::{
|
||||||
|
AlbumRef, ArtistRef, SUBSONIC_COVER_PREFIX, Source, Stream, SubsonicSong, Track, hash_str, hues_for,
|
||||||
|
parse_subsonic_cover, subsonic_cover_url,
|
||||||
|
};
|
||||||
pub use wave::{
|
pub use wave::{
|
||||||
Character, Language, MY_WAVE, Mood, PlayReport, Station, WaveBatch, WaveEvent, WaveSettings,
|
Character, Language, MY_WAVE, Mood, PlayReport, Station, WaveBatch, WaveEvent, WaveSettings,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -55,14 +55,14 @@ pub(crate) async fn lyrics(http: &reqwest::Client, track: &Track) -> Result<Opti
|
|||||||
let Some(artist) = track.artists.first().map(|a| a.name.as_str()) else { return Ok(None) };
|
let Some(artist) = track.artists.first().map(|a| a.name.as_str()) else { return Ok(None) };
|
||||||
let secs = track.duration.as_secs_f64();
|
let secs = track.duration.as_secs_f64();
|
||||||
|
|
||||||
if let Some(album) = &track.album
|
if let Some(album) = track.album_title()
|
||||||
&& secs > 0.0
|
&& secs > 0.0
|
||||||
{
|
{
|
||||||
let duration = secs.round().to_string();
|
let duration = secs.round().to_string();
|
||||||
let query = [
|
let query = [
|
||||||
("track_name", track.title.as_str()),
|
("track_name", track.title.as_str()),
|
||||||
("artist_name", artist),
|
("artist_name", artist),
|
||||||
("album_name", album.title.as_str()),
|
("album_name", album),
|
||||||
("duration", duration.as_str()),
|
("duration", duration.as_str()),
|
||||||
];
|
];
|
||||||
if let Some(record) = get::<Record>(http, "get", &query).await?
|
if let Some(record) = get::<Record>(http, "get", &query).await?
|
||||||
|
|||||||
+139
-6
@@ -31,6 +31,48 @@ pub struct Track {
|
|||||||
pub available: bool,
|
pub available: bool,
|
||||||
pub explicit: bool,
|
pub explicit: bool,
|
||||||
pub lyrics_available: bool,
|
pub lyrics_available: bool,
|
||||||
|
/// Where the audio and cover come from.
|
||||||
|
pub source: Source,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Where a track lives. Yandex tracks come from this crate; the app builds
|
||||||
|
/// others from another library and plays them through that library's client.
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq, Default)]
|
||||||
|
pub enum Source {
|
||||||
|
#[default]
|
||||||
|
Yandex,
|
||||||
|
/// A song on a Subsonic-compatible server, such as Navidrome.
|
||||||
|
Subsonic(Box<SubsonicSong>),
|
||||||
|
}
|
||||||
|
|
||||||
|
/// What the app needs to stream a server song and link to its album and artist.
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
|
pub struct SubsonicSong {
|
||||||
|
pub song_id: String,
|
||||||
|
pub album_id: Option<String>,
|
||||||
|
pub album_title: Option<String>,
|
||||||
|
pub artist_id: Option<String>,
|
||||||
|
/// Id for the server's `getCoverArt`.
|
||||||
|
pub cover_art: Option<String>,
|
||||||
|
/// File extension on the server: "mp3", "flac", "opus"…
|
||||||
|
pub suffix: String,
|
||||||
|
pub bit_rate: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Cover URLs of server songs: `subsonic://cover/{id}?size={n}`. They carry no
|
||||||
|
/// credentials, so they're safe as cache keys; the app resolves them itself.
|
||||||
|
pub const SUBSONIC_COVER_PREFIX: &str = "subsonic://cover/";
|
||||||
|
|
||||||
|
/// The cover id and size in a [`SUBSONIC_COVER_PREFIX`] URL.
|
||||||
|
pub fn parse_subsonic_cover(url: &str) -> Option<(&str, u32)> {
|
||||||
|
let rest = url.strip_prefix(SUBSONIC_COVER_PREFIX)?;
|
||||||
|
let (id, size) = rest.split_once("?size=")?;
|
||||||
|
Some((id, size.parse().ok()?)).filter(|(id, _)| !id.is_empty())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A [`SUBSONIC_COVER_PREFIX`] URL for cover `id` at `size` pixels.
|
||||||
|
pub fn subsonic_cover_url(id: &str, size: u32) -> String {
|
||||||
|
format!("{SUBSONIC_COVER_PREFIX}{id}?size={size}")
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Track {
|
impl Track {
|
||||||
@@ -66,9 +108,48 @@ impl Track {
|
|||||||
Some(i) => i.has_available_sync_lyrics.unwrap_or(false) || i.has_available_text_lyrics.unwrap_or(false),
|
Some(i) => i.has_available_sync_lyrics.unwrap_or(false) || i.has_available_text_lyrics.unwrap_or(false),
|
||||||
None => t.lyrics_available.unwrap_or(false),
|
None => t.lyrics_available.unwrap_or(false),
|
||||||
},
|
},
|
||||||
|
source: Source::Yandex,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A song from a Subsonic server. Its id is `sub-{song_id}`: unique next to
|
||||||
|
/// Yandex ids and free of the `:` that [`Track::full_id`] splits on.
|
||||||
|
pub fn from_subsonic(title: String, artist: Option<String>, duration: Duration, song: SubsonicSong) -> Self {
|
||||||
|
Self {
|
||||||
|
id: format!("sub-{}", song.song_id),
|
||||||
|
title,
|
||||||
|
version: None,
|
||||||
|
artists: artist.into_iter().map(|name| ArtistRef { id: None, name }).collect(),
|
||||||
|
album: None,
|
||||||
|
duration,
|
||||||
|
cover_uri: None,
|
||||||
|
available: true,
|
||||||
|
explicit: false,
|
||||||
|
lyrics_available: false,
|
||||||
|
source: Source::Subsonic(Box::new(song)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn is_yandex(&self) -> bool {
|
||||||
|
matches!(self.source, Source::Yandex)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn subsonic(&self) -> Option<&SubsonicSong> {
|
||||||
|
match &self.source {
|
||||||
|
Source::Subsonic(song) => Some(song),
|
||||||
|
Source::Yandex => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The album's title, whichever library the track is from.
|
||||||
|
pub fn album_title(&self) -> Option<&str> {
|
||||||
|
let title = match &self.source {
|
||||||
|
Source::Yandex => self.album.as_ref().map(|a| a.title.as_str()),
|
||||||
|
Source::Subsonic(song) => song.album_title.as_deref(),
|
||||||
|
};
|
||||||
|
title.filter(|t| !t.is_empty())
|
||||||
|
}
|
||||||
|
|
||||||
/// Decodes a track from the API's JSON, e.g. a recorded fixture.
|
/// Decodes a track from the API's JSON, e.g. a recorded fixture.
|
||||||
pub fn from_json(json: &str) -> crate::Result<Self> {
|
pub fn from_json(json: &str) -> crate::Result<Self> {
|
||||||
let raw = serde_json::from_str(json).map_err(|e| crate::Error::Api(e.to_string()))?;
|
let raw = serde_json::from_str(json).map_err(|e| crate::Error::Api(e.to_string()))?;
|
||||||
@@ -98,15 +179,19 @@ impl Track {
|
|||||||
|
|
||||||
/// Absolute cover URL at `size`×`size` pixels.
|
/// Absolute cover URL at `size`×`size` pixels.
|
||||||
pub fn cover_url(&self, size: u32) -> Option<String> {
|
pub fn cover_url(&self, size: u32) -> Option<String> {
|
||||||
cover_url(self.cover_uri.as_deref(), size)
|
match &self.source {
|
||||||
|
Source::Yandex => cover_url(self.cover_uri.as_deref(), size),
|
||||||
|
Source::Subsonic(song) => song.cover_art.as_deref().map(|id| subsonic_cover_url(id, size)),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Two stable hues for placeholder art, derived from the album (or track) id.
|
/// Two stable hues for placeholder art, derived from the album (or track) id.
|
||||||
pub fn hues(&self) -> (f32, f32) {
|
pub fn hues(&self) -> (f32, f32) {
|
||||||
hues_for(self.album.as_ref().map_or_else(
|
if let Some(album) = &self.album {
|
||||||
|| self.id.bytes().fold(7u64, |h, b| h.wrapping_mul(31).wrapping_add(u64::from(b))),
|
return hues_for(album.id as u64);
|
||||||
|a| a.id as u64,
|
}
|
||||||
))
|
let seed = self.subsonic().and_then(|s| s.album_id.as_deref()).unwrap_or(&self.id);
|
||||||
|
hues_for(hash_str(seed))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,8 +201,13 @@ pub(crate) fn cover_url(uri: Option<&str>, size: u32) -> Option<String> {
|
|||||||
Some(yamuse::models::normalize_image_url(uri, &format!("{size}x{size}")))
|
Some(yamuse::models::normalize_image_url(uri, &format!("{size}x{size}")))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A stable hash of a text id, for [`hues_for`].
|
||||||
|
pub fn hash_str(s: &str) -> u64 {
|
||||||
|
s.bytes().fold(7u64, |h, b| h.wrapping_mul(31).wrapping_add(u64::from(b)))
|
||||||
|
}
|
||||||
|
|
||||||
/// Two hues for placeholder art; equal seeds give equal art.
|
/// Two hues for placeholder art; equal seeds give equal art.
|
||||||
pub(crate) fn hues_for(seed: u64) -> (f32, f32) {
|
pub fn hues_for(seed: u64) -> (f32, f32) {
|
||||||
((seed.wrapping_mul(47) % 360) as f32, (seed.wrapping_mul(131).wrapping_add(90) % 360) as f32)
|
((seed.wrapping_mul(47) % 360) as f32, (seed.wrapping_mul(131).wrapping_add(90) % 360) as f32)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -247,6 +337,49 @@ mod tests {
|
|||||||
assert!((0.0..360.0).contains(&h1) && (0.0..360.0).contains(&h2));
|
assert!((0.0..360.0).contains(&h1) && (0.0..360.0).contains(&h2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn server_song() -> Track {
|
||||||
|
Track::from_subsonic(
|
||||||
|
"Kukushka".into(),
|
||||||
|
Some("Kino".into()),
|
||||||
|
Duration::from_secs(402),
|
||||||
|
SubsonicSong {
|
||||||
|
song_id: "s1".into(),
|
||||||
|
album_id: Some("al1".into()),
|
||||||
|
album_title: Some("Chorny Albom".into()),
|
||||||
|
artist_id: Some("ar1".into()),
|
||||||
|
cover_art: Some("al-al1".into()),
|
||||||
|
suffix: "flac".into(),
|
||||||
|
bit_rate: 1000,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn server_songs_keep_their_own_ids_and_credential_free_covers() {
|
||||||
|
let t = server_song();
|
||||||
|
assert_eq!(t.id, "sub-s1");
|
||||||
|
assert_eq!(t.full_id(), "sub-s1", "no album id appended");
|
||||||
|
assert!(!t.is_yandex() && t.album.is_none() && t.artists[0].id.is_none());
|
||||||
|
assert_eq!(t.album_title(), Some("Chorny Albom"));
|
||||||
|
assert!(!t.lyrics_available);
|
||||||
|
let cover = t.cover_url(200).unwrap();
|
||||||
|
assert_eq!(cover, "subsonic://cover/al-al1?size=200");
|
||||||
|
assert_eq!(parse_subsonic_cover(&cover), Some(("al-al1", 200)));
|
||||||
|
assert_eq!(parse_subsonic_cover("https://avatars.yandex.net/x"), None);
|
||||||
|
assert_eq!(parse_subsonic_cover("subsonic://cover/?size=1"), None);
|
||||||
|
let mut other = server_song();
|
||||||
|
other.id = "sub-s2".into();
|
||||||
|
assert_eq!(t.hues(), other.hues(), "same album, same art");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn yandex_album_titles_come_from_the_album() {
|
||||||
|
let t = track(r#"{"id":1,"albums":[{"id":5,"title":"A"}]}"#);
|
||||||
|
assert!(t.is_yandex() && t.subsonic().is_none());
|
||||||
|
assert_eq!(t.album_title(), Some("A"));
|
||||||
|
assert_eq!(track(r#"{"id":1,"albums":[{"id":5,"title":""}]}"#).album_title(), None);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn best_variant_prefers_full_mp3_at_top_bitrate() {
|
fn best_variant_prefers_full_mp3_at_top_bitrate() {
|
||||||
let v: Vec<yamuse::models::DownloadInfo> = serde_json::from_str(
|
let v: Vec<yamuse::models::DownloadInfo> = serde_json::from_str(
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# Maintainer: Yuriy Panov <uriy.panov@gmail.com>
|
# Maintainer: Yuriy Panov <uriy.panov@gmail.com>
|
||||||
# Builds the checked-out commit of this repository: run `makepkg -si` in this directory.
|
# Builds the checked-out commit of this repository: run `makepkg -si` in this directory.
|
||||||
pkgname=musyx
|
pkgname=musyx
|
||||||
pkgver=0.3.0
|
pkgver=0.4.0
|
||||||
pkgrel=1
|
pkgrel=1
|
||||||
pkgdesc='Desktop player for Yandex Music (unofficial)'
|
pkgdesc='Desktop player for Yandex Music (unofficial)'
|
||||||
arch=('x86_64' 'aarch64')
|
arch=('x86_64' 'aarch64')
|
||||||
|
|||||||
@@ -23,6 +23,9 @@
|
|||||||
</categories>
|
</categories>
|
||||||
<content_rating type="oars-1.1"/>
|
<content_rating type="oars-1.1"/>
|
||||||
<releases>
|
<releases>
|
||||||
|
<release version="0.4.0" date="2026-11-16"/>
|
||||||
|
<release version="0.3.2" date="2026-10-30"/>
|
||||||
|
<release version="0.3.1" date="2026-10-26"/>
|
||||||
<release version="0.3.0" date="2026-10-22"/>
|
<release version="0.3.0" date="2026-10-22"/>
|
||||||
<release version="0.2.1" date="2026-10-18"/>
|
<release version="0.2.1" date="2026-10-18"/>
|
||||||
<release version="0.2.0" date="2026-10-16"/>
|
<release version="0.2.0" date="2026-10-16"/>
|
||||||
|
|||||||
Reference in new issue
Block a user