diff --git a/ytnotifier.py b/ytnotifier.py
index a1ee9c6..dba0fd6 100644
--- a/ytnotifier.py
+++ b/ytnotifier.py
@@ -29,7 +29,7 @@ notify_chat = config['config']['notify_chat']
wait_seconds = config['config']['wait_seconds']
channels = config['config']['channels']
-live_regex = re.compile(r'error: (?:ytnotifier:([0-9]+) )?this live event will begin in (.+)', re.I)
+live_regex = re.compile(r'error: (?:ytnotifier:([0-9]+) )?(this live event will begin|premieres) in (.+)', re.I)
strip_date = re.compile(r' \d{4}-\d{2}-\d{2} \d{2}:\d{2}$')
ytdl = YoutubeDL({'skip_download': True, 'no_color': True})
ytdl.add_default_info_extractors()
@@ -59,7 +59,7 @@ def traverse_dict(src):
def try_get(src, getter, expected_type=None):
if reason := src.get('reason'):
- if isinstance(reason, str) and reason.startswith('This live event will begin in '):
+ if isinstance(reason, str) and (reason.startswith('This live event will begin in ') or reason.startswith('Premieres in ')):
t = _try_get(src, traverse_dict, str)
if t:
src['reason'] = f'ytnotifier:{t} {reason}'
@@ -81,18 +81,22 @@ async def _handle_video(video_id, video_title):
wait_time = too_many_attempts_count * 60 * 60
too_many_attempts_count += 1
elif match := live_regex.match(message.rstrip('.')):
- notify_text = 'Live event started'
end_schedule_time = match.group(1) or 0
- human_end_schedule_time = match.group(2)
+ is_premiere = match.group(2).lower().startswith('premieres in ')
+ if is_premiere:
+ notify_text = 'Premiere started'
+ else:
+ notify_text = 'Live event started'
+ human_end_schedule_time = match.group(3)
if end_schedule_time := int(end_schedule_time):
tmp_wait_time = end_schedule_time - time.time()
if tmp_wait_time > wait_time:
wait_time = tmp_wait_time
- await client.send_message(notify_chat, f'Live event starting in {human_end_schedule_time}: {html.escape(video_title)}')
+ await client.send_message(notify_chat, f'{"Premiere" if is_premiere else "Live event"} starting in {human_end_schedule_time}: {html.escape(video_title)}')
elif not last_was_few_moments:
- await client.send_message(notify_chat, f'Live event starting in {human_end_schedule_time}: {html.escape(video_title)}')
+ await client.send_message(notify_chat, f'{"Premiere" if is_premiere else "Live event"} starting in {human_end_schedule_time}: {html.escape(video_title)}')
elif not last_was_few_moments:
- await client.send_message(notify_chat, f'Live event starting in {human_end_schedule_time}: {html.escape(video_title)}')
+ await client.send_message(notify_chat, f'{"Premiere" if is_premeire else "Live event"} starting in {human_end_schedule_time}: {html.escape(video_title)}')
last_was_few_moments = 'moment' in human_end_schedule_time.lower()
await asyncio.sleep(wait_time)
else: