diff --git a/src/main.rs b/src/main.rs index 29d67d7..7dfef30 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,5 @@ mod config; +mod tag; mod ui; use crate::config::{Config, Transcode}; @@ -171,6 +172,9 @@ async fn main() -> Result<()> { async fn main_loop(ui_queue: ui::MsgQueue) -> Result<()> { let (config, conv_args) = task::spawn_blocking(|| -> Result<_> { gstreamer::init()?; + gstreamer::tags::register::(); + gstreamer::tags::register::(); + let config = config::config().context("Could not get the config")?; let conv_args = get_conversion_args(&config) diff --git a/src/tag.rs b/src/tag.rs new file mode 100644 index 0000000..b8cc15f --- /dev/null +++ b/src/tag.rs @@ -0,0 +1,45 @@ +use glib::Value; +use gstreamer::{ + tags::{merge_strings_with_comma, CustomTag}, + Tag, TagFlag, +}; + +pub struct MbArtistId; + +impl<'a> Tag<'a> for MbArtistId { + type TagType = &'a str; + + fn tag_name<'b>() -> &'b str { + "musicbrainz-artistid" + } +} + +impl CustomTag<'_> for MbArtistId { + const FLAG: TagFlag = TagFlag::Meta; + const NICK: &'static str = "artist ID"; + const DESCRIPTION: &'static str = "MusicBrainz artist ID"; + + fn merge_func(src: &Value) -> Value { + merge_strings_with_comma(src) + } +} + +pub struct MbAlbumArtistId; + +impl<'a> Tag<'a> for MbAlbumArtistId { + type TagType = &'a str; + + fn tag_name<'b>() -> &'b str { + "musicbrainz-albumartistid" + } +} + +impl CustomTag<'_> for MbAlbumArtistId { + const FLAG: TagFlag = TagFlag::Meta; + const NICK: &'static str = "album artist ID"; + const DESCRIPTION: &'static str = "MusicBrainz album artist ID"; + + fn merge_func(src: &Value) -> Value { + merge_strings_with_comma(src) + } +}