-
-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ID3v2: Support more frames #236
Changes from all commits
d6b9bc9
8fbbc9d
6b6f5fc
29f0021
3752f86
dad19fd
3b4bad6
7f169c4
f8a5b20
81730da
cc9f173
faf27a8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,9 +4,9 @@ pub(super) mod id; | |
pub(super) mod read; | ||
|
||
use super::items::{ | ||
AttachedPictureFrame, CommentFrame, ExtendedTextFrame, ExtendedUrlFrame, KeyValueFrame, | ||
Popularimeter, TextInformationFrame, UniqueFileIdentifierFrame, UnsynchronizedTextFrame, | ||
UrlLinkFrame, | ||
AttachedPictureFrame, CommentFrame, EventTimingCodesFrame, ExtendedTextFrame, ExtendedUrlFrame, | ||
KeyValueFrame, OwnershipFrame, Popularimeter, PrivateFrame, RelativeVolumeAdjustmentFrame, | ||
TextInformationFrame, UniqueFileIdentifierFrame, UnsynchronizedTextFrame, UrlLinkFrame, | ||
}; | ||
use super::util::upgrade::{upgrade_v2, upgrade_v3}; | ||
use super::Id3v2Version; | ||
|
@@ -181,6 +181,16 @@ pub enum FrameValue { | |
Popularimeter(Popularimeter), | ||
/// Represents an "IPLS" or "TPIL" frame | ||
KeyValue(KeyValueFrame), | ||
/// Represents an "RVA2" frame | ||
RelativeVolumeAdjustment(RelativeVolumeAdjustmentFrame), | ||
/// Unique file identifier | ||
UniqueFileIdentifier(UniqueFileIdentifierFrame), | ||
/// Represents an "OWNE" frame | ||
Ownership(OwnershipFrame), | ||
/// Represents an "ETCO" frame | ||
EventTimingCodes(EventTimingCodesFrame), | ||
/// Represents a "PRIV" frame | ||
Private(PrivateFrame), | ||
/// Binary data | ||
/// | ||
/// NOTES: | ||
|
@@ -190,8 +200,6 @@ pub enum FrameValue { | |
/// * This is used for **all** frames with an ID of [`FrameId::Outdated`] | ||
/// * This is used for unknown frames | ||
Binary(Vec<u8>), | ||
/// Unique file identifier | ||
UniqueFileIdentifier(UniqueFileIdentifierFrame), | ||
} | ||
|
||
impl TryFrom<ItemValue> for FrameValue { | ||
|
@@ -271,12 +279,36 @@ impl From<KeyValueFrame> for FrameValue { | |
} | ||
} | ||
|
||
impl From<RelativeVolumeAdjustmentFrame> for FrameValue { | ||
fn from(value: RelativeVolumeAdjustmentFrame) -> Self { | ||
Self::RelativeVolumeAdjustment(value) | ||
} | ||
} | ||
|
||
impl From<UniqueFileIdentifierFrame> for FrameValue { | ||
fn from(value: UniqueFileIdentifierFrame) -> Self { | ||
Self::UniqueFileIdentifier(value) | ||
} | ||
} | ||
|
||
impl From<OwnershipFrame> for FrameValue { | ||
fn from(value: OwnershipFrame) -> Self { | ||
Self::Ownership(value) | ||
} | ||
} | ||
|
||
impl From<EventTimingCodesFrame> for FrameValue { | ||
fn from(value: EventTimingCodesFrame) -> Self { | ||
Self::EventTimingCodes(value) | ||
} | ||
} | ||
|
||
impl From<PrivateFrame> for FrameValue { | ||
fn from(value: PrivateFrame) -> Self { | ||
Self::Private(value) | ||
} | ||
} | ||
|
||
impl FrameValue { | ||
pub(super) fn as_bytes(&self) -> Result<Vec<u8>> { | ||
Ok(match self { | ||
|
@@ -289,10 +321,35 @@ impl FrameValue { | |
FrameValue::Picture(attached_picture) => attached_picture.as_bytes(Id3v2Version::V4)?, | ||
FrameValue::Popularimeter(popularimeter) => popularimeter.as_bytes(), | ||
FrameValue::KeyValue(content) => content.as_bytes(), | ||
FrameValue::Binary(binary) => binary.clone(), | ||
FrameValue::RelativeVolumeAdjustment(frame) => frame.as_bytes(), | ||
FrameValue::UniqueFileIdentifier(frame) => frame.as_bytes(), | ||
FrameValue::Ownership(frame) => frame.as_bytes()?, | ||
FrameValue::EventTimingCodes(frame) => frame.as_bytes(), | ||
FrameValue::Private(frame) => frame.as_bytes(), | ||
FrameValue::Binary(binary) => binary.clone(), | ||
}) | ||
} | ||
|
||
/// Used for errors in write::frame::verify_frame | ||
pub(super) fn name(&self) -> &'static str { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh yeah, looks like they have some useful derives. There are probably a few places they could be used. I might look into it eventually. |
||
match self { | ||
FrameValue::Comment(_) => "Comment", | ||
FrameValue::UnsynchronizedText(_) => "UnsynchronizedText", | ||
FrameValue::Text { .. } => "Text", | ||
FrameValue::UserText(_) => "UserText", | ||
FrameValue::Url(_) => "Url", | ||
FrameValue::UserUrl(_) => "UserUrl", | ||
FrameValue::Picture { .. } => "Picture", | ||
FrameValue::Popularimeter(_) => "Popularimeter", | ||
FrameValue::KeyValue(_) => "KeyValue", | ||
FrameValue::UniqueFileIdentifier(_) => "UniqueFileIdentifier", | ||
FrameValue::RelativeVolumeAdjustment(_) => "RelativeVolumeAdjustment", | ||
FrameValue::Ownership(_) => "Ownership", | ||
FrameValue::EventTimingCodes(_) => "EventTimingCodes", | ||
FrameValue::Private(_) => "Private", | ||
FrameValue::Binary(_) => "Binary", | ||
} | ||
} | ||
} | ||
|
||
/// Various flags to describe the content of an item | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great. This is
used by many MusicBrainz tagsneeded for http://picard-docs.musicbrainz.org/en/appendices/tag_mapping.html#id21