Skip to main content

selene_core/config/
export_config.rs

1use crate::lyrics::LyricFormat;
2
3use lunar_lib::formatter::TemplateOwned;
4use serde::{Deserialize, Serialize};
5
6#[derive(Debug, Clone, Serialize, Deserialize)]
7pub struct ExportConfig {
8    // Filesystem
9    pub file_name_format: TemplateOwned,
10    pub artist_separator: String,
11    pub alt_artist_separator: String,
12
13    pub album_data_path: Option<TemplateOwned>,
14
15    // Metadata
16    pub singles_as_albums: bool,
17    pub embed_lyrics: bool,
18    pub export_synced_lyrics_as: Option<LyricFormat>,
19    pub plain_lyrics_as_txt: bool,
20
21    pub overwrite: bool,
22}
23
24impl ExportConfig {
25    #[must_use]
26    pub fn selene_export() -> Self {
27        Self {
28            file_name_format: TemplateOwned::new("{$album>/}{$main_track_artist?UNKNOWN ARTIST} - {$title?UNKNOWN TITLE}{$feat_track_artists< (feat. >)}").unwrap(),
29            artist_separator: ", ".to_owned(),
30            alt_artist_separator: " & ".to_owned(),
31            album_data_path: Some(TemplateOwned::new("{$album}/").unwrap()),
32            embed_lyrics: true,
33            export_synced_lyrics_as: Some(LyricFormat::SeleneLrc),
34            plain_lyrics_as_txt: true,
35            singles_as_albums: false,
36            overwrite: true,
37        }
38    }
39
40    #[must_use]
41    pub fn standard_export(lyric_files: bool, embed_lyrics: bool) -> Self {
42        Self {
43            file_name_format: TemplateOwned::new("{$album>/}{$main_track_artist?UNKNOWN ARTIST} - {$title?UNKNOWN TITLE}{$feat_track_artists< (feat. >)}").unwrap(),
44            artist_separator: ", ".to_owned(),
45            alt_artist_separator: " & ".to_owned(),
46            album_data_path: Some(TemplateOwned::new("{$album}/").unwrap()),
47            embed_lyrics,
48            export_synced_lyrics_as: lyric_files.then_some(LyricFormat::Lrc { a2: false }),
49            plain_lyrics_as_txt: lyric_files,
50            singles_as_albums: false,
51            overwrite: true,
52        }
53    }
54}