]> git.0d.be Git - botaradio.git/commitdiff
chore: ytquery error message
authorTerry Geng <gengyanda@gmail.com>
Mon, 2 Mar 2020 03:35:07 +0000 (11:35 +0800)
committerTerry Geng <gengyanda@gmail.com>
Mon, 2 Mar 2020 03:35:07 +0000 (11:35 +0800)
command.py
util.py

index 8082cf8cdc6f2e3ffd052af5ebec034d55ce0ab1..c9b2473b6707201f1fa6fe17298b16adbf36c55a 100644 (file)
@@ -441,7 +441,7 @@ def cmd_rb_play(bot, user, text, command, parameter):
             msg += "No playable url found for this station, please try another station."
             bot.send_msg(msg, text)
 
-yt_last_result = None
+yt_last_result = []
 yt_last_page = 0 # TODO: if we keep adding global variables, we need to consider sealing all commands up into classes.
 
 def cmd_yt_query(bot, user, text, command, parameter):
diff --git a/util.py b/util.py
index 8795cc91c84bddf7a78b5e1560896a9a05f26962..7fe18b1ed3a7e96abd4b526e21c18ed859c863f0 100644 (file)
--- a/util.py
+++ b/util.py
@@ -471,6 +471,8 @@ def get_url_from_input(string):
         return False
 
 def youtube_search(query):
+    global log
+
     query_url = "https://www.youtube.com/results?search_query=" + urllib.parse.quote(query, safe="")
 
     try:
@@ -479,10 +481,9 @@ def youtube_search(query):
         results = re.findall("watch\?v=(.*?)\".*?title=\"(.*?)\".*?"
                              "(?:user|channel).*?>(.*?)<", response) # (id, title, uploader)
 
-        print(results)
-
         if len(results) > 0:
             return results
     except:
-        print(traceback.format_exc().split("During")[0])
+        error_traceback = traceback.format_exc().split("During")[0]
+        log.error("util: youtube query failed with error:\n %s" % error_traceback)
         return False