Skip to content

Commit 40612b9

Browse files
committed
Change search index for North American countries for better results.
1 parent 4477dec commit 40612b9

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

custom_components/nintendo_wishlist/eshop.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
# North American countries.
1515
NA_COUNTRIES: Tuple[str] = ("CA", "US")
1616
NA_INDEX_NAMES: Dict[str, str] = {
17-
"CA": "noa_aem_game_en_ca",
18-
"US": "noa_aem_game_en_us",
17+
"CA": "ncom_game_en_ca",
18+
"US": "ncom_game_en_us",
1919
}
2020

2121
# Mapping of country code to language code. NOTE: language must be lowercase
@@ -64,11 +64,11 @@ class Country(enum.Enum):
6464

6565
# Below constants used by North America (US and CA)
6666
APP_ID = "U3B6GR4UA3"
67-
API_KEY = "9a20c93440cf63cf1a7008d75f7438bf"
67+
API_KEY = "c4da8be7fd29f0f5bfa42920b0a99dc7"
6868
QUERIES = [
6969
{
70-
"indexName": "noa_aem_game_en_us",
71-
"params": "query=&hitsPerPage=350&maxValuesPerFacet=30&facets=%5B%22generalFilters%22%2C%22platform%22%2C%22availability%22%2C%22categories%22%2C%22filterShops%22%2C%22virtualConsole%22%2C%22characters%22%2C%22priceRange%22%2C%22esrb%22%2C%22filterPlayers%22%5D&tagFilters=&facetFilters=%5B%5B%22generalFilters%3ADeals%22%5D%2C%5B%22platform%3ANintendo%20Switch%22%5D%5D", # noqa
70+
"indexName": "ncom_game_en_us",
71+
"params": "query=&hitsPerPage=350&maxValuesPerFacet=30&page=0&analytics=false&facets=%5B%22generalFilters%22%2C%22platform%22%2C%22availability%22%2C%22genres%22%2C%22howToShop%22%2C%22virtualConsole%22%2C%22franchises%22%2C%22priceRange%22%2C%22esrbRating%22%2C%22playerFilters%22%5D&tagFilters=&facetFilters=%5B%5B%22platform%3ANintendo%20Switch%22%5D%2C%5B%22generalFilters%3ADeals%22%5D%5D", # noqa
7272
},
7373
]
7474

@@ -105,7 +105,7 @@ async def fetch_on_sale(self) -> Dict[int, SwitchGame]:
105105

106106
def get_na_switch_game(self, game: Dict[str, Any]) -> SwitchGame:
107107
"""Get a SwitchGame from a json result."""
108-
box_art = game.get("boxArt", game.get("gallery"))
108+
box_art = game.get("boxart", game.get("gallery"))
109109
if not box_art or not box_art.endswith((".png", ".jpg")):
110110
raise ValueError("Couldn't find box art: %s", game)
111111

@@ -133,7 +133,7 @@ async def _get_page(
133133
queries[0]["params"] = query_params
134134
data = await client.multiple_queries_async(queries)
135135
# Filter out resuls w/o box art.
136-
games = [r for r in data["results"][0]["hits"] if r.get("boxArt")]
136+
games = [r for r in data["results"][0]["hits"] if r.get("boxart")]
137137
result["games"] = self.filter_wishlist_matches(games)
138138
result["num_pages"] = data["results"][0]["nbPages"]
139139
return result

tests/test_eshop.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ def client_mock():
1111
client = Mock()
1212
games = [
1313
{
14-
"boxArt": "image.png",
14+
"boxart": "image.png",
1515
"msrp": 24.99,
1616
"nsuid": 70010000531,
1717
"salePrice": 9.99,
1818
"title": "Picross",
1919
},
2020
{
21-
"boxArt": "image.png",
21+
"boxart": "image.png",
2222
"msrp": 14.99,
2323
"nsuid": 70010000532,
2424
"salePrice": 8.24,
@@ -62,7 +62,7 @@ def test_get_na_switch_game_bad_prefix_value_error():
6262
wishlist = ["title1"]
6363
eshop = EShop("US", Mock(), wishlist)
6464
with pytest.raises(ValueError, match="Couldn't find box art"):
65-
game = {"boxArt": "https://nintendo.com/art.gif"}
65+
game = {"boxart": "https://nintendo.com/art.gif"}
6666
eshop.get_na_switch_game(game)
6767

6868

@@ -71,7 +71,7 @@ def test_get_na_switch_game_success():
7171
wishlist = ["title1"]
7272
eshop = EShop("US", Mock(), wishlist)
7373
game = {
74-
"boxArt": "image.png",
74+
"boxart": "image.png",
7575
"msrp": 14.99,
7676
"nsuid": 70010000532,
7777
"salePrice": 8.24,

0 commit comments

Comments
 (0)