From edfb0d216208e75eee8e99c7d827778875752c91 Mon Sep 17 00:00:00 2001 From: odecif Date: Mon, 31 Oct 2022 11:48:23 +0100 Subject: [PATCH] Added printing of failed cover art Also parametricised nfo suffix to look for Fixes #18 --- api/api.conf | 1 + api/modules/db_connect.py | 3 +++ api/modules/game.py | 14 +++++++++----- api/modules/gamelist.py | 3 ++- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/api/api.conf b/api/api.conf index 831d628..8071541 100644 --- a/api/api.conf +++ b/api/api.conf @@ -5,6 +5,7 @@ user = user pass = pass db_name = gamedistrosys contentpath = /srv/nfs_mounts/media/PC/ +nfo_suffix = _index.nfo [Running] host = 172.29.29.51 diff --git a/api/modules/db_connect.py b/api/modules/db_connect.py index 5c9df0b..ce7847d 100644 --- a/api/modules/db_connect.py +++ b/api/modules/db_connect.py @@ -32,3 +32,6 @@ def init(): def contentpath(): return(config.get('Database','contentpath')) + +def nfosuffix(): + return(config.get('Database','nfo_suffix')) diff --git a/api/modules/game.py b/api/modules/game.py index 0e4ccf2..cb44137 100644 --- a/api/modules/game.py +++ b/api/modules/game.py @@ -26,12 +26,16 @@ def game(predefinednfo=False, return_dict=False, skip_artwork=False): if 'artwork' in nfo['game']: if nfo['game']['artwork']: for art in nfo['game']['artwork']: - if skip_artwork is False: - nfo['game']['artwork'][i]['data'] = reduceartcv2( + try: + if skip_artwork is False: + nfo['game']['artwork'][i]['data'] = reduceartcv2( + artpath+art['filename'], 'thumbnail') + if art['type'] == 'front': + nfo['game']['displayimage'] = reduceartcv2( artpath+art['filename'], 'thumbnail') - if art['type'] == 'front': - nfo['game']['displayimage'] = reduceartcv2( - artpath+art['filename'], 'thumbnail') + except Exception as e: + print("Failing cover: " + art['filename']) + print(e) i += 1 if 'displayimage' not in nfo['game']: for art in nfo['game']['artwork']: diff --git a/api/modules/gamelist.py b/api/modules/gamelist.py index e0a52c6..bceb87f 100644 --- a/api/modules/gamelist.py +++ b/api/modules/gamelist.py @@ -6,6 +6,7 @@ import modules.game import glob contentpath = modules.db_connect.contentpath() +nfosuffix = modules.db_connect.nfosuffix() # Collects all _index.nfo-files present and crunches them into a list of @@ -22,7 +23,7 @@ def show_gamelist(): @app.route('/gamelist/update', methods=['GET']) def update_gamelist(): nfolist = list(dict.fromkeys(glob.glob( - str(contentpath)+'/**/**/*_index.nfo', recursive=True))) + str(contentpath)+'/**/**/*'+nfosuffix, recursive=True))) glist = [] for nfo in nfolist: