Skip to content

[ID3v2] Standardize on fromFields#142

Open
benrr101 wants to merge 16 commits into
developfrom
feat/id3v2/from-fields
Open

[ID3v2] Standardize on fromFields#142
benrr101 wants to merge 16 commits into
developfrom
feat/id3v2/from-fields

Conversation

@benrr101

Copy link
Copy Markdown
Owner

Description

The goal of this PR is to migrate the various fromXyz static constructors in the ID3v2 frames to a standard fromFields static constructor. The parameters will vary between frame types, but they will all behave the same - construct a new frame, store the fields in the new frame, and have useful defaults for the parameters.

As I got deeper into this one I just kinda felt like what the heck am I doing. But, I'm happy that each frame type has two static constructors (well, except for attachments).

@benrr101 benrr101 added this to the v7.0.0 milestone Jul 11, 2026
@benrr101
benrr101 requested a review from Copilot July 11, 2026 20:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Standardizes ID3v2 frame construction around fromFields, including defaults and direct field initialization.

Changes:

  • Replaces specialized frame factories with fromFields.
  • Renames URL frame text accessors to url.
  • Updates tag logic and unit tests for the new APIs.

Reviewed changes

Copilot reviewed 40 out of 40 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
src/utils.ts Adds optional bigint validation.
src/id3v2/id3v2TagHeader.ts Adds field-based header construction.
src/id3v2/id3v2Tag.ts Migrates frame creation and URL access.
src/id3v2/frames/userUrlLinkFrame.ts Standardizes WXXX construction.
src/id3v2/frames/userTextInformationFrame.ts Standardizes TXXX construction.
src/id3v2/frames/urlLinkFrame.ts Adds fromFields and url.
src/id3v2/frames/unsynchronizedLyricsFrame.ts Adds field-based construction.
src/id3v2/frames/unknownFrame.ts Renames constructor to fromFields.
src/id3v2/frames/uniqueFileIdentifierFrame.ts Adds defaults to field construction.
src/id3v2/frames/textInformationFrame.ts Adds text-aware construction.
src/id3v2/frames/termsOfUseFrame.ts Expands constructor fields.
src/id3v2/frames/synchronizedLyricsFrame.ts Consolidates lyrics construction.
src/id3v2/frames/relativeVolumeFrame.ts Adds channel construction and cloning.
src/id3v2/frames/privateFrame.ts Adds owner/data construction.
src/id3v2/frames/popularimeterFrame.ts Adds rating/count construction.
src/id3v2/frames/playCountFrame.ts Adds count-based construction.
src/id3v2/frames/musicCdIdentifierFrame.ts Standardizes data construction.
src/id3v2/frames/genreFrame.ts Adds text and encoding construction.
src/id3v2/frames/eventTimeCodeFrame.ts Consolidates event construction.
src/id3v2/frames/commentsFrame.ts Consolidates comment construction.
test-unit/id3v2/userUrlLinkFrameTests.ts Updates WXXX tests.
test-unit/id3v2/userTextInformationFrameTests.ts Updates TXXX tests.
test-unit/id3v2/urlLinkFrameTests.ts Tests URL field construction.
test-unit/id3v2/unsynchronizedLyricsFrameTests.ts Tests lyrics defaults and fields.
test-unit/id3v2/unknownFrameTests.ts Tests unknown-frame construction.
test-unit/id3v2/uniqueFileIdentifierFrameTests.ts Tests UFID defaults and validation.
test-unit/id3v2/textInformationFrameTests.ts Tests text field construction.
test-unit/id3v2/termsOfUseFrameTests.ts Tests terms fields and defaults.
test-unit/id3v2/synchronizedLyricsFrameTests.ts Tests synchronized lyric fields.
test-unit/id3v2/relativeVolumeFrameTests.ts Tests channel field construction.
test-unit/id3v2/privateFrameTests.ts Tests private owner/data fields.
test-unit/id3v2/popularimeterFrameTests.ts Tests rating and play count fields.
test-unit/id3v2/playCountFrameTests.ts Tests play-count construction.
test-unit/id3v2/musicCdIdentifierFrameTests.ts Tests MCDI field construction.
test-unit/id3v2/id3v2TagTests.ts Migrates tag integration tests.
test-unit/id3v2/genreFrameTests.ts Refactors and expands genre tests.
test-unit/id3v2/frameFactoryTests.ts Migrates factory fixtures.
test-unit/id3v2/eventTimeCodeFrameTests.ts Tests event field construction.
test-unit/id3v2/commentsFrameTests.ts Tests comment field construction.
test-unit/id3v2/attachmentsFrameTests.ts Migrates unknown-frame fixtures.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/id3v2/frames/userTextInformationFrame.ts
Comment thread src/id3v2/frames/userUrlLinkFrame.ts
Comment thread src/id3v2/frames/relativeVolumeFrame.ts Outdated
Comment thread src/id3v2/frames/textInformationFrame.ts
Comment thread src/id3v2/frames/userTextInformationFrame.ts
Comment thread src/id3v2/frames/urlLinkFrame.ts Outdated
Comment thread src/id3v2/frames/userUrlLinkFrame.ts Outdated
Comment thread src/id3v2/frames/unknownFrame.ts Outdated
Comment thread src/id3v2/frames/musicCdIdentifierFrame.ts
Comment thread src/id3v2/id3v2TagHeader.ts

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 40 out of 40 changed files in this pull request and generated 10 comments.

