This commit is contained in:
JMARyA 2024-08-08 13:27:28 +02:00
parent d7652b8800
commit 4193b37b6b
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
2 changed files with 6 additions and 0 deletions

View file

@ -37,6 +37,9 @@ impl Album {
Track::find(doc! { "album_id": album}, None).await.unwrap()
}
/// Returns the cover image of an album, or `None` if it doesn't exist.
///
/// This method first retrieves the list of tracks in the album, then looks for a file named "cover.{ext}" where {ext} is one of png, jpg, jpeg, avif. The first existing cover file found will be returned.
pub async fn get_cover(&self) -> Option<String> {
let track_path = Self::get_tracks_of_album(&format!("album::{}", self._id))
.await

View file

@ -26,6 +26,9 @@ impl Artist {
a
}
/// Gets the image of an artist or `None` if it can't be found.
///
/// This function gets a track from the artist. It then expects the folder structure to be `Artist/Album/Track.ext` and searches for an image file named `artist` in the artist folder.
pub async fn get_image_of(id: &str) -> Option<String> {
let track_path = Track::find_one(doc! { "artist_id": reference_of!(Artist, id)})
.await?