added functionality
authorGeorgios Atheridis <atheridis@tutamail.com>
Mon, 2 May 2022 15:33:18 +0000 (15:33 +0000)
committerGeorgios Atheridis <atheridis@tutamail.com>
Mon, 2 May 2022 15:33:18 +0000 (15:33 +0000)
19 files changed:
skgyorugo/analyze_auto_message.py
skgyorugo/analyze_command.py
skgyorugo/auto_messages/hello1.py [deleted file]
skgyorugo/commands/addcommand.py
skgyorugo/commands/coin.py [new file with mode: 0644]
skgyorugo/commands/commands.py
skgyorugo/commands/delete.py [new file with mode: 0644]
skgyorugo/commands/editcommand.py
skgyorugo/commands/removecommand.py
skgyorugo/commands/spam.py
skgyorugo/commands/t.py
skgyorugo/database_manager.py
skgyorugo/main.py
skgyorugo/scripts/alwase.py [new file with mode: 0644]
skgyorugo/scripts/chatting.py [new file with mode: 0644]
skgyorugo/scripts/unit_converter.py
skgyorugo/tools/smart_privmsg.py
skgyorugo/tools/smart_start_stream_time.py
skgyorugo/yt_api/videos.py

index cdaf649ccdae08d3f87562ee50b5ad7b5389860c..fc3b0a335975bfc9e27b87a572e56752e6d136b4 100644 (file)
@@ -31,33 +31,45 @@ def do_auto_message(bot: Bot, message: Message, auto_message_modules: dict):
         FROM
             auto_messages
         LEFT JOIN auto_message_values USING (name)
+        ORDER BY
+            last_used ASC
         """
     )
-    fetched = c.fetchall()
+    fetched = c.fetchone()
     if not fetched:
         conn.close()
         return
 
-    for auto_message in fetched:
-        name, cooldown, end_time, last_used, value = auto_message
-        print(auto_message)
-        if time.time() < last_used + cooldown:
-            continue
-        if time.time() > start_stream_ts + end_time and end_time != 0:
-            continue
-        if value:
-            tools.smart_privmsg.send(bot, message, value)
-        else:
+    name, cooldown, end_time, last_used, value = fetched
+    print(fetched)
+    if time.time() < last_used + cooldown:
+        return
+    if time.time() > start_stream_ts + end_time and end_time != 0:
+        return
+    if value:
+        tools.smart_privmsg.send(bot, message, value)
+    else:
+        try:
             auto_message_modules[name].main(bot, message)
-        c.execute(
-            "REPLACE INTO auto_messages VALUES (?, ?, ?, ?)",
-            (
-                name,
-                cooldown,
-                end_time,
-                int(time.time()),
+        except KeyError:
+            c.execute(
+                """
+                    DELETE FROM
+                        auto_messages
+                    WHERE
+                        name = ?
+                """,
+                (name, )
             )
+            conn.commit()
+            return
+
+    c.execute(
+        "UPDATE auto_messages SET last_used = ? WHERE name = ?",
+        (
+            int(time.time()),
+            name,
         )
-        conn.commit()
-        time.sleep(1.5)
+    )
+    conn.commit()
     conn.close()
index d071dd774e0e4d8c3a6e45bb261435f4a19ac033..472a29c4227122537f23c6fab33c2bcedfc56a9b 100644 (file)
@@ -12,7 +12,15 @@ def do_command(bot: Bot, message: Message, command_modules: dict):
     conn = sqlite3.connect(os.path.join(PATH, "database.db"))
     c = conn.cursor()
 
-    command = message.value.split(' ')[0]
+    try:
+        replied_message = message.tags["reply-parent-msg-body"]
+    except KeyError:
+        replied_message = None
+
+    if replied_message:
+        command = message.value.split(' ')[1]
+    else:
+        command = message.value.split(' ')[0]
     prefix = command[0]
     command = command[1:]
     user_id = message.tags["user-id"]
@@ -26,10 +34,13 @@ def do_command(bot: Bot, message: Message, command_modules: dict):
             value,
             commands.user_cooldown,
             commands.global_cooldown,
-            CASE WHEN cooldowns.user_cooldown >= (commands.last_used + commands.global_cooldown) THEN
-                cooldowns.user_cooldown
-            ELSE
-                (commands.last_used + commands.global_cooldown)
+            CASE 
+                WHEN ? <= 10 THEN
+                    0
+                WHEN cooldowns.user_cooldown >= (commands.last_used + commands.global_cooldown) THEN
+                    cooldowns.user_cooldown
+                ELSE
+                    (commands.last_used + commands.global_cooldown)
             END AS avail_time
 
         FROM
@@ -46,6 +57,7 @@ def do_command(bot: Bot, message: Message, command_modules: dict):
             AND permission >= ?
         """,
         (
+            user_perm,
             user_id,
             command,
             prefix,
@@ -53,7 +65,6 @@ def do_command(bot: Bot, message: Message, command_modules: dict):
         )
     )
     fetched = c.fetchall()