Comment thread src/id3v2/id3v2Tag.ts
Comment thread src/id3v2/frames/relativeVolumeFrame.ts Outdated
Comment thread src/id3v2/frames/textInformationFrame.ts
Comment thread src/id3v2/frames/userTextInformationFrame.ts
Comment thread src/id3v2/frames/musicCdIdentifierFrame.ts
Comment thread src/id3v2/frames/urlLinkFrame.ts Outdated
Comment thread src/id3v2/frames/userUrlLinkFrame.ts Outdated
Comment thread src/id3v2/frames/unknownFrame.ts Outdated
Comment thread src/id3v2/frames/userUrlLinkFrame.ts Outdated
Comment thread src/id3v2/frames/userTextInformationFrame.ts

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 42 out of 42 changed files in this pull request and generated 3 comments.

Comment thread src/id3v2/frames/userTextInformationFrame.ts Outdated
Comment thread src/id3v2/frames/eventTimeCodeFrame.ts Outdated
Comment thread src/id3v2/frames/userTextInformationFrame.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 42 out of 42 changed files in this pull request and generated 2 comments.

Comment thread src/id3v2/frames/userTextInformationFrame.ts Outdated
Comment thread src/id3v2/frames/relativeVolumeFrame.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 42 out of 42 changed files in this pull request and generated 2 comments.

Comment thread src/id3v2/frames/relativeVolumeFrame.ts
Comment thread src/id3v2/id3v2TagHeader.ts

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 42 out of 42 changed files in this pull request and generated 3 comments.

Comment thread src/id3v2/id3v2TagHeader.ts
Comment thread src/id3v2/frames/privateFrame.ts
Comment thread test-unit/id3v2/id3v2TagTests.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 42 out of 42 changed files in this pull request and generated 4 comments.

Comment thread src/id3v2/frames/unknownFrame.ts Outdated
Comment thread src/id3v2/frames/urlLinkFrame.ts
Comment thread src/id3v2/frames/userUrlLinkFrame.ts
Comment thread src/id3v2/id3v2Tag.ts

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 42 out of 42 changed files in this pull request and generated 2 comments.

Comment on lines +51 to +58
public static fromFields(playCount: bigint = BigInt(0)): PlayCountFrame {
Guards.ulong(playCount, "playCount");

const frame = new PlayCountFrame(new Id3v2FrameHeader(FrameIdentifiers.PCNT));
frame._playCount = playCount;

return frame;
}

const frame = new PopularimeterFrame(new Id3v2FrameHeader(FrameIdentifiers.POPM));
frame._user = user;
frame._playCount = playCount;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants