diff --git a/src/id3/v2/frame/mod.rs b/src/id3/v2/frame/mod.rs index 4c9c226bd..c269aac24 100644 --- a/src/id3/v2/frame/mod.rs +++ b/src/id3/v2/frame/mod.rs @@ -20,6 +20,14 @@ use crate::id3::v2::items::popularimeter::Popularimeter; use std::convert::{TryFrom, TryInto}; use std::hash::{Hash, Hasher}; +// +// +// > The three byte language field, present in several frames, is used to describe +// > the language of the frame’s content, according to ISO-639-2 [ISO-639-2]. +// > The language should be represented in lower case. If the language is not known +// > the string “XXX” should be used. +pub(super) const UNKNOWN_LANGUAGE: [u8; 3] = *b"XXX"; + // TODO: Messy module, rough conversions /// Represents an `ID3v2` frame @@ -270,12 +278,11 @@ impl From for Option> { let value; match input.key().try_into().map(FrameID::into_owned) { Ok(id) => { - // We make the VERY bold assumption the language is English value = match (&id, input.item_value) { (FrameID::Valid(ref s), ItemValue::Text(text)) if s == "COMM" => { FrameValue::Comment(LanguageFrame { encoding: TextEncoding::UTF8, - language: *b"eng", + language: UNKNOWN_LANGUAGE, description: String::new(), content: text, }) @@ -283,7 +290,7 @@ impl From for Option> { (FrameID::Valid(ref s), ItemValue::Text(text)) if s == "USLT" => { FrameValue::UnSyncText(LanguageFrame { encoding: TextEncoding::UTF8, - language: *b"eng", + language: UNKNOWN_LANGUAGE, description: String::new(), content: text, }) @@ -383,13 +390,13 @@ impl<'a> TryFrom<&'a TagItem> for FrameRef<'a> { value: Cow::Owned(match (id, tag_item.value()) { ("COMM", ItemValue::Text(text)) => FrameValue::Comment(LanguageFrame { encoding: TextEncoding::UTF8, - language: *b"eng", + language: UNKNOWN_LANGUAGE, description: String::new(), content: text.clone(), }), ("USLT", ItemValue::Text(text)) => FrameValue::UnSyncText(LanguageFrame { encoding: TextEncoding::UTF8, - language: *b"eng", + language: UNKNOWN_LANGUAGE, description: String::new(), content: text.clone(), }), diff --git a/src/id3/v2/tag.rs b/src/id3/v2/tag.rs index 871cf7332..1ce87d0ec 100644 --- a/src/id3/v2/tag.rs +++ b/src/id3/v2/tag.rs @@ -1,6 +1,6 @@ use super::flags::ID3v2TagFlags; use super::frame::id::FrameID; -use super::frame::{Frame, FrameFlags, FrameValue}; +use super::frame::{Frame, FrameFlags, FrameValue, UNKNOWN_LANGUAGE}; use super::ID3v2Version; use crate::error::{LoftyError, Result}; use crate::id3::v2::frame::FrameRef; @@ -62,7 +62,7 @@ macro_rules! impl_accessor { /// /// * [`ItemKey::Comment`](crate::ItemKey::Comment) and [`ItemKey::Lyrics`](crate::ItemKey::Lyrics) - Unlike a normal text frame, these require a [`LanguageFrame`]. /// An attempt is made to create this information, but it may be incorrect. -/// * `language` - Assumed to be "eng" +/// * `language` - Unknown and set to "XXX" /// * `description` - Left empty, which is invalid if there are more than one of these frames. These frames can only be identified /// by their descriptions, and as such they are expected to be unique for each. /// * [`ItemKey::Unknown("WXXX" | "TXXX")`](crate::ItemKey::Unknown) - These frames are also identified by their descriptions. @@ -422,7 +422,7 @@ impl Accessor for ID3v2Tag { id: FrameID::Valid(Cow::Borrowed("COMM")), value: FrameValue::Comment(LanguageFrame { encoding: TextEncoding::UTF8, - language: *b"eng", + language: UNKNOWN_LANGUAGE, description: String::new(), content: value, }),