ID3v1: Properly capitalize ID3v1Tag

This commit is contained in:
Serial 2022-06-26 11:46:47 -04:00
parent e3132d4123
commit a3e7a81c2e
No known key found for this signature in database
GPG key ID: DA95198DC17C4568
10 changed files with 31 additions and 30 deletions

View file

@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Bitrates in properties will be rounded up, similar to FFmpeg and TagLib
- **ID3v1**: Renamed `Id3v1Tag` -> `ID3v1Tag`
- **ID3v2**:
- Insert multi-value frames separately when converting to `Tag`
- E.g. An artist of "foo/bar/baz" will become 3 different `TagItem`s with `ItemKey::TrackArtist`

View file

@ -1,5 +1,5 @@
use lofty::ape::ApeTag;
use lofty::id3::v1::Id3v1Tag;
use lofty::id3::v1::ID3v1Tag;
use lofty::id3::v2::ID3v2Tag;
use lofty::iff::{AiffTextChunks, RiffInfoList};
use lofty::mp4::Ilst;
@ -25,7 +25,7 @@ macro_rules! bench_tag_write {
bench_tag_write!(aiff_text, AiffTextChunks);
bench_tag_write!(ape, ApeTag);
bench_tag_write!(id3v2, ID3v2Tag);
bench_tag_write!(id3v1, Id3v1Tag);
bench_tag_write!(id3v1, ID3v1Tag);
bench_tag_write!(ilst, Ilst);
bench_tag_write!(riff_info, RiffInfoList);
bench_tag_write!(vorbis_comments, VorbisComments);

View file

@ -14,7 +14,7 @@ pub(crate) mod write;
use crate::error::Result;
use crate::file::{AudioFile, FileType, TaggedFile};
#[cfg(feature = "id3v1")]
use crate::id3::v1::tag::Id3v1Tag;
use crate::id3::v1::tag::ID3v1Tag;
#[cfg(feature = "id3v2")]
use crate::id3::v2::tag::ID3v2Tag;
use crate::properties::FileProperties;
@ -40,7 +40,7 @@ pub use properties::ApeProperties;
pub struct ApeFile {
#[cfg(feature = "id3v1")]
/// An ID3v1 tag
pub(crate) id3v1_tag: Option<Id3v1Tag>,
pub(crate) id3v1_tag: Option<ID3v1Tag>,
#[cfg(feature = "id3v2")]
/// An ID3v2 tag (Not officially supported)
pub(crate) id3v2_tag: Option<ID3v2Tag>,
@ -117,7 +117,7 @@ impl ApeFile {
id3v2_tag, ID3v2Tag;
#[cfg(feature = "id3v1")]
id3v1_tag, Id3v1Tag;
id3v1_tag, ID3v1Tag;
#[cfg(feature = "ape")]
ape_tag, ApeTag

View file

@ -6,7 +6,7 @@ use super::{ApeFile, ApeProperties};
use crate::error::{FileDecodingError, Result};
use crate::file::FileType;
#[cfg(feature = "id3v1")]
use crate::id3::v1::tag::Id3v1Tag;
use crate::id3::v1::tag::ID3v1Tag;
#[cfg(feature = "id3v2")]
use crate::id3::v2::{read::parse_id3v2, tag::ID3v2Tag};
use crate::id3::{find_id3v1, find_id3v2, find_lyrics3v2, ID3FindResults};
@ -27,7 +27,7 @@ where
#[cfg(feature = "id3v2")]
let mut id3v2_tag: Option<ID3v2Tag> = None;
#[cfg(feature = "id3v1")]
let mut id3v1_tag: Option<Id3v1Tag> = None;
let mut id3v1_tag: Option<ID3v1Tag> = None;
#[cfg(feature = "ape")]
let mut ape_tag: Option<ApeTag> = None;

View file

@ -46,7 +46,7 @@ where
}
#[cfg(feature = "id3v1")]
pub(crate) type FindID3v1Content = Option<v1::tag::Id3v1Tag>;
pub(crate) type FindID3v1Content = Option<v1::tag::ID3v1Tag>;
#[cfg(not(feature = "id3v1"))]
pub(crate) type FindID3v1Content = Option<()>;

View file

@ -2,7 +2,7 @@
//!
//! # ID3v1 notes
//!
//! See also: [`Id3v1Tag`]
//! See also: [`ID3v1Tag`]
//!
//! ## Genres
//!
@ -21,7 +21,7 @@ cfg_if::cfg_if! {
pub use constants::GENRES;
pub(crate) mod tag;
pub use tag::Id3v1Tag;
pub use tag::ID3v1Tag;
pub(crate) mod read;
pub(crate) mod write;

View file

@ -1,8 +1,8 @@
use super::constants::GENRES;
use super::tag::Id3v1Tag;
use super::tag::ID3v1Tag;
pub fn parse_id3v1(reader: [u8; 128]) -> Id3v1Tag {
let mut tag = Id3v1Tag {
pub fn parse_id3v1(reader: [u8; 128]) -> ID3v1Tag {
let mut tag = ID3v1Tag {
title: None,
artist: None,
album: None,

View file

@ -28,7 +28,6 @@ macro_rules! impl_accessor {
}
}
#[derive(Default, Debug, PartialEq, Eq, Clone)]
/// An ID3v1 tag
///
/// ID3v1 is a severely limited format, with each field
@ -53,7 +52,8 @@ macro_rules! impl_accessor {
///
/// * [`GENRES`] contains the string
/// * The [`ItemValue`](crate::ItemValue) can be parsed into a `u8`
pub struct Id3v1Tag {
#[derive(Default, Debug, PartialEq, Eq, Clone)]
pub struct ID3v1Tag {
/// Track title, 30 bytes max
pub title: Option<String>,
/// Track artist, 30 bytes max
@ -86,7 +86,7 @@ pub struct Id3v1Tag {
pub genre: Option<u8>,
}
impl Accessor for Id3v1Tag {
impl Accessor for ID3v1Tag {
impl_accessor!(title, artist, album,);
fn genre(&self) -> Option<&str> {
@ -168,7 +168,7 @@ impl Accessor for Id3v1Tag {
}
}
impl TagExt for Id3v1Tag {
impl TagExt for ID3v1Tag {
type Err = LoftyError;
fn is_empty(&self) -> bool {
@ -211,8 +211,8 @@ impl TagExt for Id3v1Tag {
}
}
impl From<Id3v1Tag> for Tag {
fn from(input: Id3v1Tag) -> Self {
impl From<ID3v1Tag> for Tag {
fn from(input: ID3v1Tag) -> Self {
let mut tag = Self::new(TagType::ID3v1);
input.title.map(|t| tag.insert_text(ItemKey::TrackTitle, t));
@ -240,7 +240,7 @@ impl From<Id3v1Tag> for Tag {
}
}
impl From<Tag> for Id3v1Tag {
impl From<Tag> for ID3v1Tag {
fn from(input: Tag) -> Self {
Self {
title: input.get_string(&ItemKey::TrackTitle).map(str::to_owned),
@ -275,7 +275,7 @@ pub(crate) struct Id3v1TagRef<'a> {
pub genre: Option<u8>,
}
impl<'a> Into<Id3v1TagRef<'a>> for &'a Id3v1Tag {
impl<'a> Into<Id3v1TagRef<'a>> for &'a ID3v1Tag {
fn into(self) -> Id3v1TagRef<'a> {
Id3v1TagRef {
title: self.title.as_deref(),
@ -339,12 +339,12 @@ impl<'a> Id3v1TagRef<'a> {
#[cfg(test)]
mod tests {
use crate::id3::v1::Id3v1Tag;
use crate::id3::v1::ID3v1Tag;
use crate::{Tag, TagExt, TagType};
#[test]
fn parse_id3v1() {
let expected_tag = Id3v1Tag {
let expected_tag = ID3v1Tag {
title: Some(String::from("Foo title")),
artist: Some(String::from("Bar artist")),
album: Some(String::from("Baz album")),
@ -387,7 +387,7 @@ mod tests {
fn tag_to_id3v1() {
let tag = crate::tag::utils::test_utils::create_tag(TagType::ID3v1);
let id3v1_tag: Id3v1Tag = tag.into();
let id3v1_tag: ID3v1Tag = tag.into();
assert_eq!(id3v1_tag.title.as_deref(), Some("Foo title"));
assert_eq!(id3v1_tag.artist.as_deref(), Some("Bar artist"));

View file

@ -13,7 +13,7 @@ use crate::ape::tag::ApeTag;
use crate::error::Result;
use crate::file::{AudioFile, FileType, TaggedFile};
#[cfg(feature = "id3v1")]
use crate::id3::v1::tag::Id3v1Tag;
use crate::id3::v1::tag::ID3v1Tag;
#[cfg(feature = "id3v2")]
use crate::id3::v2::tag::ID3v2Tag;
use crate::properties::FileProperties;
@ -29,7 +29,7 @@ pub struct Mp3File {
pub(crate) id3v2_tag: Option<ID3v2Tag>,
#[cfg(feature = "id3v1")]
/// An ID3v1 tag
pub(crate) id3v1_tag: Option<Id3v1Tag>,
pub(crate) id3v1_tag: Option<ID3v1Tag>,
#[cfg(feature = "ape")]
/// An APEv1/v2 tag
pub(crate) ape_tag: Option<ApeTag>,
@ -102,7 +102,7 @@ impl Mp3File {
id3v2_tag, ID3v2Tag;
#[cfg(feature = "id3v1")]
id3v1_tag, Id3v1Tag;
id3v1_tag, ID3v1Tag;
#[cfg(feature = "ape")]
ape_tag, ApeTag

View file

@ -8,7 +8,7 @@ use crate::ape::tag::ApeTag;
use crate::error::Result;
use crate::file::{AudioFile, FileType, TaggedFile};
#[cfg(feature = "id3v1")]
use crate::id3::v1::tag::Id3v1Tag;
use crate::id3::v1::tag::ID3v1Tag;
use crate::properties::FileProperties;
use crate::tag::{Tag, TagType};
@ -22,7 +22,7 @@ pub use properties::WavPackProperties;
pub struct WavPackFile {
#[cfg(feature = "id3v1")]
/// An ID3v1 tag
pub(crate) id3v1_tag: Option<Id3v1Tag>,
pub(crate) id3v1_tag: Option<ID3v1Tag>,
#[cfg(feature = "ape")]
/// An APEv1/v2 tag
pub(crate) ape_tag: Option<ApeTag>,
@ -86,7 +86,7 @@ impl AudioFile for WavPackFile {
impl WavPackFile {
crate::macros::tag_methods! {
#[cfg(feature = "id3v1")]
id3v1_tag, Id3v1Tag;
id3v1_tag, ID3v1Tag;
#[cfg(feature = "ape")]
ape_tag, ApeTag