Skip to content

Commit 5508b9f

Browse files
fixes for api changes
1 parent 7c888ec commit 5508b9f

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

howlongtobeatpy/howlongtobeatpy/HTMLRequests.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class SearchModifiers(Enum):
2727
class HTMLRequests:
2828
BASE_URL = 'https://howlongtobeat.com/'
2929
REFERER_HEADER = BASE_URL
30-
SEARCH_URL = BASE_URL + "api/search"
30+
SEARCH_URL = BASE_URL + "api/find"
3131
GAME_URL = BASE_URL + "game"
3232

3333
@staticmethod
@@ -73,7 +73,7 @@ def get_search_request_data(game_name: str, search_modifiers: SearchModifiers, p
7373
'perspective': "",
7474
'flow': "",
7575
'genre': "",
76-
"subGenre": ""
76+
"difficulty": ""
7777
},
7878
'rangeYear':
7979
{
@@ -116,7 +116,7 @@ def send_web_request(game_name: str, search_modifiers: SearchModifiers = SearchM
116116
if api_key_result is None:
117117
api_key_result = HTMLRequests.send_website_request_getcode(True)
118118
# Make the request
119-
# The main method currently is the call to api/search/key
119+
# The main method currently is the call to api/find/key
120120
search_url_with_key = HTMLRequests.SEARCH_URL + "/" + api_key_result
121121
payload = HTMLRequests.get_search_request_data(game_name, search_modifiers, page, None)
122122
resp = requests.post(search_url_with_key, headers=headers, data=payload, timeout=60)
@@ -145,7 +145,7 @@ async def send_async_web_request(game_name: str, search_modifiers: SearchModifie
145145
if api_key_result is None:
146146
api_key_result = await HTMLRequests.async_send_website_request_getcode(True)
147147
# Make the request
148-
# The main method currently is the call to api/search/key
148+
# The main method currently is the call to api/find/key
149149
search_url_with_key = HTMLRequests.SEARCH_URL + "/" + api_key_result
150150
payload = HTMLRequests.get_search_request_data(game_name, search_modifiers, page, None)
151151
async with aiohttp.ClientSession() as session:
@@ -253,8 +253,8 @@ def extract_api_from_script(script_content: str):
253253
if matches:
254254
key = ''.join(matches)
255255
return key
256-
# Test 2 - The API Key is in format fetch("/api/search/".concat("X").concat("Y")...
257-
concat_api_key_pattern = r'\/api\/search\/"(?:\.concat\("[^"]*"\))*'
256+
# Test 2 - The API Key is in format fetch("/api/find/".concat("X").concat("Y")...
257+
concat_api_key_pattern = r'\/api\/find\/"(?:\.concat\("[^"]*"\))*'
258258
matches = re.findall(concat_api_key_pattern, script_content)
259259
if matches:
260260
matches = str(matches).split('.concat')
@@ -267,7 +267,7 @@ def extract_api_from_script(script_content: str):
267267
@staticmethod
268268
def send_website_request_getcode(parse_all_scripts: bool):
269269
"""
270-
Function that send a request to howlongtobeat to scrape the /api/search key
270+
Function that send a request to howlongtobeat to scrape the /api/find key
271271
@return: The string key to use
272272
"""
273273
# Make the post request and return the result if is valid
@@ -294,7 +294,7 @@ def send_website_request_getcode(parse_all_scripts: bool):
294294
@staticmethod
295295
async def async_send_website_request_getcode(parse_all_scripts: bool):
296296
"""
297-
Function that send a request to howlongtobeat to scrape the /api/search key
297+
Function that send a request to howlongtobeat to scrape the /api/find key
298298
@return: The string key to use
299299
"""
300300
# Make the post request and return the result if is valid

0 commit comments

Comments
 (0)