Re-organized providers and added a few
This commit is contained in:
@@ -32,6 +32,9 @@ pub struct AppConfig {
|
||||
|
||||
#[serde(default)]
|
||||
pub indexing: IndexingConfig,
|
||||
|
||||
#[serde(default)]
|
||||
pub metadata: MetadataConfig,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
@@ -94,6 +97,39 @@ pub struct IndexingConfig {
|
||||
pub concurrency: usize,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct MetadataConfig {
|
||||
/// Source for structured metadata: "musicbrainz" (default).
|
||||
#[serde(default = "default_metadata_source")]
|
||||
pub metadata_source: String,
|
||||
|
||||
/// Source for artist images: "wikipedia" (default).
|
||||
#[serde(default = "default_artist_image_source")]
|
||||
pub artist_image_source: String,
|
||||
|
||||
/// Source for artist bios: "wikipedia" (default) or "lastfm".
|
||||
#[serde(default = "default_artist_bio_source")]
|
||||
pub artist_bio_source: String,
|
||||
|
||||
/// Source for lyrics: "lrclib" (default).
|
||||
#[serde(default = "default_lyrics_source")]
|
||||
pub lyrics_source: String,
|
||||
|
||||
/// Source for cover art: "coverartarchive" (default).
|
||||
#[serde(default = "default_cover_art_source")]
|
||||
pub cover_art_source: String,
|
||||
|
||||
/// Last.fm API key for fetching artist bios. Set via SHANTY_LASTFM_API_KEY env var.
|
||||
/// Required if artist_bio_source is "lastfm".
|
||||
#[serde(skip)]
|
||||
pub lastfm_api_key: Option<String>,
|
||||
|
||||
/// fanart.tv API key for artist images/banners. Set via SHANTY_FANART_API_KEY env var.
|
||||
/// Required if artist_image_source is "fanarttv".
|
||||
#[serde(skip)]
|
||||
pub fanart_api_key: Option<String>,
|
||||
}
|
||||
|
||||
// --- Defaults ---
|
||||
|
||||
impl Default for AppConfig {
|
||||
@@ -108,6 +144,7 @@ impl Default for AppConfig {
|
||||
tagging: TaggingConfig::default(),
|
||||
download: DownloadConfig::default(),
|
||||
indexing: IndexingConfig::default(),
|
||||
metadata: MetadataConfig::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -154,6 +191,20 @@ impl Default for IndexingConfig {
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for MetadataConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
metadata_source: default_metadata_source(),
|
||||
artist_image_source: default_artist_image_source(),
|
||||
artist_bio_source: default_artist_bio_source(),
|
||||
lyrics_source: default_lyrics_source(),
|
||||
cover_art_source: default_cover_art_source(),
|
||||
lastfm_api_key: None,
|
||||
fanart_api_key: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn default_library_path() -> PathBuf {
|
||||
dirs::audio_dir().unwrap_or_else(|| PathBuf::from("~/Music"))
|
||||
}
|
||||
@@ -206,6 +257,21 @@ fn default_rate_limit_auth() -> u32 {
|
||||
fn default_concurrency() -> usize {
|
||||
4
|
||||
}
|
||||
fn default_metadata_source() -> String {
|
||||
"musicbrainz".to_string()
|
||||
}
|
||||
fn default_artist_image_source() -> String {
|
||||
"wikipedia".to_string()
|
||||
}
|
||||
fn default_artist_bio_source() -> String {
|
||||
"wikipedia".to_string()
|
||||
}
|
||||
fn default_lyrics_source() -> String {
|
||||
"lrclib".to_string()
|
||||
}
|
||||
fn default_cover_art_source() -> String {
|
||||
"coverartarchive".to_string()
|
||||
}
|
||||
fn default_cookie_refresh_hours() -> u32 {
|
||||
6
|
||||
}
|
||||
@@ -295,6 +361,12 @@ impl AppConfig {
|
||||
if let Ok(v) = std::env::var("SHANTY_WEB_BIND") {
|
||||
config.web.bind = v;
|
||||
}
|
||||
if let Ok(v) = std::env::var("SHANTY_LASTFM_API_KEY") {
|
||||
config.metadata.lastfm_api_key = Some(v);
|
||||
}
|
||||
if let Ok(v) = std::env::var("SHANTY_FANART_API_KEY") {
|
||||
config.metadata.fanart_api_key = Some(v);
|
||||
}
|
||||
config
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user