Added discord timestamps (#6264)

Co-authored-by: palmtree5 <3577255+palmtree5@users.noreply.github.com>
This commit is contained in:
gip 2024-04-04 03:32:15 -04:00 committed by GitHub
parent 24afd61a85
commit f8d6bbb0af
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -221,17 +221,16 @@ class YoutubeStream(Stream):
if vid_data["liveStreamingDetails"].get("scheduledStartTime", None) is not None: if vid_data["liveStreamingDetails"].get("scheduledStartTime", None) is not None:
if "actualStartTime" not in vid_data["liveStreamingDetails"]: if "actualStartTime" not in vid_data["liveStreamingDetails"]:
start_time = parse_time(vid_data["liveStreamingDetails"]["scheduledStartTime"]) start_time = parse_time(vid_data["liveStreamingDetails"]["scheduledStartTime"])
start_time_unix = time.mktime(start_time.timetuple())
start_in = start_time - datetime.now(timezone.utc) start_in = start_time - datetime.now(timezone.utc)
if start_in.total_seconds() > 0: if start_in.total_seconds() > 0:
embed.description = _("This stream will start in {time}").format( embed.description = _("This stream will start <t:{time}:R>").format(
time=humanize_timedelta( time=int(start_time_unix)
timedelta=timedelta(minutes=start_in.total_seconds() // 60)
) # getting rid of seconds
) )
else: else:
embed.description = _( embed.description = _("This stream was scheduled for <t:{time}:R>").format(
"This stream was scheduled for {min} minutes ago" time=int(start_time_unix)
).format(min=round((start_in.total_seconds() * -1) // 60)) )
embed.timestamp = start_time embed.timestamp = start_time
is_schedule = True is_schedule = True
else: else: