Skip to content

feat(chroma): add chromasearch command#6486

Open
ShimmerGlass wants to merge 1 commit intobeetbox:masterfrom
ShimmerGlass:chromasearch
Open

feat(chroma): add chromasearch command#6486
ShimmerGlass wants to merge 1 commit intobeetbox:masterfrom
ShimmerGlass:chromasearch

Conversation

@ShimmerGlass
Copy link
Copy Markdown

@ShimmerGlass ShimmerGlass commented Apr 1, 2026

Description

Add a new command to the chroma plugin: chromasearch.

This command lets user search the database by chromaprint fingerprint similarity.
Database item fingerprints are computed on the fly if needed. This is useful for example to check if an unknown / untagged audio file already exists in the database.

Will update changelog and doc once naming & co are sorted.

To Do

  • Documentation. (If you've added a new command-line flag, for example, find the appropriate page under docs/ to describe it.)
  • Changelog. (Add an entry to docs/changelog.rst to the bottom of one of the lists near the top of the document.)
  • Tests. (Very much encouraged but not strictly required.)

@ShimmerGlass ShimmerGlass requested a review from a team as a code owner April 1, 2026 20:33
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 1, 2026

Thank you for the PR! The changelog has not been updated, so here is a friendly reminder to check if you need to add an entry.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 1, 2026

Codecov Report

❌ Patch coverage is 69.23077% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.11%. Comparing base (131768b) to head (6049f1a).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
beetsplug/chroma.py 69.23% 12 Missing and 8 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6486      +/-   ##
==========================================
+ Coverage   70.06%   70.11%   +0.04%     
==========================================
  Files         147      147              
  Lines       18562    18622      +60     
  Branches     3026     3038      +12     
==========================================
+ Hits        13005    13056      +51     
+ Misses       4924     4923       -1     
- Partials      633      643      +10     
Files with missing lines Coverage Δ
beetsplug/chroma.py 36.53% <69.23%> (+14.53%) ⬆️
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ShimmerGlass ShimmerGlass force-pushed the chromasearch branch 3 times, most recently from 0469115 to ad89644 Compare April 2, 2026 07:05
Copy link
Copy Markdown
Member

@snejus snejus left a comment

Choose a reason for hiding this comment

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

Looks great. Would you mind adding a test?

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

grug see PR add new chroma plugin CLI command chromasearch to search local beets library by chromaprint fingerprint similarity, computing missing fingerprints on demand.

Changes:

  • add chromasearch subcommand with --search, --count, --full, plus format/path output support
  • extend fingerprint_item with quiet flag to reduce logging in some paths
  • add small TopN + ScoredItem helper for keeping best matches
Comments suppressed due to low confidence (1)

beetsplug/chroma.py:436

  • grug see fingerprint_item got quiet flag, but still log info for "no duration" and "fingerprinting" even when quiet=True. chromasearch pass quiet=True so grug expect less spam. grug think wrap these info logs with if not quiet: too, or rename flag to say what it really do.
    if not item.length:
        log.info("{.filepath}: no duration available", item)
    elif item.acoustid_fingerprint:
        if not quiet:
            if write:
                log.info("{.filepath}: fingerprint exists, skipping", item)
            else:
                log.info("{.filepath}: using existing fingerprint", item)
        return item.acoustid_fingerprint
    else:
        log.info("{.filepath}: fingerprinting", item)
        try:

@ShimmerGlass ShimmerGlass force-pushed the chromasearch branch 6 times, most recently from 4e290d2 to e04902b Compare April 3, 2026 20:45
@ShimmerGlass
Copy link
Copy Markdown
Author

@snejus answered comments and added tests! lmk what you think :)

Comment on lines +31 to +49
def test_chroma_search_exact(self, compare_fingerprints):
self.setup_lib()
compare_fingerprints.side_effect = self.compare_fingerprints

output = self.run_search(FINGERPRINT_2)
assert self.line_count(output) == 1
assert TEST_TITLE_2 in output

output = self.run_search(FINGERPRINT_1)
assert self.line_count(output) == 1
assert TEST_TITLE_1 in output

def test_chroma_search_close(self, compare_fingerprints):
self.setup_lib()
compare_fingerprints.side_effect = self.compare_fingerprints

output = self.run_search(FINGERPRINT_1_CLOSE)
assert self.line_count(output) == 2
assert TEST_TITLE_1 in output.split("\n")[0]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Move tests below the setup methods to make it consistent with the rest of the tests.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

done !

@ShimmerGlass ShimmerGlass force-pushed the chromasearch branch 2 times, most recently from 4b4d8a1 to 5886db5 Compare April 4, 2026 07:48
@ShimmerGlass
Copy link
Copy Markdown
Author

@snejus added docs and changelog :)

This command lets user search the database by chromaprint fingerprint
similarity.
Database item fingerprints are computed on the fly if needed.
This is useful for example to check if an unknown / untagged audio file
already exists in the database.
@JOJ0 JOJ0 added the plugin Pull requests that are plugins related label Apr 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

plugin Pull requests that are plugins related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants