termusiclib/config/v2/server/
metadata.rs

1use serde::{Deserialize, Serialize};
2
3use crate::config::v2::server::ScanDepth;
4
5/// Settings specific for the metadata scanner & parser.
6#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
7#[serde(default)] // allow missing fields and fill them with the `..Self::default()` in this struct
8pub struct MetadataSettings {
9    /// How deep the metadata scanner should go from the root of a given directory.
10    ///
11    /// It is recommended to keep this relatively high, or at least as how deep a given music directory root can be.
12    ///
13    /// Note that the Metadata Scanner is in the background and should never block any event processing (like the TUI)
14    pub directory_scan_depth: ScanDepth,
15    /// Separators to use to split a given Artist and Album Artist into multiple.
16    ///
17    /// This is used for artists if there is no `TXX:ARTISTS`(or equivalent) tag.
18    /// This is used for album artists if there is no `TXX:ALBUMARTISTS`(or equivalent) tag.
19    ///
20    /// Note that values can contain spaces for example for `ArtistA x ArtistB`.
21    ///
22    /// After split, the Artist values are trimmed.
23    pub artist_separators: Vec<String>,
24}
25
26/// The default and most common separators used for artists.
27pub const DEFAULT_ARTIST_SEPARATORS: &[&str] =
28    &[",", ";", "&", "ft.", "feat.", "/", "|", "×", "、", " x "];
29
30impl Default for MetadataSettings {
31    fn default() -> Self {
32        Self {
33            directory_scan_depth: ScanDepth::Limited(10),
34            artist_separators: DEFAULT_ARTIST_SEPARATORS
35                .iter()
36                .map(ToString::to_string)
37                .collect(),
38        }
39    }
40}