Skip to content
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

fix: improve lyrics fetching and query encoding for special characters #594

Merged
merged 4 commits into from
Dec 30, 2024

Conversation

Mapleshade20
Copy link
Contributor

@Mapleshade20 Mapleshade20 commented Dec 30, 2024

This pull request includes several changes to improve lyrics fetching.

Changelogs

  • Specific to LRCLIB
  1. Use /api/get instead of /api/search for searching LRCLIB songs, in accordance with official docs recommendation.
  2. Add a boolean property instrumental to the struct LrclibSong. Fix lyrics parser so that it returns an empty array for instrumental songs, which gets "It is instrumental" correctly displayed. Before this change, empty lyrics would trigger a Decode Error.
  3. Keep parenthesis and hyphen in the song title upon the first query. If nothing matches, fallback to a stripped title query. This ensures precise matches for songs like "Contact - Sped Up" or "Wake Me Up (Nightcore)".
  • General
  1. Percent-encode special characters for all keys and values in queries. This prevents query errors for songs like "He & I" or "Hello? Anyone?"

A Small Breaking Change: enhance 'queryString' dictionary extension

Issue Reference

Closes #411

Test

  • My Test Method: Use GitHub workflow to build. Inject the dylib into Spotify app.
  • Test Result: Lyrics from LRCLIB, Genius, and Musixmatch sources works well. Many previously failed queries can be successfully performed now, and mismatched lyrics occur much less likely.

@whoeevee
Copy link
Owner

incredibly nice

@whoeevee whoeevee merged commit 85a002b into whoeevee:swift Dec 30, 2024
1 check 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
2 participants