fix: Cookies for Youtube query (#264)
This commit is contained in:
parent
61748c199a
commit
72595f20fc
@ -121,7 +121,7 @@ port = 64738
|
|||||||
# bot.
|
# bot.
|
||||||
# This problem can be resolved if the bot bears a valid cookie.
|
# 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.
|
# 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] stores settings related to the web interface.
|
||||||
[webinterface]
|
[webinterface]
|
||||||
|
4
util.py
4
util.py
@ -321,8 +321,8 @@ def youtube_search(query):
|
|||||||
import json
|
import json
|
||||||
|
|
||||||
try:
|
try:
|
||||||
cookie = json.loads(var.config.get('bot', 'youtube_query_cookie', default='{}'))
|
cookie = json.loads(var.config.get('bot', 'youtube_query_cookie', fallback='{}'))
|
||||||
r = requests.get("https://www.youtube.com/results", cookie=cookie,
|
r = requests.get("https://www.youtube.com/results", cookies=cookie,
|
||||||
params={'search_query': query}, timeout=5)
|
params={'search_query': query}, timeout=5)
|
||||||
result_json_match = re.findall(r">var ytInitialData = (.*?);</script>", r.text)
|
result_json_match = re.findall(r">var ytInitialData = (.*?);</script>", r.text)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user