Skip to content

Commit

Permalink
handle not started space
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryu1845 committed Mar 12, 2022
1 parent a333c01 commit 59cc0be
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions twspace_dl/twspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down

0 comments on commit 59cc0be

Please sign in to comment.