fix: update GOG search URL to use correct endpoint - #79
Merged
Merged
Conversation
The GOG search URL format changed from: /games?search=... to /en/games?query=...&order=desc:score
HLTB now requires authentication via x-auth-token header. The token is fetched from /api/search/init endpoint and cached for 30 minutes. On 403 errors, the token is refreshed and request retried.
HLTB uses a dynamic hash/key in their search API endpoint that changes
periodically. This update:
- Extracts the API key from HLTB's _app JavaScript bundle
- Uses endpoint format: /api/s/{key}
- Falls back to known key d4b2e330db04dbf3 if extraction fails
- Caches endpoint for 1 hour to avoid excessive requests
The previous approach of appending a hash to /api/s/ was incorrect. Changed to: - Extract endpoint dynamically from JS fetch() calls - Fallback to /api/search which is the standard endpoint - Retry on 404 errors in addition to 403/308
Added tests for: - findBestMatch with various edge cases (subtitles, ampersands, null names) - buildSearchRequestBody JSON structure validation - escapeJson character escaping - Levenshtein similarity calculation - normalize string handling Uses reflection to test private methods where needed.
HLTB API endpoint format keeps changing. This update: - Tries /api/s, /api/search, and /api/s/ as fallbacks - Caches working endpoint for future requests - Uses helper method trySearchEndpoint for cleaner code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The GOG search URL format changed from:
/games?search=... to /en/games?query=...&order=desc:score