mirror of
https://github.com/Serial-ATA/lofty-rs
synced 2024-11-10 06:34:18 +00:00
Misc: Remove id3v1
feature
This commit is contained in:
parent
2fc30f3b5a
commit
75d683a7bf
15 changed files with 20 additions and 61 deletions
|
@ -30,9 +30,8 @@ once_cell = "1.16.0"
|
|||
paste = "1.0.11"
|
||||
|
||||
[features]
|
||||
default = ["ape", "id3v1", "id3v2", "aiff_text_chunks", "riff_info_list"]
|
||||
default = ["ape", "id3v2", "aiff_text_chunks", "riff_info_list"]
|
||||
ape = []
|
||||
id3v1 = []
|
||||
id3v2 = ["flate2"]
|
||||
id3v2_restrictions = []
|
||||
aiff_text_chunks = []
|
||||
|
|
|
@ -23,7 +23,6 @@ pub struct AACFile {
|
|||
#[cfg(feature = "id3v2")]
|
||||
#[lofty(tag_type = "ID3v2")]
|
||||
pub(crate) id3v2_tag: Option<ID3v2Tag>,
|
||||
#[cfg(feature = "id3v1")]
|
||||
#[lofty(tag_type = "ID3v1")]
|
||||
pub(crate) id3v1_tag: Option<ID3v1Tag>,
|
||||
pub(crate) properties: AACProperties,
|
||||
|
|
|
@ -91,7 +91,6 @@ where
|
|||
#[allow(unused_variables)]
|
||||
let ID3FindResults(header, id3v1) = find_id3v1(reader, true)?;
|
||||
|
||||
#[cfg(feature = "id3v1")]
|
||||
if header.is_some() {
|
||||
stream_len -= 128;
|
||||
file.id3v1_tag = id3v1;
|
||||
|
|
|
@ -10,7 +10,6 @@ pub(crate) mod header;
|
|||
mod properties;
|
||||
mod read;
|
||||
|
||||
#[cfg(feature = "id3v1")]
|
||||
use crate::id3::v1::tag::ID3v1Tag;
|
||||
#[cfg(feature = "id3v2")]
|
||||
use crate::id3::v2::tag::ID3v2Tag;
|
||||
|
@ -37,7 +36,6 @@ pub use properties::ApeProperties;
|
|||
#[lofty(internal_write_module_do_not_use_anywhere_else)]
|
||||
pub struct ApeFile {
|
||||
/// An ID3v1 tag
|
||||
#[cfg(feature = "id3v1")]
|
||||
#[lofty(tag_type = "ID3v1")]
|
||||
pub(crate) id3v1_tag: Option<ID3v1Tag>,
|
||||
/// An ID3v2 tag (Not officially supported)
|
||||
|
|
|
@ -4,7 +4,6 @@ use super::header::read_ape_header;
|
|||
use super::tag::{read::read_ape_tag, ApeTag};
|
||||
use super::{ApeFile, ApeProperties};
|
||||
use crate::error::Result;
|
||||
#[cfg(feature = "id3v1")]
|
||||
use crate::id3::v1::tag::ID3v1Tag;
|
||||
#[cfg(feature = "id3v2")]
|
||||
use crate::id3::v2::{read::parse_id3v2, tag::ID3v2Tag};
|
||||
|
@ -27,7 +26,6 @@ where
|
|||
|
||||
#[cfg(feature = "id3v2")]
|
||||
let mut id3v2_tag: Option<ID3v2Tag> = None;
|
||||
#[cfg(feature = "id3v1")]
|
||||
let mut id3v1_tag: Option<ID3v1Tag> = None;
|
||||
#[cfg(feature = "ape")]
|
||||
let mut ape_tag: Option<ApeTag> = None;
|
||||
|
@ -107,10 +105,7 @@ where
|
|||
|
||||
if id3v1_header.is_some() {
|
||||
stream_len -= 128;
|
||||
#[cfg(feature = "id3v1")]
|
||||
{
|
||||
id3v1_tag = id3v1;
|
||||
}
|
||||
id3v1_tag = id3v1;
|
||||
}
|
||||
|
||||
// Next, check for a Lyrics3v2 tag, and skip over it, as it's no use to us
|
||||
|
@ -150,7 +145,6 @@ where
|
|||
data.seek(SeekFrom::Start(mac_start))?;
|
||||
|
||||
Ok(ApeFile {
|
||||
#[cfg(feature = "id3v1")]
|
||||
id3v1_tag,
|
||||
#[cfg(feature = "id3v2")]
|
||||
id3v2_tag,
|
||||
|
|
|
@ -825,7 +825,6 @@ impl FileType {
|
|||
},
|
||||
#[cfg(feature = "aiff_text_chunks")]
|
||||
FileType::AIFF if tag_type == TagType::AIFFText => true,
|
||||
#[cfg(feature = "id3v1")]
|
||||
FileType::APE | FileType::MPEG | FileType::WavPack | FileType::AAC
|
||||
if tag_type == TagType::ID3v1 =>
|
||||
{
|
||||
|
|
|
@ -45,16 +45,11 @@ where
|
|||
Ok(ID3FindResults(header, size))
|
||||
}
|
||||
|
||||
#[cfg(feature = "id3v1")]
|
||||
pub(crate) type FindID3v1Content = Option<v1::tag::ID3v1Tag>;
|
||||
#[cfg(not(feature = "id3v1"))]
|
||||
pub(crate) type FindID3v1Content = Option<()>;
|
||||
|
||||
#[allow(unused_variables)]
|
||||
pub(crate) fn find_id3v1<R>(
|
||||
data: &mut R,
|
||||
read: bool,
|
||||
) -> Result<ID3FindResults<(), FindID3v1Content>>
|
||||
) -> Result<ID3FindResults<(), Option<v1::tag::ID3v1Tag>>>
|
||||
where
|
||||
R: Read + Seek,
|
||||
{
|
||||
|
@ -71,7 +66,6 @@ where
|
|||
if &id3v1_header == b"TAG" {
|
||||
header = Some(());
|
||||
|
||||
#[cfg(feature = "id3v1")]
|
||||
if read {
|
||||
let mut id3v1_tag = [0; 128];
|
||||
data.read_exact(&mut id3v1_tag)?;
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
/// All possible genres for ID3v1
|
||||
#[cfg(any(feature = "id3v1"))]
|
||||
pub const GENRES: [&str; 192] = [
|
||||
"Blues",
|
||||
"Classic rock",
|
||||
|
@ -195,18 +194,13 @@ pub const GENRES: [&str; 192] = [
|
|||
"Psybient",
|
||||
];
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(feature = "id3v1")] {
|
||||
use crate::tag::item::ItemKey;
|
||||
|
||||
pub(crate) const VALID_ITEMKEYS: [ItemKey; 7] = [
|
||||
ItemKey::TrackTitle,
|
||||
ItemKey::TrackArtist,
|
||||
ItemKey::AlbumTitle,
|
||||
ItemKey::Year,
|
||||
ItemKey::Comment,
|
||||
ItemKey::TrackNumber,
|
||||
ItemKey::Genre,
|
||||
];
|
||||
}
|
||||
}
|
||||
use crate::tag::item::ItemKey;
|
||||
pub(crate) const VALID_ITEMKEYS: [ItemKey; 7] = [
|
||||
ItemKey::TrackTitle,
|
||||
ItemKey::TrackArtist,
|
||||
ItemKey::AlbumTitle,
|
||||
ItemKey::Year,
|
||||
ItemKey::Comment,
|
||||
ItemKey::TrackNumber,
|
||||
ItemKey::Genre,
|
||||
];
|
||||
|
|
|
@ -15,15 +15,11 @@
|
|||
//! A track number of 0 will be treated as an empty field.
|
||||
//! Additionally, there is no track total field.
|
||||
pub(crate) mod constants;
|
||||
pub(crate) mod read;
|
||||
pub(crate) mod tag;
|
||||
pub(crate) mod write;
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(feature = "id3v1")] {
|
||||
pub use constants::GENRES;
|
||||
// Exports
|
||||
|
||||
pub(crate) mod tag;
|
||||
pub use tag::ID3v1Tag;
|
||||
|
||||
pub(crate) mod read;
|
||||
pub(crate) mod write;
|
||||
}
|
||||
}
|
||||
pub use constants::GENRES;
|
||||
pub use tag::ID3v1Tag;
|
||||
|
|
|
@ -9,7 +9,6 @@ pub use properties::MPEGProperties;
|
|||
|
||||
#[cfg(feature = "ape")]
|
||||
use crate::ape::tag::ApeTag;
|
||||
#[cfg(feature = "id3v1")]
|
||||
use crate::id3::v1::tag::ID3v1Tag;
|
||||
#[cfg(feature = "id3v2")]
|
||||
use crate::id3::v2::tag::ID3v2Tag;
|
||||
|
@ -26,7 +25,6 @@ pub struct MPEGFile {
|
|||
#[lofty(tag_type = "ID3v2")]
|
||||
pub(crate) id3v2_tag: Option<ID3v2Tag>,
|
||||
/// An ID3v1 tag
|
||||
#[cfg(feature = "id3v1")]
|
||||
#[lofty(tag_type = "ID3v1")]
|
||||
pub(crate) id3v1_tag: Option<ID3v1Tag>,
|
||||
/// An APEv1/v2 tag
|
||||
|
|
|
@ -108,7 +108,6 @@ where
|
|||
#[allow(unused_variables)]
|
||||
let ID3FindResults(header, id3v1) = find_id3v1(reader, true)?;
|
||||
|
||||
#[cfg(feature = "id3v1")]
|
||||
if header.is_some() {
|
||||
file.id3v1_tag = id3v1;
|
||||
}
|
||||
|
|
|
@ -687,7 +687,6 @@ impl TagItem {
|
|||
}
|
||||
|
||||
pub(crate) fn re_map(&self, tag_type: TagType) -> bool {
|
||||
#[cfg(feature = "id3v1")]
|
||||
if tag_type == TagType::ID3v1 {
|
||||
use crate::id3::v1::constants::VALID_ITEMKEYS;
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ use crate::macros::err;
|
|||
use crate::tag::{Tag, TagType};
|
||||
use crate::{aac, ape, flac, iff, mpeg, wavpack};
|
||||
|
||||
#[cfg(feature = "id3v1")]
|
||||
use crate::id3::v1::tag::Id3v1TagRef;
|
||||
#[cfg(feature = "id3v2")]
|
||||
use crate::id3::v2::{self, tag::Id3v2TagRef, ID3v2TagFlags};
|
||||
|
@ -49,7 +48,6 @@ pub(crate) fn dump_tag<W: Write>(tag: &Tag, writer: &mut W) -> Result<()> {
|
|||
items: ape::tag::tagitems_into_ape(tag.items()),
|
||||
}
|
||||
.dump_to(writer),
|
||||
#[cfg(feature = "id3v1")]
|
||||
TagType::ID3v1 => Into::<Id3v1TagRef<'_>>::into(tag).dump_to(writer),
|
||||
#[cfg(feature = "id3v2")]
|
||||
TagType::ID3v2 => Id3v2TagRef {
|
||||
|
|
|
@ -4,7 +4,6 @@ mod read;
|
|||
|
||||
#[cfg(feature = "ape")]
|
||||
use crate::ape::tag::ApeTag;
|
||||
#[cfg(feature = "id3v1")]
|
||||
use crate::id3::v1::tag::ID3v1Tag;
|
||||
|
||||
use lofty_attr::LoftyFile;
|
||||
|
@ -18,7 +17,6 @@ pub use properties::WavPackProperties;
|
|||
#[lofty(internal_write_module_do_not_use_anywhere_else)]
|
||||
pub struct WavPackFile {
|
||||
/// An ID3v1 tag
|
||||
#[cfg(feature = "id3v1")]
|
||||
#[lofty(tag_type = "ID3v1")]
|
||||
pub(crate) id3v1_tag: Option<ID3v1Tag>,
|
||||
/// An APEv1/v2 tag
|
||||
|
|
|
@ -17,7 +17,6 @@ where
|
|||
let mut stream_length = reader.seek(SeekFrom::End(0))?;
|
||||
reader.seek(SeekFrom::Start(current_pos))?;
|
||||
|
||||
#[cfg(feature = "id3v1")]
|
||||
let mut id3v1_tag = None;
|
||||
#[cfg(feature = "ape")]
|
||||
let mut ape_tag = None;
|
||||
|
@ -26,10 +25,7 @@ where
|
|||
|
||||
if id3v1_header.is_some() {
|
||||
stream_length -= 128;
|
||||
#[cfg(feature = "id3v1")]
|
||||
{
|
||||
id3v1_tag = id3v1;
|
||||
}
|
||||
id3v1_tag = id3v1;
|
||||
}
|
||||
|
||||
// Next, check for a Lyrics3v2 tag, and skip over it, as it's no use to us
|
||||
|
@ -64,7 +60,6 @@ where
|
|||
}
|
||||
|
||||
Ok(WavPackFile {
|
||||
#[cfg(feature = "id3v1")]
|
||||
id3v1_tag,
|
||||
#[cfg(feature = "ape")]
|
||||
ape_tag,
|
||||
|
|
Loading…
Reference in a new issue