Merge pull request #133 from zurdi15/develop

v1.6.2
This commit is contained in:
Zurdi
2023-04-04 16:07:44 +02:00
committed by GitHub
6 changed files with 32 additions and 19 deletions

View File

@@ -114,20 +114,25 @@ class IGDBHandler():
@check_twitch_token
def get_matched_roms(self, file_name: str, p_igdb_id: int) -> list:
search_term: str = unidecode.unidecode(re.sub('[\(\[].*?[\)\]]', '', file_name.split('.')[0]))
matched_roms: list = requests.post("https://api.igdb.com/v4/games/", headers=self.headers,
data=f"search \"{search_term}\";fields name, id, slug, summary; where platforms=[{p_igdb_id}];").json()
log.info(f"Matched roms for {file_name}: {matched_roms}")
for rom in matched_roms:
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
rom['r_igdb_id'] = rom.pop('id')
rom['r_slug'] = rom.pop('slug')
def get_matched_roms(self, file_name: str, p_igdb_id: int, p_slug: str) -> list:
matched_roms: list[dict] = []
if p_igdb_id != '':
search_term: str = unidecode.unidecode(re.sub('[\(\[].*?[\)\]]', '', file_name.split('.')[0]))
log.debug(search_term)
matched_roms: list = requests.post("https://api.igdb.com/v4/games/", headers=self.headers,
data=f"search \"{search_term}\";fields name, id, slug, summary; where platforms=[{p_igdb_id}];").json()
log.info(f"Matched roms for {file_name}: {matched_roms}")
for rom in matched_roms:
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
rom['r_igdb_id'] = rom.pop('id')
rom['r_slug'] = rom.pop('slug')
else:
log.warning(f"{p_slug} is not supported!")
return matched_roms

View File

@@ -97,8 +97,8 @@ async def search_rom_igdb(req: Request) -> dict:
"""Get all the roms matched from igdb."""
data: dict = await req.json()
log.info(f"getting {data['file_name']} roms from {data['p_igdb_id']} igdb ...")
return {'data': igdbh.get_matched_roms(data['file_name'], data['p_igdb_id'])}
log.info(f"getting {data['rom']['file_name']} roms from {data['rom']['p_slug']} igdb ...")
return {'data': igdbh.get_matched_roms(data['rom']['file_name'], data['rom']['p_igdb_id'], data['rom']['p_slug'])}
if __name__ == '__main__':

View File

@@ -1,3 +1,12 @@
# v1.6.2 (_04-04-2023_)
## Added
- Support for commodore64
## Fixed
- Searching in IGDB for games in not supported platforms doesn't raise an error anymore
<br>
# v1.6.1 (_04-04-2023_)
## Added

View File

Before

Width:  |  Height:  |  Size: 264 KiB

After

Width:  |  Height:  |  Size: 264 KiB

View File

@@ -28,8 +28,7 @@ async function searchRomIGDB() {
dialogSearchRom.value = true
console.log("searching for rom... "+rom.value.file_name)
await axios.put('/api/search/roms/igdb', {
file_name: rom.value.file_name,
p_igdb_id: rom.value.p_igdb_id
rom: rom.value
}).then((response) => {
console.log(response.data.data)
matchedRoms.value = response.data.data

View File

@@ -124,7 +124,7 @@ This will change over the time, adding games metadata for more platforms. Make s
| arcade | Arcade | ✅ |
| atari | atari | ❌ |
| coleco | coleco | ❌ |
| commodore | commodore | |
| c64 | Commodore C64/128/MAX | |
| cpc | cpc | ❌ |
| cps1 | cps1 | ❌ |
| cps2 | cps2 | ❌ |