Add check if there are any Products for given productId.

This commit is contained in:
Yuuki Chan 2024-11-15 12:31:28 +09:00
parent 4b8d80aafa
commit 4521e085c4

9
run.py
View file

@ -15,9 +15,13 @@ def get_game_name(pid: str) -> str:
if req.status_code == 200: if req.status_code == 200:
j = req.json() 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: else:
return 'Unknown Title' return 'Error'
def main(): def main():
@ -31,6 +35,7 @@ def main():
game = get_game_name(product_id) 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') 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__': if __name__ == '__main__':