Skip to content

fix(taglib): parse both id3 and aliased tags, as lyrics appears to be mapped to lyrics-xxx #4310

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

Merged
merged 2 commits into from
Jul 9, 2025

Conversation

kgarner7
Copy link
Contributor

@kgarner7 kgarner7 commented Jul 5, 2025

Description

Taglib appears to map certain lyrics tags to lyrics:xxx, or in the case of at least WMA (wm/lyrics) and M4a (@lyr), duplicates those values. For items which have lyrics:xxx (mapped by whatever tag) and an aliased field (unsyncedlyrics), the two could not be parsed at the same time.

Now, always parse ID3 tags for pairs (this is primarily relevant for lyrics). Because of the duplicate behavior for wma and m4a, also remove those format-specific items from the tags.

Related Issues

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Refactor
  • Other (please describe):

Checklist

Please review and check all that apply:

  • My code follows the project’s coding style
  • I have tested the changes locally
  • I have added or updated documentation as needed
  • I have added tests that prove my fix/feature works (or explain why not)
  • All existing and new tests pass

How to Test

make test PKG=./adapters/taglib

Screenshots / Demos (if applicable)

Additional Notes

...why does taglib do this? I can't see it from the source. Discussion: https://discord.com/channels/671335427726114836/1391091057911005255

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @kgarner7, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a bug in how taglib handles lyrics metadata, specifically when both generic ID3-style lyrics and format-specific or aliased lyrics tags are present. The core change ensures that all available lyrics are correctly parsed and combined, preventing data loss or duplication, and is backed by comprehensive new test cases across various audio formats.

Highlights

  • Lyrics Parsing Logic Enhancement: I've updated the processPairMapping function in model/metadata/metadata.go to ensure that both ID3-style lyrics tags (e.g., lyrics:xxx) and any aliased lyrics tags (like unsyncedlyrics) are always parsed and combined. Previously, there was a potential for one to be preferred over the other, leading to incomplete lyrics data. Now, ID3-based tags are always collected first, and then aliased tags are appended, ensuring comprehensive lyrics extraction.
  • Refined Lyrics Tag Aliases: In resources/mappings.yaml, I've removed specific format-dependent lyrics aliases (©lyr and wm/lyrics). This change was made because taglib consistently maps these to the generic lyrics:xxx tag. By removing these redundant aliases, the parsing logic is simplified, and potential duplication or conflicts in lyrics data are avoided, aligning with taglib's actual behavior.
  • Expanded Lyrics Test Coverage: I've added a significant suite of new end-to-end tests in adapters/taglib/end_to_end_test.go to thoroughly validate the improved lyrics parsing. These tests cover various scenarios, including fetching both synced and unsynced lyrics from mixed FLAC files, handling USLT and SYLT tags in MP3s, and a parameterized test table that verifies correct lyrics extraction across a wide range of audio formats (FLAC, M4A, OGG, WMA, WV, WAV, AIFF), ensuring the fix works universally.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly addresses an issue where both ID3 and aliased lyrics tags were not being parsed simultaneously. The logic change in model/metadata/metadata.go is sound, and the accompanying update to resources/mappings.yaml is consistent with the fix. The new tests in adapters/taglib/end_to_end_test.go are comprehensive and cover various formats and scenarios. I've added a few suggestions to improve the maintainability and consistency of the new test code by refactoring duplicated logic.

@deluan deluan merged commit 6730716 into navidrome:master Jul 9, 2025
31 checks passed
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