From de13265915ff73e8b8fe30a86f7403e51d2a1e3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abdulkadir=20Furkan=20=C5=9Eanl=C4=B1?= Date: Sun, 21 Jan 2024 12:29:34 +0100 Subject: [PATCH] Fix YouTube shortlink incompatibility, remove 'graceful' SIGTERM. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Abdulkadir Furkan Şanlı --- main.py | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/main.py b/main.py index b2cff87..d196ae2 100755 --- a/main.py +++ b/main.py @@ -5,7 +5,6 @@ import asyncio import os import pickle import re -import signal import sqlite3 import sys from datetime import datetime, timedelta @@ -181,7 +180,7 @@ async def message_callback(client, room, event): ) for link in youtube_links: - video_id = link.split("v=")[-1] + video_id = link.split("v=")[-1].split("&")[0].split("/")[-1] if is_music(youtube, video_id): try: cursor.execute( @@ -248,23 +247,12 @@ async def get_client(): return client -def sigterm_handler(signum, frame): - """Gracefully stop syncing on SIGTERM.""" - asyncio.get_event_loop().stop() - - async def main(): """Get DB and Matrix client ready, and start syncing.""" define_tables() client = await get_client() - signal.signal(signal.SIGTERM, sigterm_handler) sync_token = load_sync_token() - try: - await client.sync_forever(30000, full_state=True, since=sync_token) - finally: - conn.close() - await client.logout() - sys.exit() + await client.sync_forever(30000, full_state=True, since=sync_token) if __name__ == "__main__":