refactor: Have parsers handle "everything"#18
Conversation
- It acts more like a function rather than a class. - If we want things to be reusable, instead of accepting some initial parameters, we would expose a `parseFrom` function which might be overloaded to support `List<Metadata>` & `Metadata`.
- In the future, we may want to change up what we expose in `ReplayGainParser`, for example: `trackGain` (prev `gain`), `trackPeak`, `albumGain`, and `albumPeak`.
- This only occurs for ID3 binary frames.
- This was due to the null bytes that we didn't handle before.
|
Warning Review limit reached
More reviews will be available in 48 minutes and 11 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
ChangesParser rewrite and module integration
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@android/src/main/java/com/cyanchill/missingcore/metadataretriever/modules/LyricsParser.kt`:
- Around line 60-67: The BOM detection logic in the encodingCharSet assignment
is reading bytes from the wrong location in byteArr. The USLT/SYLT header is
dropped later in the code, but the current BOM detection using indices [1] and
[2] is checking pre-header bytes instead of the actual lyric text bytes. Move
the encodingCharSet assignment and BOM detection logic to occur after the header
has been dropped from byteArr, so that the UTF-16 endianness check examines the
correct bytes from the actual lyric content rather than the frame header,
preventing incorrect endianness selection and garbled output.
- Around line 99-104: The handleVorbisComment method is incorrectly marking
Vorbis LYRICS comments as synchronized by passing true as the isSync parameter
to ParsedResult. Since Vorbis LYRICS tags are inherently unsynchronized, change
the boolean parameter from true to false in the ParsedResult constructor call so
that the parser continues scanning for actual synchronized lyrics frames like
SYLT instead of prematurely stopping based on this unsynchronized source.
- Around line 56-67: The code in the encodingCharSet assignment accesses byteArr
at indices 0, 1, and 2 without checking if the array has sufficient length,
which can throw ArrayIndexOutOfBoundsException for malformed or short ID3
frames. Add a bounds check before the val encodingByte assignment to ensure
byteArr has at least 3 elements, and handle the case where the array is too
short by returning early or using a default charset value.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 9a76c4f3-cd71-4b2f-8d77-551bf4ac9dc8
📒 Files selected for processing (5)
CHANGELOG.mdandroid/src/main/java/com/cyanchill/missingcore/metadataretriever/modules/LyricsParser.ktandroid/src/main/java/com/cyanchill/missingcore/metadataretriever/modules/MetadataRetrieverModule.ktandroid/src/main/java/com/cyanchill/missingcore/metadataretriever/modules/ReplayGainParser.ktandroid/src/main/java/com/cyanchill/missingcore/metadataretriever/utils/LyricsParser.kt
💤 Files with no reviewable changes (1)
- android/src/main/java/com/cyanchill/missingcore/metadataretriever/utils/LyricsParser.kt
- We were previously checking the bytes representing "language", which isn't encoded.
|
@coderabbitai review |
✅ Action performedReview finished.
|
- This is due to potentially being at the end of the returned lyrics.
Right now, we want our parsers to handle everything:
If we want these to be more reusable, we would drop the initial arguments & the
initblock and exposeparseFrommethods that may be overloaded so that we can support bothList<Metadata>&Metadata.Entry.This PR also fixes an issues where we sometimes had "junk" in front of the returned lyrics. The root cause was not handling the lyrics returned by ID3's binary frame correctly.
USLTbinary frames starts with 4 bytes of "junk".SYLTbinary frames starts with 6 bytes of "junk".This is then followed by some more "junk" (in the form of "content" descriptor) of unknown size, which ends with 1 or 2
nullbytes based on encoding (UTF16 uses 2 bytes fornullwhile the others use 1 byte).Summary by CodeRabbit