-    print(fetched)
     if not fetched:
         conn.close()
         return
diff --git a/skgyorugo/auto_messages/hello1.py b/skgyorugo/auto_messages/hello1.py
deleted file mode 100644 (file)
index 2c749ae..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-from aptbot.bot import Message, Commands, Bot
-
-COOLDOWN = 25 * 60
-END_TIME = 2 * 60 * 60
-
-
-def main(bot: Bot, message: Message):
-    msg = "ELLO it's me Murphy. I managed to find my way in to twitch chat PepeLaugh"
-    bot.send_privmsg(message.channel, msg)
index bd6fc1d9679d465ade86a2c56db5301c31ee800d..5df96e63917350107ef4d5be6acd407defb3cadb 100644 (file)
@@ -33,6 +33,22 @@ def main(bot: Bot, message: Message):
 
     conn = sqlite3.connect(os.path.join(PATH, "database.db"))
     c = conn.cursor()
+    c.execute(
+        "SELECT value FROM commands LEFT JOIN command_values USING(command) WHERE command = ? AND prefix = ?",
+        (
+            command_name,
+            command_prefix,
+        )
+    )
+    try:
+        if not c.fetchone()[0]:
+            bot.send_privmsg(
+                message.channel,
+                f"The command {command_prefix}{command_name} already exists"
+            )
+            return
+    except TypeError:
+        pass
     try:
         c.execute(
             "INSERT INTO commands VALUES (?, ?, ?, ?, ?, ?, ?)",
@@ -47,26 +63,24 @@ def main(bot: Bot, message: Message):
             )
         )
     except sqlite3.IntegrityError:
-        bot.send_privmsg(
-            message.channel,
-            f"The command {command_name} already exists."
-        )
+        pass
     except Exception as e:
         bot.send_privmsg(
             message.channel,
             f"There was an error adding the command: {e}"
         )
