Skip to content

fix: update GOG search URL to use correct endpoint - #79

Merged
RobertMeissner merged 6 commits into
mainfrom
claude/add-gog-search-xQtSb
Jan 20, 2026
Merged

RobertMeissner merged 6 commits into
mainfrom
claude/add-gog-search-xQtSb

Conversation

@RobertMeissner

Copy link
Copy Markdown
Owner

The GOG search URL format changed from:
/games?search=... to /en/games?query=...&order=desc:score

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
@RobertMeissner
RobertMeissner merged commit 3693659 into main Jan 20, 2026
3 checks 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

Development

Successfully merging this pull request may close these issues.

2 participants