Skip to content

feat: search item by it's hash#478

Open
tikhonp wants to merge 1 commit into
swingmx:masterfrom
tikhonp:hash_search
Open

feat: search item by it's hash#478
tikhonp wants to merge 1 commit into
swingmx:masterfrom
tikhonp:hash_search

Conversation

@tikhonp

@tikhonp tikhonp commented May 22, 2026

Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

The PR fulfills these requirements:

  • When resolving a specific issue, it's referenced in the PR's title (e.g. fix #xxx[,#xxx], where "xxx" is the issue number)

If adding a new feature, the PR's description includes:

  • A convincing reason for adding this feature (it's best to open a suggestion issue first and wait for approval before working on it)

Other information:

Initially, I needed an endpoint to get information about a single track by its hash, so I implemented an addition to the search functionality. Now, I can retrieve a song by hash not only through the API, but also via the web interface.

If you type the exact hash of a song, artist, or album, you will get that specific item; otherwise, the search behaves as usual.

P.S. I really love Swing Music for its simplicity and elegant interface, but without this feature, I’d have to maintain my own fork, which seems harder to manage in the long run. A merge would be highly appreciated.

Copilot AI review requested due to automatic review settings May 22, 2026 14:54

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

Note

Copilot was unable to run its full agentic suite in this review.

Adds “hash query” shortcuts to the search endpoints so that when the query looks like an entity hash, results can be fetched directly from stores instead of doing fuzzy search.

Changes:

  • Introduced hash-query detection (HASH_QUERY_LENGTH) and helper methods to resolve tracks/artists/albums by hash.
  • Updated search_tracks, search_artists, and search_albums to short-circuit to hash lookups when applicable.

Comment on lines +58 to +69
def _is_hash_query(self) -> bool:
return len(self.query) == HASH_QUERY_LENGTH

def _search_tracks_by_hash(self):
if not self._is_hash_query():
return None

group = TrackStore.trackhashmap.get(self.query)
if group:
return group.tracks

return []
def _is_hash_query(self) -> bool:
return len(self.query) == HASH_QUERY_LENGTH

def _search_tracks_by_hash(self):

return []

def _search_artist_by_hash(self):

return []

def _search_album_by_hash(self):
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