ckatzorke / howlongtobeat

A simple api for https://howlongtobeat.com/
Do What The F*ck You Want To Public License
338 stars 45 forks source link

scrape search key for every request #64

Open Jan540 opened 2 months ago

Jan540 commented 2 months ago

As mentioned in #63 the search url changed.

It now requires a "api key" when searching for games: api/search/<search_key>. This key gets refreshed every now and then and can be scraped out of one of their scripts. I have implemented the basic functionality of fetching the key before every request based on how it was done in https://github.com/ScrappyCocco/HowLongToBeat-PythonAPI/issues/25.

I also noticed that Dark Souls only has 3 platforms. The test required 4. -> I have gone and changed the test.

xavdid commented 2 months ago

I copied your PR for my fork, thank you for that!

FWIW, you can load the API key lazily rather than on every request (if you store it on the class): https://github.com/xavdid/howlongtobeat/commit/5375d74481726b94c457e1828d48814c40a591d7#diff-1af9a3390b92891b019f2dbae92c77ca7d05282003849d5642715613e809ab54R89