feat: cover art cache, Collection tabs, and album, artist and playlist pages
- ym-api: album/artist/playlist summaries and pages, liked albums and artists, own and liked playlists (batch-resolved from like ids), playlist tracks with missing ones looked up, image download - Cover cache: fetched when a cover nears the viewport (sensor), at most eight at once, kept in memory and on disk; arrivals are batched every 150 ms so cached lists rebuild once per batch - Collection tabs for liked tracks, albums, artists and playlists, each loading on first visit with a retry on failure - Album, Artist and Playlist routes with cover headers, Play/Shuffle and track lists; pages cached per session; sidebar lists playlists - Shared lazy track list keyed on contents, playing track, likes and cover version; card grid that wraps
This commit is contained in:
1 parent
b73af1f870
commit
3b934df8cc
22 files changed
+1773
-247
No files matched your search
@@ -1,6 +1,10 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::auth::Credentials;
|
||||
use crate::library::{
|
||||
AlbumPage, AlbumSummary, ArtistPage, ArtistSummary, LibraryPlaylists, PlaylistId, PlaylistPage,
|
||||
PlaylistSummary,
|
||||
};
|
||||
use crate::models::{Stream, Track, best_variant};
|
||||
use crate::{Error, Result};
|
||||
|
||||
@@ -118,6 +122,102 @@ impl YmClient {
|
||||
Ok(bytes.into())
|
||||
}
|
||||
|
||||
/// Albums the user liked, newest first, with full details.
|
||||
pub async fn liked_albums(&self) -> Result<Vec<AlbumSummary>> {
|
||||
let likes = self.inner.liked_albums(None).await?;
|
||||
let ids: Vec<i64> = likes
|
||||
.into_iter()
|
||||
.filter_map(|like| like.album.and_then(|a| a.id).or_else(|| like.id.and_then(|i| i.as_number())))
|
||||
.collect();
|
||||
if ids.is_empty() {
|
||||
return Ok(Vec::new());
|
||||
}
|
||||
let albums = self.inner.albums(&ids).await?;
|
||||
Ok(albums.into_iter().filter_map(AlbumSummary::from_yamuse).collect())
|
||||
}
|
||||
|
||||
pub async fn liked_artists(&self) -> Result<Vec<ArtistSummary>> {
|
||||
let artists = self.inner.liked_artists(None).await?;
|
||||
Ok(artists.into_iter().filter_map(ArtistSummary::from_yamuse).collect())
|
||||
}
|
||||
|
||||
/// Playlists the user owns, and ones they liked.
|
||||
pub async fn library_playlists(&self) -> Result<LibraryPlaylists> {
|
||||
let own = self.inner.user_playlists_list(None).await?;
|
||||
let likes = self.inner.liked_playlists(None).await?;
|
||||
let liked_ids: Vec<String> = likes
|
||||
.iter()
|
||||
.filter_map(|like| {
|
||||
let p = like.playlist.as_ref()?;
|
||||
let owner = p.uid.or_else(|| p.owner.as_ref().and_then(|o| o.uid))?;
|
||||
Some(format!("{owner}:{}", p.kind?))
|
||||
})
|
||||
.collect();
|
||||
let liked = if liked_ids.is_empty() {
|
||||
Vec::new()
|
||||
} else {
|
||||
self.inner.playlists_list(&liked_ids).await?
|
||||
};
|
||||
Ok(LibraryPlaylists {
|
||||
own: own.iter().filter_map(PlaylistSummary::from_yamuse).collect(),
|
||||
liked: liked.iter().filter_map(PlaylistSummary::from_yamuse).collect(),
|
||||
})
|
||||
}
|
||||
|
||||
pub async fn album(&self, id: i64) -> Result<AlbumPage> {
|
||||
let album = self.inner.album_with_tracks(id).await?;
|
||||
AlbumPage::from_yamuse(album).ok_or_else(|| Error::Api(format!("album {id} has no id")))
|
||||
}
|
||||
|
||||
pub async fn artist(&self, id: i64) -> Result<ArtistPage> {
|
||||
let brief = self.inner.artist_brief_info(id).await?;
|
||||
ArtistPage::from_yamuse(brief).ok_or_else(|| Error::Api(format!("artist {id} not found")))
|
||||
}
|
||||
|
||||
/// A playlist with all its tracks. Tracks the response didn't embed are looked up.
|
||||
pub async fn playlist(&self, id: PlaylistId) -> Result<PlaylistPage> {
|
||||
let raw = self.inner.user_playlist(id.kind, Some(id.owner)).await?;
|
||||
let playlist = PlaylistSummary::from_yamuse(&raw)
|
||||
.ok_or_else(|| Error::Api(format!("playlist {}:{} incomplete", id.owner, id.kind)))?;
|
||||
|
||||
let mut tracks: Vec<Option<Track>> = Vec::with_capacity(raw.tracks.len());
|
||||
let mut missing = Vec::new();
|
||||
for (i, short) in raw.tracks.into_iter().enumerate() {
|
||||
match short.track.and_then(Track::from_yamuse) {
|
||||
Some(track) => tracks.push(Some(track)),
|
||||
None => {
|
||||
if let Some(id) = short.id {
|
||||
let id = match id {
|
||||
yamuse::models::Id::Number(n) => n.to_string(),
|
||||
yamuse::models::Id::Text(s) => s,
|
||||
};
|
||||
missing.push((i, id));
|
||||
}
|
||||
tracks.push(None);
|
||||
}
|
||||
}
|
||||
}
|
||||
if !missing.is_empty() {
|
||||
let fetched = self.tracks(missing.iter().map(|(_, id)| id.clone()).collect()).await?;
|
||||
for ((slot, _), track) in missing.iter().zip(fetched) {
|
||||
tracks[*slot] = Some(track);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(PlaylistPage {
|
||||
playlist,
|
||||
description: raw.description.filter(|d| !d.trim().is_empty()),
|
||||
tracks: tracks.into_iter().flatten().collect(),
|
||||
})
|
||||
}
|
||||
|
||||
/// Downloads an image (covers are a few kilobytes).
|
||||
pub async fn image(&self, url: &str) -> Result<Vec<u8>> {
|
||||
Ok(yamuse::download::Downloader::new(self.inner.transport(), [url.to_owned()])
|
||||
.to_bytes()
|
||||
.await?)
|
||||
}
|
||||
|
||||
/// Re-reads the account, e.g. after a subscription may have changed.
|
||||
pub async fn account(&self) -> Result<Account> {
|
||||
let status = self.inner.refresh_account().await?;
|
||||
|
||||
@@ -6,8 +6,13 @@
|
||||
pub mod auth;
|
||||
mod client;
|
||||
mod error;
|
||||
mod library;
|
||||
mod models;
|
||||
|
||||
pub use client::{Account, YmClient};
|
||||
pub use library::{
|
||||
AlbumKind, AlbumPage, AlbumSummary, ArtistPage, ArtistSummary, LibraryPlaylists, PlaylistId,
|
||||
PlaylistPage, PlaylistSummary,
|
||||
};
|
||||
pub use models::{AlbumRef, ArtistRef, Stream, Track};
|
||||
pub use error::{Error, Result};
|
||||
@@ -0,0 +1,329 @@
|
||||
//! Albums, artists and playlists, as cards and as full pages.
|
||||
|
||||
use std::time::Duration;
|
||||
|
||||
use yamuse::models as y;
|
||||
|
||||
use crate::models::{ArtistRef, Track, cover_url, hues_for};
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum AlbumKind {
|
||||
Album,
|
||||
Single,
|
||||
Compilation,
|
||||
Podcast,
|
||||
Audiobook,
|
||||
}
|
||||
|
||||
impl AlbumKind {
|
||||
fn from_api(meta_type: Option<&str>, kind: Option<&str>) -> Self {
|
||||
match (meta_type, kind) {
|
||||
(Some("podcast"), _) | (_, Some("podcast")) => AlbumKind::Podcast,
|
||||
(_, Some("audiobook")) | (Some("audiobook"), _) => AlbumKind::Audiobook,
|
||||
(_, Some("single")) => AlbumKind::Single,
|
||||
(_, Some("compilation")) => AlbumKind::Compilation,
|
||||
_ => AlbumKind::Album,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn label(self) -> &'static str {
|
||||
match self {
|
||||
AlbumKind::Album => "Album",
|
||||
AlbumKind::Single => "Single",
|
||||
AlbumKind::Compilation => "Compilation",
|
||||
AlbumKind::Podcast => "Podcast",
|
||||
AlbumKind::Audiobook => "Audiobook",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct AlbumSummary {
|
||||
pub id: i64,
|
||||
pub title: String,
|
||||
pub version: Option<String>,
|
||||
pub artists: Vec<ArtistRef>,
|
||||
pub year: Option<i32>,
|
||||
pub track_count: u32,
|
||||
pub kind: AlbumKind,
|
||||
cover_uri: Option<String>,
|
||||
}
|
||||
|
||||
impl AlbumSummary {
|
||||
pub(crate) fn from_yamuse(a: y::Album) -> Option<Self> {
|
||||
Some(Self {
|
||||
id: a.id?,
|
||||
title: a.title.unwrap_or_else(|| "Untitled".into()),
|
||||
version: a.version.filter(|v| !v.trim().is_empty()),
|
||||
artists: artist_refs(a.artists),
|
||||
year: a.year.and_then(|y| i32::try_from(y).ok()),
|
||||
track_count: a.track_count.unwrap_or(0).max(0) as u32,
|
||||
kind: AlbumKind::from_api(a.meta_type.as_deref(), a.r#type.as_deref()),
|
||||
cover_uri: a.cover_uri.or_else(|| a.cover.and_then(|c| c.uri)),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn full_title(&self) -> String {
|
||||
match &self.version {
|
||||
Some(v) => format!("{} ({v})", self.title),
|
||||
None => self.title.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn artist_line(&self) -> String {
|
||||
join_names(&self.artists)
|
||||
}
|
||||
|
||||
/// "Кино · 1988", the line under a card.
|
||||
pub fn subtitle(&self) -> String {
|
||||
match self.year {
|
||||
Some(year) => format!("{} · {year}", self.artist_line()),
|
||||
None => self.artist_line(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn cover_url(&self, size: u32) -> Option<String> {
|
||||
cover_url(self.cover_uri.as_deref(), size)
|
||||
}
|
||||
|
||||
pub fn hues(&self) -> (f32, f32) {
|
||||
hues_for(self.id as u64)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct ArtistSummary {
|
||||
pub id: i64,
|
||||
pub name: String,
|
||||
pub genres: Vec<String>,
|
||||
pub likes: Option<i64>,
|
||||
cover_uri: Option<String>,
|
||||
}
|
||||
|
||||
impl ArtistSummary {
|
||||
pub(crate) fn from_yamuse(a: y::Artist) -> Option<Self> {
|
||||
Some(Self {
|
||||
id: a.id.and_then(|i| i.as_number())?,
|
||||
name: a.name.unwrap_or_else(|| "Unknown artist".into()),
|
||||
genres: a.genres,
|
||||
likes: a.likes_count,
|
||||
cover_uri: a.cover.and_then(|c| c.uri).or(a.og_image),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn cover_url(&self, size: u32) -> Option<String> {
|
||||
cover_url(self.cover_uri.as_deref(), size)
|
||||
}
|
||||
|
||||
pub fn hues(&self) -> (f32, f32) {
|
||||
hues_for(self.id as u64 ^ 0x5bd1_e995)
|
||||
}
|
||||
}
|
||||
|
||||
/// A playlist is addressed by its owner and a per-owner number ("kind").
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub struct PlaylistId {
|
||||
pub owner: i64,
|
||||
pub kind: i64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct PlaylistSummary {
|
||||
pub id: PlaylistId,
|
||||
pub title: String,
|
||||
pub owner_name: String,
|
||||
pub track_count: u32,
|
||||
pub duration: Duration,
|
||||
pub public: bool,
|
||||
cover_uri: Option<String>,
|
||||
}
|
||||
|
||||
impl PlaylistSummary {
|
||||
pub(crate) fn from_yamuse(p: &y::Playlist) -> Option<Self> {
|
||||
let owner = p.owner.as_ref();
|
||||
let id = PlaylistId { owner: p.uid.or_else(|| owner.and_then(|o| o.uid))?, kind: p.kind? };
|
||||
let cover = p.cover.as_ref().and_then(|c| c.uri.clone().or_else(|| c.items_uri.first().cloned()));
|
||||
Some(Self {
|
||||
id,
|
||||
title: p.title.clone().unwrap_or_else(|| "Untitled playlist".into()),
|
||||
owner_name: owner
|
||||
.and_then(|o| o.name.clone().or_else(|| o.login.clone()))
|
||||
.unwrap_or_default(),
|
||||
track_count: p.track_count.unwrap_or(0).max(0) as u32,
|
||||
duration: Duration::from_millis(p.duration_ms.unwrap_or(0).max(0) as u64),
|
||||
public: p.visibility.as_deref() == Some("public"),
|
||||
cover_uri: cover.or_else(|| p.og_image.clone()),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn cover_url(&self, size: u32) -> Option<String> {
|
||||
cover_url(self.cover_uri.as_deref(), size)
|
||||
}
|
||||
|
||||
pub fn hues(&self) -> (f32, f32) {
|
||||
hues_for((self.id.owner as u64).wrapping_mul(1_000_003) ^ self.id.kind as u64)
|
||||
}
|
||||
|
||||
pub fn subtitle(&self) -> String {
|
||||
let count = match self.track_count {
|
||||
1 => "1 track".to_owned(),
|
||||
n => format!("{n} tracks"),
|
||||
};
|
||||
if self.owner_name.is_empty() { count } else { format!("{} · {count}", self.owner_name) }
|
||||
}
|
||||
}
|
||||
|
||||
/// The user's playlists for the sidebar and Collection.
|
||||
#[derive(Debug, Clone, Default, PartialEq, Eq)]
|
||||
pub struct LibraryPlaylists {
|
||||
pub own: Vec<PlaylistSummary>,
|
||||
pub liked: Vec<PlaylistSummary>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct AlbumPage {
|
||||
pub album: AlbumSummary,
|
||||
pub tracks: Vec<Track>,
|
||||
pub release_date: Option<String>,
|
||||
pub label: Option<String>,
|
||||
pub likes: Option<i64>,
|
||||
}
|
||||
|
||||
impl AlbumPage {
|
||||
pub(crate) fn from_yamuse(a: y::Album) -> Option<Self> {
|
||||
let tracks = a
|
||||
.volumes
|
||||
.iter()
|
||||
.flatten()
|
||||
.cloned()
|
||||
.filter_map(Track::from_yamuse)
|
||||
.collect();
|
||||
let release_date = a.release_date.clone();
|
||||
let label = a.labels.first().and_then(|l| l.name()).map(str::to_owned);
|
||||
let likes = a.likes_count;
|
||||
Some(Self { album: AlbumSummary::from_yamuse(a)?, tracks, release_date, label, likes })
|
||||
}
|
||||
|
||||
pub fn duration(&self) -> Duration {
|
||||
self.tracks.iter().map(|t| t.duration).sum()
|
||||
}
|
||||
|
||||
/// Decodes an album (with `volumes`) from the API's JSON, e.g. a recorded fixture.
|
||||
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()))?;
|
||||
Self::from_yamuse(raw).ok_or_else(|| crate::Error::Api("album has no id".into()))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct ArtistPage {
|
||||
pub artist: ArtistSummary,
|
||||
pub popular: Vec<Track>,
|
||||
pub albums: Vec<AlbumSummary>,
|
||||
/// Compilations and features the artist appears on.
|
||||
pub also_albums: Vec<AlbumSummary>,
|
||||
pub similar: Vec<ArtistSummary>,
|
||||
pub monthly_listeners: Option<i64>,
|
||||
}
|
||||
|
||||
impl ArtistPage {
|
||||
pub(crate) fn from_yamuse(b: y::BriefInfo) -> Option<Self> {
|
||||
let monthly_listeners = b.stats.as_ref().and_then(|s| s.last_month_listeners);
|
||||
Some(Self {
|
||||
artist: ArtistSummary::from_yamuse(b.artist?)?,
|
||||
popular: b.popular_tracks.into_iter().filter_map(Track::from_yamuse).collect(),
|
||||
albums: b.albums.into_iter().filter_map(AlbumSummary::from_yamuse).collect(),
|
||||
also_albums: b.also_albums.into_iter().filter_map(AlbumSummary::from_yamuse).collect(),
|
||||
similar: b.similar_artists.into_iter().filter_map(ArtistSummary::from_yamuse).collect(),
|
||||
monthly_listeners,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct PlaylistPage {
|
||||
pub playlist: PlaylistSummary,
|
||||
pub description: Option<String>,
|
||||
pub tracks: Vec<Track>,
|
||||
}
|
||||
|
||||
fn artist_refs(artists: Vec<y::Artist>) -> Vec<ArtistRef> {
|
||||
artists
|
||||
.into_iter()
|
||||
.filter_map(|a| Some(ArtistRef { id: a.id.and_then(|i| i.as_number()), name: a.name? }))
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub(crate) fn join_names(artists: &[ArtistRef]) -> String {
|
||||
if artists.is_empty() {
|
||||
return "Unknown artist".into();
|
||||
}
|
||||
artists.iter().map(|a| a.name.as_str()).collect::<Vec<_>>().join(", ")
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn album(json: &str) -> y::Album {
|
||||
serde_json::from_str(json).unwrap()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn album_page_flattens_volumes() {
|
||||
let page = AlbumPage::from_yamuse(album(
|
||||
r#"{"id":5,"title":"Группа крови","year":1988,"type":"","artists":[{"id":1,"name":"Кино"}],
|
||||
"coverUri":"a/%%","labels":[{"name":"Мелодия"}],
|
||||
"volumes":[[{"id":1,"title":"A","durationMs":1000}],[{"id":2,"title":"B","durationMs":2000}]]}"#,
|
||||
))
|
||||
.unwrap();
|
||||
assert_eq!(page.tracks.len(), 2);
|
||||
assert_eq!(page.duration(), Duration::from_secs(3));
|
||||
assert_eq!(page.album.subtitle(), "Кино · 1988");
|
||||
assert_eq!(page.album.kind, AlbumKind::Album);
|
||||
assert_eq!(page.label.as_deref(), Some("Мелодия"));
|
||||
assert_eq!(page.album.cover_url(100).as_deref(), Some("https://a/100x100"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn album_kinds() {
|
||||
assert_eq!(AlbumKind::from_api(None, Some("single")), AlbumKind::Single);
|
||||
assert_eq!(AlbumKind::from_api(Some("podcast"), None), AlbumKind::Podcast);
|
||||
assert_eq!(AlbumKind::from_api(None, Some("audiobook")), AlbumKind::Audiobook);
|
||||
assert_eq!(AlbumKind::from_api(Some("music"), None), AlbumKind::Album);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn playlist_needs_owner_and_kind_and_uses_mosaic_cover() {
|
||||
let p: y::Playlist = serde_json::from_str(
|
||||
r#"{"owner":{"uid":9,"name":"Юрий"},"kind":1003,"title":"Дорога","trackCount":14,
|
||||
"visibility":"private","cover":{"type":"mosaic","itemsUri":["m/%%"]}}"#,
|
||||
)
|
||||
.unwrap();
|
||||
let s = PlaylistSummary::from_yamuse(&p).unwrap();
|
||||
assert_eq!(s.id, PlaylistId { owner: 9, kind: 1003 });
|
||||
assert!(!s.public);
|
||||
assert_eq!(s.subtitle(), "Юрий · 14 tracks");
|
||||
assert_eq!(s.cover_url(200).as_deref(), Some("https://m/200x200"));
|
||||
let orphan: y::Playlist = serde_json::from_str(r#"{"title":"x"}"#).unwrap();
|
||||
assert!(PlaylistSummary::from_yamuse(&orphan).is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn artist_page_from_brief_info() {
|
||||
let b: y::BriefInfo = serde_json::from_str(
|
||||
r#"{"artist":{"id":3,"name":"Земфира","genres":["rock"],"cover":{"uri":"z/%%"}},
|
||||
"popularTracks":[{"id":10,"title":"Хочешь?"}],
|
||||
"albums":[{"id":20,"title":"Вендетта","year":2005}],
|
||||
"similarArtists":[{"id":4,"name":"Сплин"}],
|
||||
"stats":{"lastMonthListeners":4100000}}"#,
|
||||
)
|
||||
.unwrap();
|
||||
let page = ArtistPage::from_yamuse(b).unwrap();
|
||||
assert_eq!(page.artist.name, "Земфира");
|
||||
assert_eq!(page.popular.len(), 1);
|
||||
assert_eq!(page.albums[0].year, Some(2005));
|
||||
assert_eq!(page.similar[0].name, "Сплин");
|
||||
assert_eq!(page.monthly_listeners, Some(4_100_000));
|
||||
}
|
||||
}
|
||||
@@ -72,10 +72,7 @@ impl Track {
|
||||
|
||||
/// "Artist A, Artist B", or "Unknown artist".
|
||||
pub fn artist_line(&self) -> String {
|
||||
if self.artists.is_empty() {
|
||||
return "Unknown artist".into();
|
||||
}
|
||||
self.artists.iter().map(|a| a.name.as_str()).collect::<Vec<_>>().join(", ")
|
||||
crate::library::join_names(&self.artists)
|
||||
}
|
||||
|
||||
/// Title with its version: "Song (Live)".
|
||||
@@ -88,20 +85,29 @@ impl Track {
|
||||
|
||||
/// Absolute cover URL at `size`×`size` pixels.
|
||||
pub fn cover_url(&self, size: u32) -> Option<String> {
|
||||
let uri = self.cover_uri.as_deref()?;
|
||||
Some(yamuse::models::normalize_image_url(uri, &format!("{size}x{size}")))
|
||||
cover_url(self.cover_uri.as_deref(), size)
|
||||
}
|
||||
|
||||
/// Two stable hues for placeholder art, derived from the album (or track) id.
|
||||
pub fn hues(&self) -> (f32, f32) {
|
||||
let seed = self.album.as_ref().map_or_else(
|
||||
hues_for(self.album.as_ref().map_or_else(
|
||||
|| self.id.bytes().fold(7u64, |h, b| h.wrapping_mul(31).wrapping_add(u64::from(b))),
|
||||
|a| a.id as u64,
|
||||
);
|
||||
((seed.wrapping_mul(47) % 360) as f32, (seed.wrapping_mul(131).wrapping_add(90) % 360) as f32)
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
/// Absolute URL for a `%%`-templated image uri at `size`×`size` pixels.
|
||||
pub(crate) fn cover_url(uri: Option<&str>, size: u32) -> Option<String> {
|
||||
let uri = uri.filter(|u| !u.is_empty())?;
|
||||
Some(yamuse::models::normalize_image_url(uri, &format!("{size}x{size}")))
|
||||
}
|
||||
|
||||
/// Two hues for placeholder art; equal seeds give equal art.
|
||||
pub(crate) fn hues_for(seed: u64) -> (f32, f32) {
|
||||
((seed.wrapping_mul(47) % 360) as f32, (seed.wrapping_mul(131).wrapping_add(90) % 360) as f32)
|
||||
}
|
||||
|
||||
/// Where a track's audio comes from.
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct Stream {
|
||||
|
||||
Reference in new issue
Block a user