Skip to content

Commit

Permalink
Merge pull request #48 from zurdi15/hotfix/missing_cover_search_IGDB
Browse files Browse the repository at this point in the history
default cover shows when matched game has no cover in IGDB search
  • Loading branch information
zurdi15 authored Mar 28, 2023
2 parents 9f1cce1 + c498fa7 commit 1e794f8
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions backend/src/handler/igdb_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import requests

from config.config import CLIENT_ID, CLIENT_SECRET
from config.config import CLIENT_ID, CLIENT_SECRET, DEFAULT_URL_COVER_L
from logger.logger import log


Expand Down Expand Up @@ -120,9 +120,12 @@ def get_matched_roms(self, filename: str, p_igdb_id: int) -> list:
data=f"search \"{search_term}\";fields name, id, slug, summary; where platforms=[{p_igdb_id}];").json()
log.info(f"Matched roms for {filename}: {matched_roms}")
for rom in matched_roms:
res_details: dict = requests.post("https://api.igdb.com/v4/covers/", headers=self.headers,
data=f"fields url; where game={rom['id']};").json()[0]
rom['url_cover'] = f"https:{res_details['url']}".replace('t_thumb', f't_cover_big')
try:
res_details: dict = requests.post("https://api.igdb.com/v4/covers/", headers=self.headers,
data=f"fields url; where game={rom['id']};").json()[0]
rom['url_cover'] = f"https:{res_details['url']}".replace('t_thumb', f't_cover_big')
except IndexError:
rom['url_cover'] = DEFAULT_URL_COVER_L
return matched_roms


Expand Down

0 comments on commit 1e794f8

Please sign in to comment.