From 72595f20fc5627a735eb61861b056298b309e00c Mon Sep 17 00:00:00 2001 From: dadidji <81387591+dadidji@users.noreply.github.com> Date: Sat, 24 Apr 2021 04:53:52 +0000 Subject: [PATCH] fix: Cookies for Youtube query (#264) --- configuration.example.ini | 2 +- util.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/configuration.example.ini b/configuration.example.ini index d067e6f..a56a2a8 100644 --- a/configuration.example.ini +++ b/configuration.example.ini @@ -121,7 +121,7 @@ port = 64738 # bot. # This problem can be resolved if the bot bears a valid cookie. # If the bot complains "unable to query youtube", you may try to add your cookie here. -#youtube_query_cookie = {'CONSENT': 'paste your CONSENT cookie value here'} +#youtube_query_cookie = {"CONSENT": "paste your CONSENT cookie value here"} # [webinterface] stores settings related to the web interface. [webinterface] diff --git a/util.py b/util.py index 59060a5..3d4fa66 100644 --- a/util.py +++ b/util.py @@ -321,8 +321,8 @@ def youtube_search(query): import json try: - cookie = json.loads(var.config.get('bot', 'youtube_query_cookie', default='{}')) - r = requests.get("https://www.youtube.com/results", cookie=cookie, + cookie = json.loads(var.config.get('bot', 'youtube_query_cookie', fallback='{}')) + r = requests.get("https://www.youtube.com/results", cookies=cookie, params={'search_query': query}, timeout=5) result_json_match = re.findall(r">var ytInitialData = (.*?);", r.text)