selene-core 0.8.0

selene-core is the backend for Selene, a local-first music player
Documentation
use crate::lyrics::LyricFormat;

use lunar_lib::formatter::TemplateOwned;
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ExportConfig {
    // Filesystem
    pub file_name_format: TemplateOwned,
    pub artist_separator: String,
    pub alt_artist_separator: String,

    pub album_data_path: Option<TemplateOwned>,

    // Metadata
    pub singles_as_albums: bool,
    pub embed_lyrics: bool,
    pub export_synced_lyrics_as: Option<LyricFormat>,
    pub plain_lyrics_as_txt: bool,

    pub overwrite: bool,
}

impl ExportConfig {
    #[must_use]
    pub fn selene_export() -> Self {
        Self {
            file_name_format: TemplateOwned::new("{$album>/}{$main_track_artist?UNKNOWN ARTIST} - {$title?UNKNOWN TITLE}{$feat_track_artists< (feat. >)}").unwrap(),
            artist_separator: ", ".to_owned(),
            alt_artist_separator: " & ".to_owned(),
            album_data_path: Some(TemplateOwned::new("{$album}/").unwrap()),
            embed_lyrics: true,
            export_synced_lyrics_as: Some(LyricFormat::SeleneLrc),
            plain_lyrics_as_txt: true,
            singles_as_albums: false,
            overwrite: true,
        }
    }

    #[must_use]
    pub fn standard_export(lyric_files: bool, embed_lyrics: bool) -> Self {
        Self {
            file_name_format: TemplateOwned::new("{$album>/}{$main_track_artist?UNKNOWN ARTIST} - {$title?UNKNOWN TITLE}{$feat_track_artists< (feat. >)}").unwrap(),
            artist_separator: ", ".to_owned(),
            alt_artist_separator: " & ".to_owned(),
            album_data_path: Some(TemplateOwned::new("{$album}/").unwrap()),
            embed_lyrics,
            export_synced_lyrics_as: lyric_files.then_some(LyricFormat::Lrc { a2: false }),
            plain_lyrics_as_txt: lyric_files,
            singles_as_albums: false,
            overwrite: true,
        }
    }
}