From 59cc0bedf40340ed42e6316806b3c4b154c3c744 Mon Sep 17 00:00:00 2001 From: Ryu1845 Date: Sat, 12 Mar 2022 15:59:15 +0100 Subject: [PATCH] handle not started space --- twspace_dl/twspace.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/twspace_dl/twspace.py b/twspace_dl/twspace.py index c532a77..abffb56 100644 --- a/twspace_dl/twspace.py +++ b/twspace_dl/twspace.py @@ -40,9 +40,17 @@ def __init__(self, metadata: dict) -> None: self["title"] = root["title"] self["creator_name"] = creator_info["name"] # type: ignore self["creator_screen_name"] = creator_info["screen_name"] # type: ignore - self["start_date"] = datetime.fromtimestamp( - int(root["started_at"]) / 1000 - ).strftime("%Y-%m-%d") + try: + self["start_date"] = datetime.fromtimestamp( + int(root["started_at"]) / 1000 + ).strftime("%Y-%m-%d") + except ValueError as err: + sched_start = datetime.fromtimestamp( + int(root["scheduled_start"]) / 1000 + ).strftime("%Y-%m-%d %H:%M:%S") + raise ValueError( + f"Space should start at {sched_start}, try again later" + ) from err self["state"] = root["state"] self["available_for_replay"] = root["is_space_available_for_replay"] self["media_key"] = root["media_key"]