From 4521e085c4e53fcb9327b62353867c17d6ccdc55 Mon Sep 17 00:00:00 2001 From: Yuuki Chan Date: Fri, 15 Nov 2024 12:31:28 +0900 Subject: [PATCH] Add check if there are any Products for given productId. --- run.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/run.py b/run.py index 9eb6231..be9183d 100644 --- a/run.py +++ b/run.py @@ -15,9 +15,13 @@ def get_game_name(pid: str) -> str: if req.status_code == 200: j = req.json() - return j['Products'][0]['LocalizedProperties'][0]['ProductTitle'] + + if j['Products']: + return j['Products'][0]['LocalizedProperties'][0]['ProductTitle'] + else: + return 'Unknown Title' else: - return 'Unknown Title' + return 'Error' def main(): @@ -31,6 +35,7 @@ def main(): game = get_game_name(product_id) print(f'\033[91m{clip}\033[97m is for product: \033[91m{game}\033[97m ContentID: \033[91m{content_id}\033[99m') + break if __name__ == '__main__':