修复epic未获取时间时出错

This commit is contained in:
HibiKier
2022-08-14 21:18:29 +08:00
parent ca78e32d97
commit ddbebba6f1
2 changed files with 13 additions and 6 deletions
+9 -6
View File
@@ -96,12 +96,15 @@ async def get_epic_free(bot: Bot, type_event: str):
if pair["key"] == "publisherName":
game_pub = pair["value"]
game_desp = game["description"]
end_date_iso = game["promotions"]["promotionalOffers"][0][
"promotionalOffers"
][0]["endDate"][:-1]
end_date = datetime.fromisoformat(end_date_iso).strftime(
"%b.%d %H:%M"
)
try:
end_date_iso = game["promotions"]["promotionalOffers"][0][
"promotionalOffers"
][0]["endDate"][:-1]
end_date = datetime.fromisoformat(end_date_iso).strftime(
"%b.%d %H:%M"
)
except IndexError:
end_date = '未知'
# API 返回不包含游戏商店 URL,此处自行拼接,可能出现少数游戏 404 请反馈
if game.get("productSlug"):
game_url = "https://store.epicgames.com/zh-CN/p/{}".format(