From 16cc5a44eb64d61edf5f71c89c62a3058235c1a4 Mon Sep 17 00:00:00 2001 From: odecif Date: Fri, 28 Oct 2022 15:25:58 +0200 Subject: [PATCH 1/2] Added handling for when artwork is missing --- api/modules/game.py | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/api/modules/game.py b/api/modules/game.py index 63067af..c2c613c 100644 --- a/api/modules/game.py +++ b/api/modules/game.py @@ -23,15 +23,23 @@ def game(predefinednfo=False, return_dict=False, skip_artwork=False): # Add front cover artwork in medium size artpath = os.path.dirname(nfopath)+'/art/' i = 0 - for art in nfo['game']['artwork']: - 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') - i += 1 - + 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( + artpath+art['filename'], 'thumbnail') + if art['type'] == 'front': + nfo['game']['displayimage'] = reduceartcv2( + artpath+art['filename'], 'thumbnail') + i += 1 + if 'displayimage' not in nfo['game']: + for art in nfo['game']['artwork']: + if art['type'] == 'cd': + nfo['game']['displayimage'] = reduceartcv2( + artpath+art['filename'], 'thumbnail') + else: + nfo['game']['displayimage'] = "" if return_dict is False: return jsonify(nfo) return nfo From dee805633e4615ef1c9aa5381830a088977b841b Mon Sep 17 00:00:00 2001 From: odecif Date: Fri, 28 Oct 2022 15:37:21 +0200 Subject: [PATCH 2/2] Hide linuxinstructions when missing Fixes #3 --- site/modules/game.py | 7 ++++++- site/templates/game.html | 10 ++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/site/modules/game.py b/site/modules/game.py index e51724f..8e824af 100644 --- a/site/modules/game.py +++ b/site/modules/game.py @@ -27,7 +27,12 @@ def game(lang_code): # game['game']['plot'] = game['game']['plot'].replace("\\n", "
") game['game']['plot'] = game['game']['plot'].split('\\n') - game['game']['linuxinstructions'] = game['game']['linuxinstructions'].split('\\n') + if 'linuxinstructions' in game['game']: + if game['game']['linuxinstructions'] != "": + game['game']['linuxinstructions'] = ( + game['game']['linuxinstructions'].split('\\n')) + else: + game['game'].pop('linuxinstructions') return render_template('game.html', game=game, **languages[lang_code], lang_code=lang_code) diff --git a/site/templates/game.html b/site/templates/game.html index a20193d..a104749 100644 --- a/site/templates/game.html +++ b/site/templates/game.html @@ -75,10 +75,12 @@

{{game.game.cdkey}}

{% endif %} -

{{lang_game_linuxinstructions}}

- {% for part in game.game.linuxinstructions %} -

{{part}}

- {% endfor %} + {% if 'linuxinstructions' in game.game %} +

{{lang_game_linuxinstructions}}

+ {% for part in game.game.linuxinstructions %} +

{{part}}

+ {% endfor %} + {% endif%} {% endblock %}