parent
b7232b8bae
commit
61748c199a
@ -13,6 +13,7 @@ import util
|
||||
import variables as var
|
||||
from pyradios import RadioBrowser
|
||||
from database import SettingsDatabase, MusicDatabase, Condition
|
||||
import media.playlist
|
||||
from media.item import item_id_generators, dict_to_item, dicts_to_items, ValidationFailedError
|
||||
from media.cache import get_cached_wrapper_from_scrap, get_cached_wrapper_by_id, get_cached_wrappers_by_tags, \
|
||||
get_cached_wrapper, get_cached_wrappers, get_cached_wrapper_from_dict, get_cached_wrappers_from_dicts
|
||||
|
@ -116,6 +116,13 @@ port = 64738
|
||||
# - leave empty (do nothing)
|
||||
#when_nobody_in_channel =
|
||||
|
||||
# 'youtube_query_cookie': Sometimes youtube will block the request of our bot and
|
||||
# request the bot to complete a captcha to verify the request is not made by a
|
||||
# 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'}
|
||||
|
||||
# [webinterface] stores settings related to the web interface.
|
||||
[webinterface]
|
||||
# 'enable': Set 'enabled' to True if you'd like to use the web interface to manage
|
||||
|
4
util.py
4
util.py
@ -321,7 +321,9 @@ def youtube_search(query):
|
||||
import json
|
||||
|
||||
try:
|
||||
r = requests.get("https://www.youtube.com/results", params={'search_query': query}, timeout=5)
|
||||
cookie = json.loads(var.config.get('bot', 'youtube_query_cookie', default='{}'))
|
||||
r = requests.get("https://www.youtube.com/results", cookie=cookie,
|
||||
params={'search_query': query}, timeout=5)
|
||||
result_json_match = re.findall(r">var ytInitialData = (.*?);</script>", r.text)
|
||||
|
||||
if not len(result_json_match):
|
||||
|
Loading…
x
Reference in New Issue
Block a user