-    else:
-        c.execute(
-            "INSERT INTO command_values VALUES (?, ?)",
-            (
-                command_name,
-                command_value,
-            )
-        )
-        bot.send_privmsg(
-            message.channel,
-            f"Successfully added {command_name}."
+        conn.close()
+        return
+    c.execute(
+        "INSERT INTO command_values VALUES (?, ?)",
+        (
+            command_name,
+            command_value,
         )
+    )
+    bot.send_privmsg(
+        message.channel,
+        f"Successfully added {command_name}."
+    )
     conn.commit()
     conn.close()
diff --git a/skgyorugo/commands/coin.py b/skgyorugo/commands/coin.py
new file mode 100644 (file)
index 0000000..7fca71a
--- /dev/null
@@ -0,0 +1,21 @@
+from aptbot.bot import Message, Commands, Bot
+import tools.smart_privmsg
+import random
+
+PERMISSION = 99
+PREFIX = '?'
+DESCRIPTION = r"Tosses a coin, there's a 50% chance it's heads and a 50% chance it's tails"
+USER_COOLDOWN = 10
+GLOBAL_COOLDOWN = 5
+
+
+def main(bot: Bot, message: Message):
+    r = random.random()
+    if r < 0.02:
+        tools.smart_privmsg.send(bot, message, f"the coin landed on it's side, try again.", reply=message.tags["id"])
+    elif r < 0.51:
+        tools.smart_privmsg.send(bot, message, f"heads", reply=message.tags["id"])
+    else:
+        tools.smart_privmsg.send(bot, message, f"tails", reply=message.tags["id"])
+
+
index d2cf437b1bd3bcff5eba864e0f0a35c18a4ee823..8de41a135c4e66a0b3a0bcb4bbe0347b0c8ad22d 100644 (file)
@@ -40,5 +40,4 @@ def main(bot: Bot, message: Message):
         commands.append(f"{command[0]}{command[1]}")
 
     commands = ' '.join(commands)
-    print(f"commands is: {commands}")
     tools.smart_privmsg.send(bot, message, commands)
diff --git a/skgyorugo/commands/delete.py b/skgyorugo/commands/delete.py
new file mode 100644 (file)
index 0000000..936cde6
--- /dev/null
@@ -0,0 +1,16 @@
+from aptbot.bot import Message, Commands, Bot
+
+PERMISSION = 10
+PREFIX = '\\'
+DESCRIPTION = "Reply to a message with \\delete to delete that message"
+USER_COOLDOWN = 0
+GLOBAL_COOLDOWN = 0
+
+def main(bot: Bot, message: Message):
+    try:
+        replied_msg_id = message.tags["reply-parent-msg-id"]
+    except KeyError:
+        return
+    delete = f"/delete {replied_msg_id}"
+    bot.send_privmsg(message.channel, delete)
+
index 99973bdfe2ea31e51c47ee05b45ea60a6264fd2b..adee4c8f9baccad5b464477101ebfd5836208727 100644 (file)
@@ -29,7 +29,7 @@ def main(bot: Bot, message: Message):
     conn = sqlite3.connect(os.path.join(PATH, "database.db"))
     c = conn.cursor()
     c.execute(
-        "SELECT value FROM commands WHERE command = ? AND prefix = ?",
+        "SELECT value FROM commands LEFT JOIN command_values USING(command) WHERE command = ? AND prefix = ?",
         (
             command_name,
             command_prefix,
@@ -44,7 +44,7 @@ def main(bot: Bot, message: Message):
 
     try:
         c.execute(
-            "UPDATE commands SET value = ? WHERE command = ?",
+            "UPDATE command_values SET value = ? WHERE command = ?",
             (
                 command_value,
                 command_name,
index 8e83b26bacb053b13dbe2c71fe70745576fe07f7..4af03a95704388e35cba22ba51c9ed1dbb2997d8 100644 (file)
@@ -21,10 +21,9 @@ def main(bot: Bot, message: Message):
     conn = sqlite3.connect(os.path.join(PATH, "database.db"))
     c = conn.cursor()
     c.execute(
-        "SELECT value FROM commands WHERE command = ? AND prefix = ?",
+        "SELECT value FROM command_values WHERE command = ?",
         (
             command_name,
-            command_prefix,
         )
     )
     command_path = os.path.join(COMMANDS_PATH, f"{command_name}.py")
index 6830140412fcfb9570427668a47bfedc40e9cc77..571a38f4494ddbc87242393f9ab044ab4d3f3d64 100644 (file)
@@ -11,7 +11,14 @@ MAX_LENGTH = 450
 
 
 def main(bot: Bot, message: Message):
-    msg = ' '.join(message.value.split(' ')[1:])
+    try:
+        replied_message = message.tags["reply-parent-msg-body"]
+    except KeyError:
+        replied_message = None
+    if replied_message:
+        msg = replied_message
+    else:
+        msg = ' '.join(message.value.split(' ')[1:])
     new_msg = ""
     while len(new_msg) + len(msg) < MAX_LENGTH:
         new_msg += msg + " "
index fc4e7f2c1b57957c6b0aa5bdd862566a50799284..30f2c5962c1f163e4250f99f17bfcd4710a4fb19 100644 (file)
@@ -10,6 +10,16 @@ GLOBAL_COOLDOWN = 5
 
 
 def main(bot: Bot, message: Message):
-    msg = ' '.join(message.value.split(' ')[1:])
+    try:
+        replied_message = message.tags["reply-parent-msg-body"]
+    except KeyError:
+        replied_message = None
+    if replied_message:
+        msg = replied_message
+        replied_msg_id = message.tags["reply-parent-msg-id"]
+    else:
+        msg = ' '.join(message.value.split(' ')[1:])
+        replied_msg_id = None
     trans = scripts.translator.translate(msg)
-    tools.smart_privmsg.send(bot, message, trans)
+    print(trans)
+    tools.smart_privmsg.send(bot, message, trans, reply=replied_msg_id)
index ff3a7194f8a1d2fbc5961f6c05af9eff8556a971..09fdf6bca34480945fe7eadc54cabedbb2d04c11 100644 (file)
@@ -1,3 +1,4 @@
+from aptbot.bot import Message, Commands
 import sqlite3
 import os
 import ttv_api.users
@@ -94,6 +95,7 @@ def create_database():
         print(e)
 
     admin_id = ttv_api.users.get_users(user_logins=["skgyorugo"])
+    aptbot_id = ttv_api.users.get_users(user_logins=["murphyai"])
     broadcaster_id = ttv_api.users.get_users(user_logins=[streamer_login])
     if admin_id:
         try:
@@ -101,6 +103,12 @@ def create_database():
                       (admin_id[0].user_id, 0))
         except sqlite3.IntegrityError as e:
             print(e)
+    if aptbot_id:
+        try:
+            c.execute("INSERT INTO users VALUES (?, ?)",
+                      (aptbot_id[0].user_id, 0))
+        except sqlite3.IntegrityError as e:
+            print(e)
     if broadcaster_id:
         try:
             c.execute("INSERT INTO users VALUES (?, ?)",
@@ -210,6 +218,120 @@ def update_commands_in_database(modules, commands):
     conn.commit()
     conn.close()
 
+def add_message_to_chat_history(message: Message):
+    if message.command != Commands.PRIVMSG:
+        return
+    conn = sqlite3.connect(os.path.join(PATH, "chat_history.db"))
+    c = conn.cursor()
+
+    try:
+        bits = message.tags["bits"]
+    except KeyError:
+        bits = None
+    try:
+        rp_display_name = message.tags["reply-parent-display-name"]
+        rp_msg_body = message.tags["reply-parent-msg-body"]
+        rp_msg_id = message.tags["reply-parent-msg-id"]
+        rp_user_id = int( message.tags["reply-parent-user-id"] )
+        rp_user_login = message.tags["reply-parent-user-login"]
+    except KeyError:
+        rp_display_name = None
+        rp_msg_body = None
+        rp_msg_id = None
+        rp_user_id = None
+        rp_user_login = None
+
+    c.execute(
+        """
+        INSERT INTO chat (
+            "id",
+            "nick",
+            "channel",
+            "message",
+            "tmi-sent-ts",
+            "badge-info",
+            "badges",
+            "bits",
+            "color",
+            "display-name",
+            "first-msg",
+            "mod",
+            "room-id",
+            "user-id",
+            "user-type",
+            "turbo",
+            "subscriber",
+            "reply-parent-display-name",
+            "reply-parent-msg-body",
+            "reply-parent-msg-id",
+            "reply-parent-user-id",
+            "reply-parent-user-login"
+        ) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);
+        """,
+        (
+            message.tags["id"],
+            message.nick,
+            message.channel,
+            message.value,
+            int(message.tags["tmi-sent-ts"]),
+            message.tags["badge-info"],
+            message.tags["badges"],
+            bits,
+            message.tags["color"],
+            message.tags["display-name"],
+            int(message.tags["first-msg"]),
+            int( message.tags["mod"] ),
+            int( message.tags["room-id"] ),
+            int( message.tags["user-id"] ),
+            message.tags["user-type"],
+            int( message.tags["turbo"] ),
+            int( message.tags["subscriber"] ),
+            rp_display_name,
+            rp_msg_body,
+            rp_msg_id,
+            rp_user_id,
+            rp_user_login,
+        )
+    )
+    conn.commit()
+    conn.close()
+
+def create_chat_history_database():
+    conn = sqlite3.connect(os.path.join(PATH, "chat_history.db"))
+    c = conn.cursor()
+
+    c.execute(
+        """
+        CREATE TABLE IF NOT EXISTS "chat" (
+            "id"       TEXT NOT NULL,
+            "nick"     TEXT NOT NULL,
+            "channel"  TEXT NOT NULL,
+            "message"  TEXT NOT NULL,
+            "tmi-sent-ts"      INTEGER NOT NULL,
+            "badge-info"       TEXT NOT NULL,
+            "badges"   TEXT NOT NULL,
+            "bits"     TEXT,
+            "color"    TEXT NOT NULL,
+            "display-name"     TEXT NOT NULL,
+            "first-msg"        INTEGER NOT NULL,
+            "mod"      INTEGER NOT NULL,
+            "room-id"  INTEGER NOT NULL,
+            "user-id"  INTEGER NOT NULL,
+            "user-type"        TEXT NOT NULL,
+            "turbo"    INTEGER NOT NULL,
+            "subscriber"       INTEGER NOT NULL,
+            "reply-parent-display-name"        TEXT,
+            "reply-parent-msg-body"    TEXT,
+            "reply-parent-msg-id"      TEXT,
+            "reply-parent-user-id"     INTEGER,
+            "reply-parent-user-login"  TEXT,
+            PRIMARY KEY("id")
+        );
+        """
+    )
+    conn.commit()
+    conn.close()
+
 
 def update_auto_messages_in_database(modules, auto_messages):
     conn = sqlite3.connect(os.path.join(PATH, "database.db"))
index 12cc36c0bca9f9d86f8d8754dc678e5376262446..88d5d249b24b52db3525a82249b924d7495f4df4 100644 (file)
@@ -8,8 +8,11 @@ import tools.smart_privmsg
 import tools.permissions
 import analyze_command
 import scripts.unit_converter
+import scripts.alwase
+import scripts.chatting
 import database_manager
 import analyze_auto_message
+import time
 from importlib import reload
 
 reload(tools.raid)
@@ -17,6 +20,8 @@ reload(tools.smart_privmsg)
 reload(tools.permissions)
 reload(analyze_command)
 reload(scripts.unit_converter)
+reload(scripts.alwase)
+reload(scripts.chatting)
 reload(database_manager)
 reload(analyze_auto_message)
 
@@ -90,16 +95,25 @@ for spec in auto_message_specs:
 
 database_manager.create_database()
 database_manager.create_variables_db()
+database_manager.create_chat_history_database()
 database_manager.update_commands_in_database(commands_modules, commands)
 database_manager.update_auto_messages_in_database(
     auto_message_modules, auto_messages)
 
 
+def start(bot: Bot, message: Message):
+    while True:
+        analyze_auto_message.do_auto_message(bot, message, auto_message_modules)
+        time.sleep(30)
+
+
 def main(bot: Bot, message: Message):
     if message.command == Commands.PRIVMSG:
+        database_manager.add_message_to_chat_history(message)
         analyze_command.do_command(bot, message, commands_modules)
         scripts.unit_converter.send_metric(bot, message)
-
-    analyze_auto_message.do_auto_message(bot, message, auto_message_modules)
+        scripts.alwase.alwase(bot, message)
+        scripts.chatting.chatting(bot, message)
+        scripts.chatting.chatting_annoy(bot, message)
 
     tools.raid.raid(bot, message)
diff --git a/skgyorugo/scripts/alwase.py b/skgyorugo/scripts/alwase.py
new file mode 100644 (file)
index 0000000..b538bdb
--- /dev/null
@@ -0,0 +1,14 @@
+from aptbot.bot import Bot, Message, Commands
+import tools.smart_privmsg
+import random
+
+def alwase(bot: Bot, message: Message):
+    if "always" not in message.value.lower():
+        return
+    try:
+        replied_msg_id = message.tags["id"]
+    except KeyError:
+        replied_msg_id = None
+    msgs = ["It's alwase Madge", "Why don't you spell it alwase? Madge", "Spell it alwase or peepoArriveBan"]
+    msg = random.choice(msgs)
+    tools.smart_privmsg.send(bot, message, msg, reply=replied_msg_id)
diff --git a/skgyorugo/scripts/chatting.py b/skgyorugo/scripts/chatting.py
new file mode 100644 (file)
index 0000000..5d79de3
--- /dev/null
@@ -0,0 +1,27 @@
+from aptbot.bot import Bot, Message, Commands
+import tools.smart_privmsg
+import random
+
+
+def chatting(bot: Bot, message: Message):
+    if "Chatting" not in message.value:
+        return
+    if random.random() > 0.4:
+        return
+    msg = ""
+    if "reply-parent-msg-body" in message.tags:
+        if message.value.split(' ')[1] == "Chatting":
+            msg = ' '.join(message.value.split(' ')[1:])
+    else:
+        if message.value.split(' ')[0] == "Chatting":
+            msg = message.value
+    if msg:
+        tools.smart_privmsg.send(bot, message, msg)
+
+
+def chatting_annoy(bot: Bot, message: Message):
+    nicks = {}
+    if message.nick.lower() not in nicks:
+        return
+    msg = "Chatting " + message.value
+    tools.smart_privmsg.send(bot, message, msg)
index ffd6315655fb504b12d4a8658d2b608aa31b2259..32382cda43ec624e81b6fc0e27d05355105e689d 100644 (file)
@@ -15,7 +15,11 @@ def send_metric(bot: Bot, message: Message):
         elif cm[i] > 0:
             text += f"{ft_inch[i][0]:.1f}ft. and {ft_inch[i][1]:.1f}in. is {cm[i]:.1f}cm. | "
     if text:
-        tools.smart_privmsg.send(bot, message, text)
+        try:
+            replied_msg_id = message.tags["id"]
+        except KeyError:
+            replied_msg_id = None
+        tools.smart_privmsg.send(bot, message, text, reply=replied_msg_id)
 
 
 def _tometric(text: str) -> tuple[list[tuple[int, int]], list[float]]:
index 1ddcc97fd5694eaa8cc8d5191c0e097fd54386b7..c70791bcb1aa695452b0a48601ae952e55a7aa5f 100644 (file)
@@ -17,18 +17,18 @@ def _split_message(message: str) -> list[str]:
     return word_list
 
 
-def send_safe(bot: Bot, channel: str, messages: Union[str, list]):
+def send_safe(bot: Bot, channel: str, messages: Union[str, list], reply=None):
     if isinstance(messages, list):
         for i in range(len(messages)):
-            if messages[i].startswith('/') or messages[i].startswith('!'):
+            if messages[i].startswith('/') or messages[i].startswith('!') or messages[i].startswith('\\') or messages[i].startswith('?'):
                 messages[i] = messages[i][1:]
     else:
-        if messages.startswith('/') or messages.startswith('!'):
+        if messages.startswith('/') or messages.startswith('!') or messages.startswith('\\') or messages.startswith('?'):
             messages = messages[1:]
-    bot.send_privmsg(channel, messages)
+    bot.send_privmsg(channel, messages, reply)
 
 
-def send(bot: Bot, message_data: Message, message: str, to_remove: int = 1, safe_send: bool = True):
+def send(bot: Bot, message_data: Message, message: str, to_remove: int = 1, safe_send: bool = True, reply=None):
     # for msg in _split_message(' '.join(message_data.value.split(' ')[1:])):
     #     message = message.replace("{message}", msg)
     #     message = message.replace("{nick}", message_data.nick)
@@ -40,6 +40,6 @@ def send(bot: Bot, message_data: Message, message: str, to_remove: int = 1, safe
 
     messages = _split_message(message)
     if safe_send:
-        send_safe(bot, message_data.channel, messages)
+        send_safe(bot, message_data.channel, messages, reply)
     else:
-        bot.send_privmsg(message_data.channel, messages)
+        bot.send_privmsg(message_data.channel, messages, reply)
index 27aaca42a83ef4be7d3b7118b665ec1fd6126621..97d1f34cce13ec712d7b07fd124e3ab5fe504f24 100644 (file)
@@ -40,14 +40,10 @@ def start_stream_timestamp() -> Optional[int]:
                 max_last_checked[0],
             )
         )
-        print(f"I checked {max_last_checked}")
 
     fetched = c.fetchone()
     if fetched:
         start_stream_ts, last_checked, _ = fetched
-        print(f"stream ts = {start_stream_ts}")
-        print(
-            f"last_checked {last_checked} + check_streamtime_cd {CHECK_STREAMTIME_CD} \n time.time {time.time()}")
         if time.time() < last_checked + CHECK_STREAMTIME_CD:
             return start_stream_ts
 
@@ -75,7 +71,6 @@ def start_stream_timestamp() -> Optional[int]:
 
     if not fetched:
         start_stream_ts = int(stream_info[0].started_at.timestamp())
-        print("TEST")
         c.execute(
             "REPLACE INTO stream_info VALUES (?, ?, ?)",
             (
@@ -88,7 +83,6 @@ def start_stream_timestamp() -> Optional[int]:
         conn.close()
         return start_stream_ts
 
-    print("MORE TEST")
     start_stream_ts, last_checked, _ = fetched
     c.execute(
         "REPLACE INTO stream_info VALUES (?, ?, ?)",
index c43954a7643966bfd9d1535589ad9d1416663db2..9c68f72c955db46f97e6bd12cfa6aa51416c94fa 100644 (file)
@@ -1,4 +1,5 @@
 from yt_api import *
+import html
 
 
 @dataclass
@@ -17,11 +18,10 @@ def get_newest_video(channel_id: str) -> Optional[Video]:
         "GET",
         get_url,
     )
-    print(f"the r.status is {r.status}")
     if r.status != 200:
         return None
     data = json.loads(r.data.decode("utf-8"))["items"][0]
     video_id = data["id"]["videoId"]
-    video_title = data["snippet"]["title"]
+    video_title = html.unescape(data["snippet"]["title"])
 
     return Video(video_title, video_id)