support setting of album name with tags command
This commit is contained in:
parent
9f48d9eab5
commit
ed04740908
|
@ -22,30 +22,19 @@ pub struct FFProbeOutputFormat {
|
|||
pub tags: FFProbeOutputTags,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
#[derive(Default, Debug, Clone, Deserialize)]
|
||||
pub struct FFProbeOutputTags {
|
||||
#[serde(alias = "TRACK", alias = "track")]
|
||||
pub track_number: Option<String>,
|
||||
|
||||
#[serde(alias = "TITLE")]
|
||||
pub title: String,
|
||||
#[serde(default, alias = "ARTIST")]
|
||||
pub artist: String,
|
||||
#[serde(default, alias = "ALBUM")]
|
||||
pub album: Option<String>,
|
||||
#[serde(alias = "TRACK", alias = "track")]
|
||||
pub track_number: Option<String>,
|
||||
|
||||
#[serde(default, alias = "REPLAYGAIN_TRACK_PEAK")]
|
||||
pub replaygain_track_peak: Option<String>,
|
||||
#[serde(default, alias = "REPLAYGAIN_TRACK_GAIN")]
|
||||
pub replaygain_track_gain: Option<String>,
|
||||
}
|
||||
|
||||
impl Default for FFProbeOutputTags {
|
||||
fn default() -> Self {
|
||||
FFProbeOutputTags {
|
||||
title: "".to_string(),
|
||||
artist: "".to_string(),
|
||||
replaygain_track_peak: None,
|
||||
replaygain_track_gain: None,
|
||||
track_number: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,10 +2,11 @@ use serde::Serialize;
|
|||
|
||||
use super::ffprobe_output;
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
#[derive(Default, Debug, Clone, Serialize)]
|
||||
pub struct FFProbeTags {
|
||||
pub title: String,
|
||||
pub artist: String,
|
||||
pub album: Option<String>,
|
||||
pub replaygain_track_peak: Option<String>,
|
||||
pub replaygain_track_gain: Option<String>,
|
||||
pub track_number: Option<u64>,
|
||||
|
@ -30,6 +31,7 @@ impl From<ffprobe_output::FFProbeOutputTags> for FFProbeTags {
|
|||
FFProbeTags {
|
||||
title: val.title,
|
||||
artist: val.artist,
|
||||
album: val.album,
|
||||
replaygain_track_peak: val.replaygain_track_peak,
|
||||
replaygain_track_gain: val.replaygain_track_gain,
|
||||
track_number,
|
||||
|
|
|
@ -24,7 +24,6 @@ fn main() {
|
|||
|
||||
let bindings = bindgen::Builder::default()
|
||||
.header("src/wrapper.h")
|
||||
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
|
||||
.generate()
|
||||
.expect("Unable to generate bindings");
|
||||
|
||||
|
|
|
@ -27,6 +27,16 @@ impl Tag for TagLibTag {
|
|||
|
||||
unsafe { bindings::wrap_taglib_tag_set_artist(self.ctx, artist.as_ptr()) };
|
||||
}
|
||||
fn album(&self) -> Option<String> {
|
||||
let album_ref = unsafe { bindings::wrap_taglib_tag_album(self.ctx) };
|
||||
|
||||
c_str_to_str(album_ref)
|
||||
}
|
||||
fn set_album(&mut self, album: String) {
|
||||
let album = CString::new(album).unwrap();
|
||||
|
||||
unsafe { bindings::wrap_taglib_tag_set_album(self.ctx, album.as_ptr()) };
|
||||
}
|
||||
fn track(&self) -> Option<u64> {
|
||||
let track = unsafe { bindings::wrap_taglib_tag_track(self.ctx) };
|
||||
|
||||
|
|
|
@ -7,7 +7,10 @@ pub trait File {
|
|||
pub trait Tag {
|
||||
fn title(&self) -> Option<String>;
|
||||
fn artist(&self) -> Option<String>;
|
||||
fn album(&self) -> Option<String>;
|
||||
fn track(&self) -> Option<u64>;
|
||||
fn set_title(&mut self, title: String);
|
||||
fn set_artist(&mut self, artist: String);
|
||||
fn set_album(&mut self, album: String);
|
||||
|
||||
}
|
||||
|
|
|
@ -70,6 +70,11 @@ char* wrap_taglib_tag_artist(TagLib_Tag *tag) {
|
|||
return stringToCharArray(t->artist());
|
||||
}
|
||||
|
||||
char* wrap_taglib_tag_album(TagLib_Tag *tag) {
|
||||
const TagLib::Tag *t = reinterpret_cast<const TagLib::Tag *>(tag);
|
||||
return stringToCharArray(t->album());
|
||||
}
|
||||
|
||||
unsigned int wrap_taglib_tag_track(TagLib_Tag *tag) {
|
||||
const TagLib::Tag *t = reinterpret_cast<const TagLib::Tag *>(tag);
|
||||
return t->track();
|
||||
|
@ -85,6 +90,11 @@ void wrap_taglib_tag_set_artist(TagLib_Tag *tag, const char *artist) {
|
|||
t->setArtist(charArrayToString(artist));
|
||||
}
|
||||
|
||||
void wrap_taglib_tag_set_album(TagLib_Tag *tag, const char *album) {
|
||||
TagLib::Tag *t = reinterpret_cast<TagLib::Tag *>(tag);
|
||||
t->setAlbum(charArrayToString(album));
|
||||
}
|
||||
|
||||
void wrap_taglib_opustag_add_field(TagLib_Tag *tag, const char *key, const char *value) {
|
||||
TagLib::Ogg::XiphComment *t = reinterpret_cast<TagLib::Ogg::XiphComment *>(tag);
|
||||
t->addField(charArrayToString(key), charArrayToString(value));
|
||||
|
|
|
@ -17,9 +17,11 @@ bool wrap_taglib_file_save(TagLib_File *file);
|
|||
|
||||
char* wrap_taglib_tag_title(TagLib_Tag *tag);
|
||||
char* wrap_taglib_tag_artist(TagLib_Tag *tag);
|
||||
char* wrap_taglib_tag_album(TagLib_Tag *tag);
|
||||
unsigned int wrap_taglib_tag_track(TagLib_Tag *tag);
|
||||
void wrap_taglib_tag_set_title(TagLib_Tag *tag, const char *title);
|
||||
void wrap_taglib_tag_set_artist(TagLib_Tag *tag, const char *artist);
|
||||
void wrap_taglib_tag_set_album(TagLib_Tag *tag, const char *album);
|
||||
|
||||
void wrap_taglib_opustag_add_field(TagLib_Tag *tag, const char *key, const char *value);
|
||||
void wrap_taglib_opustag_remove_fields(TagLib_Tag *tag, const char *key);
|
||||
|
|
Loading…
Reference in a new issue