Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 9, 2025

Extends the existing suffix-stripping logic in clean_name_for_search() to also remove parenthetical content from track and album names before searching MusicBrainz. This improves search accuracy by removing edition-specific metadata that may not be present in the MusicBrainz database.

Problem

Apple Music often includes parenthetical information like "(Deluxe Edition)", "(Remastered)", or "(Live)" in track and album names, but these details may not be present in MusicBrainz entries, causing search misses.

Solution

Enhanced the centralized clean_name_for_search() function to remove:

  • Parenthetical content (e.g., "(Deluxe Edition)", "(Remastered)")
  • Existing suffix removal (" - Single", " - EP") continues to work

The implementation properly handles:

  • Nested parentheses: "Title (Contains (Nested) Text)""Title"
  • Multiple parenthetical sections: "Multiple (First) (Second) Parentheses""Multiple Parentheses"
  • Combined cleaning: "Greatest Hits (Deluxe Edition) - EP""Greatest Hits"

Examples

# Before
"Abbey Road (Remastered)""Abbey Road (Remastered)"
"Born to Run (Special Edition) - Single""Born to Run (Special Edition)"

# After  
"Abbey Road (Remastered)""Abbey Road"
"Born to Run (Special Edition) - Single""Born to Run"

Changes

  • Enhanced clean_name_for_search() function with robust parentheses removal logic
  • Updated documentation in README.md with examples of new functionality
  • Added comprehensive tests with 26 test cases covering edge cases and realistic scenarios
  • Maintained backward compatibility - all existing suffix removal functionality preserved

The cleaning logic is automatically applied to both track and album searches through the existing integration points in search_musicbrainz_recording() and search_musicbrainz_release_group().

This pull request was created as a result of the following prompt from Copilot chat.

Extend the logic that strips suffixes like "- EP" and "- Single" from track and album names to also remove any extra information present within parentheses (e.g., "Album Name (Deluxe Edition)") before searching. Ensure this preprocessing step is applied consistently for both tracks and albums within the search routines. Refactor the relevant code to centralize this cleaning logic, update comments and documentation to describe the new behavior, and add tests to validate the feature. This change should be pushed to the 'test' branch rather than 'main'.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Strip extra info in parentheses from album names before searching (branch: test) Extend name cleaning to remove parenthetical content for improved MusicBrainz matching Sep 9, 2025
Copilot AI requested a review from ekinnee September 9, 2025 16:41
@ekinnee
Copy link
Owner

ekinnee commented Sep 9, 2025

@copilot Try to create and push to the test branch again.

@ekinnee
Copy link
Owner

ekinnee commented Sep 9, 2025

@copilot See last comment.

@ekinnee
Copy link
Owner

ekinnee commented Sep 9, 2025

@copilot Try to create and push to the test branch again.

@ekinnee ekinnee reopened this Sep 9, 2025
@ekinnee ekinnee marked this pull request as ready for review September 9, 2025 16:46
@ekinnee ekinnee merged commit f31e91e into test Sep 9, 2025
1 check failed
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