Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

Commit

Permalink
fix: Cookies for Youtube query (#264)
Browse files Browse the repository at this point in the history
  • Loading branch information
dadidji authored Apr 24, 2021
1 parent 61748c1 commit 72595f2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion configuration.example.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (.*?);</script>", r.text)

Expand Down

0 comments on commit 72595f2

Please sign in to comment.