mirror of
https://github.com/azlux/botamusique
synced 2024-11-23 22:06:09 +00:00
Compare commits
No commits in common. "b0ace7b67a22b58dd93baef0e507b0904ba33b21" and "e9bb9d3489b75f8e8f233a2317ba5d261471b1f7" have entirely different histories.
b0ace7b67a
...
e9bb9d3489
@ -624,7 +624,7 @@ def cmd_help(bot, user, text, command, parameter):
|
|||||||
def cmd_stop(bot, user, text, command, parameter):
|
def cmd_stop(bot, user, text, command, parameter):
|
||||||
global log
|
global log
|
||||||
|
|
||||||
if var.config.getboolean("bot", "clear_when_stop_in_oneshot") \
|
if var.config.getboolean("bot", "clear_when_stop_in_oneshot", fallback=False) \
|
||||||
and var.playlist.mode == 'one-shot':
|
and var.playlist.mode == 'one-shot':
|
||||||
cmd_clear(bot, user, text, command, parameter)
|
cmd_clear(bot, user, text, command, parameter)
|
||||||
else:
|
else:
|
||||||
@ -1152,7 +1152,7 @@ def cmd_shortlist(bot, user, text, command, parameter):
|
|||||||
def cmd_delete_from_library(bot, user, text, command, parameter):
|
def cmd_delete_from_library(bot, user, text, command, parameter):
|
||||||
global song_shortlist, log
|
global song_shortlist, log
|
||||||
|
|
||||||
if not var.config.getboolean("bot", "delete_allowed"):
|
if not var.config.getboolean("bot", "delete_allowed", fallback=True):
|
||||||
bot.mumble.users[text.actor].send_text_message(tr('not_admin'))
|
bot.mumble.users[text.actor].send_text_message(tr('not_admin'))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ language = en_US
|
|||||||
logfile =
|
logfile =
|
||||||
max_track_duration = 60
|
max_track_duration = 60
|
||||||
max_track_playlist = 20
|
max_track_playlist = 20
|
||||||
music_database_path = music.db
|
music_database_path =
|
||||||
music_folder = music_folder/
|
music_folder = music_folder/
|
||||||
pip3_path = venv/bin/pip
|
pip3_path = venv/bin/pip
|
||||||
playback_mode = one-shot
|
playback_mode = one-shot
|
||||||
@ -62,8 +62,9 @@ target_version = git
|
|||||||
tmp_folder = /tmp/
|
tmp_folder = /tmp/
|
||||||
tmp_folder_max_size = 10
|
tmp_folder_max_size = 10
|
||||||
username = botamusique
|
username = botamusique
|
||||||
volume = 0.8
|
volume = 0.1
|
||||||
when_nobody_in_channel = nothing
|
when_nobody_in_channel = nothing
|
||||||
|
youtube_query_cookie =
|
||||||
|
|
||||||
[webinterface]
|
[webinterface]
|
||||||
access_address = http://127.0.0.1:8181
|
access_address = http://127.0.0.1:8181
|
||||||
@ -83,7 +84,7 @@ web_logfile =
|
|||||||
[debug]
|
[debug]
|
||||||
ffmpeg = False
|
ffmpeg = False
|
||||||
mumble_connection = False
|
mumble_connection = False
|
||||||
redirect_ffmpeg_log = False
|
redirect_ffmpeg_log = True
|
||||||
youtube_dl = False
|
youtube_dl = False
|
||||||
|
|
||||||
[radio]
|
[radio]
|
||||||
|
14
interface.py
14
interface.py
@ -163,7 +163,7 @@ def requires_auth(f):
|
|||||||
bad_access_count[request.remote_addr] += 1
|
bad_access_count[request.remote_addr] += 1
|
||||||
log.info(f"web: bad token from ip {request.remote_addr}, "
|
log.info(f"web: bad token from ip {request.remote_addr}, "
|
||||||
f"{bad_access_count[request.remote_addr]} attempts.")
|
f"{bad_access_count[request.remote_addr]} attempts.")
|
||||||
if bad_access_count[request.remote_addr] > var.config.getint("webinterface", "max_attempts"):
|
if bad_access_count[request.remote_addr] > var.config.getint("webinterface", "max_attempts", fallback=10):
|
||||||
banned_ip.append(request.remote_addr)
|
banned_ip.append(request.remote_addr)
|
||||||
log.info(f"web: access banned for {request.remote_addr}")
|
log.info(f"web: access banned for {request.remote_addr}")
|
||||||
else:
|
else:
|
||||||
@ -464,7 +464,7 @@ def post():
|
|||||||
var.music_db.manage_special_tags()
|
var.music_db.manage_special_tags()
|
||||||
log.info("web: Local file cache refreshed.")
|
log.info("web: Local file cache refreshed.")
|
||||||
elif action == "stop":
|
elif action == "stop":
|
||||||
if var.config.getboolean("bot", "clear_when_stop_in_oneshot") \
|
if var.config.getboolean("bot", "clear_when_stop_in_oneshot", fallback=False) \
|
||||||
and var.playlist.mode == 'one-shot':
|
and var.playlist.mode == 'one-shot':
|
||||||
var.bot.clear()
|
var.bot.clear()
|
||||||
else:
|
else:
|
||||||
@ -559,12 +559,12 @@ def library_info():
|
|||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
|
|
||||||
tags = var.music_db.query_all_tags()
|
tags = var.music_db.query_all_tags()
|
||||||
max_upload_file_size = util.parse_file_size(var.config.get("webinterface", "max_upload_file_size"))
|
max_upload_file_size = util.parse_file_size(var.config.get("webinterface", "max_upload_file_size", fallback="30MB"))
|
||||||
|
|
||||||
return jsonify(dict(
|
return jsonify(dict(
|
||||||
dirs=get_all_dirs(),
|
dirs=get_all_dirs(),
|
||||||
upload_enabled=var.config.getboolean("webinterface", "upload_enabled") or var.bot.is_admin(user),
|
upload_enabled=var.config.getboolean("webinterface", "upload_enabled", fallback=True) or var.bot.is_admin(user),
|
||||||
delete_allowed=var.config.getboolean("bot", "delete_allowed") or var.bot.is_admin(user),
|
delete_allowed=var.config.getboolean("bot", "delete_allowed", fallback=True) or var.bot.is_admin(user),
|
||||||
tags=tags,
|
tags=tags,
|
||||||
max_upload_file_size=max_upload_file_size
|
max_upload_file_size=max_upload_file_size
|
||||||
))
|
))
|
||||||
@ -609,7 +609,7 @@ def library():
|
|||||||
|
|
||||||
return redirect("./", code=302)
|
return redirect("./", code=302)
|
||||||
elif payload['action'] == 'delete':
|
elif payload['action'] == 'delete':
|
||||||
if var.config.getboolean("bot", "delete_allowed"):
|
if var.config.getboolean("bot", "delete_allowed", fallback=True):
|
||||||
items = dicts_to_items(var.music_db.query_music(condition))
|
items = dicts_to_items(var.music_db.query_music(condition))
|
||||||
for item in items:
|
for item in items:
|
||||||
var.playlist.remove_by_id(item.id)
|
var.playlist.remove_by_id(item.id)
|
||||||
@ -685,7 +685,7 @@ def library():
|
|||||||
def upload():
|
def upload():
|
||||||
global log
|
global log
|
||||||
|
|
||||||
if not var.config.getboolean("webinterface", "upload_enabled"):
|
if not var.config.getboolean("webinterface", "upload_enabled", fallback=True):
|
||||||
abort(403)
|
abort(403)
|
||||||
|
|
||||||
file = request.files['file']
|
file = request.files['file']
|
||||||
|
@ -396,7 +396,7 @@ class AutoPlaylist(OneshotPlaylist):
|
|||||||
self.mode = "autoplay"
|
self.mode = "autoplay"
|
||||||
|
|
||||||
def refresh(self):
|
def refresh(self):
|
||||||
dicts = var.music_db.query_random_music(var.config.getint("bot", "autoplay_length"),
|
dicts = var.music_db.query_random_music(var.config.getint("bot", "autoplay_length", fallback=5),
|
||||||
Condition().and_not_sub_condition(
|
Condition().and_not_sub_condition(
|
||||||
Condition().and_like('tags', "%don't autoplay,%")))
|
Condition().and_like('tags', "%don't autoplay,%")))
|
||||||
|
|
||||||
|
17
media/url.py
17
media/url.py
@ -131,7 +131,7 @@ class URLItem(BaseItem):
|
|||||||
}
|
}
|
||||||
succeed = False
|
succeed = False
|
||||||
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
|
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
|
||||||
attempts = var.config.getint('bot', 'download_attempts')
|
attempts = var.config.getint('bot', 'download_attempts', fallback=2)
|
||||||
for i in range(attempts):
|
for i in range(attempts):
|
||||||
try:
|
try:
|
||||||
info = ydl.extract_info(self.url, download=False)
|
info = ydl.extract_info(self.url, download=False)
|
||||||
@ -167,24 +167,19 @@ class URLItem(BaseItem):
|
|||||||
'noplaylist': True,
|
'noplaylist': True,
|
||||||
'writethumbnail': True,
|
'writethumbnail': True,
|
||||||
'updatetime': False,
|
'updatetime': False,
|
||||||
'verbose': var.config.getboolean('debug', 'youtube_dl'),
|
'verbose': var.config.getboolean('debug', 'youtube_dl')
|
||||||
'postprocessors': [{
|
|
||||||
'key': 'FFmpegThumbnailsConvertor',
|
|
||||||
'format': 'jpg',
|
|
||||||
'when': 'before_dl'
|
|
||||||
}]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cookie = var.config.get('youtube_dl', 'cookie_file')
|
cookie = var.config.get('youtube_dl', 'cookie_file', fallback=None)
|
||||||
if cookie:
|
if cookie:
|
||||||
ydl_opts['cookiefile'] = var.config.get('youtube_dl', 'cookie_file')
|
ydl_opts['cookiefile'] = var.config.get('youtube_dl', 'cookie_file', fallback=None)
|
||||||
|
|
||||||
user_agent = var.config.get('youtube_dl', 'user_agent')
|
user_agent = var.config.get('youtube_dl', 'user_agent', fallback=None)
|
||||||
if user_agent:
|
if user_agent:
|
||||||
youtube_dl.utils.std_headers['User-Agent'] = var.config.get('youtube_dl', 'user_agent')
|
youtube_dl.utils.std_headers['User-Agent'] = var.config.get('youtube_dl', 'user_agent')
|
||||||
|
|
||||||
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
|
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
|
||||||
attempts = var.config.getint('bot', 'download_attempts')
|
attempts = var.config.getint('bot', 'download_attempts', fallback=2)
|
||||||
download_succeed = False
|
download_succeed = False
|
||||||
for i in range(attempts):
|
for i in range(attempts):
|
||||||
self.log.info("bot: download attempts %d / %d" % (i + 1, attempts))
|
self.log.info("bot: download attempts %d / %d" % (i + 1, attempts))
|
||||||
|
@ -15,16 +15,16 @@ def get_playlist_info(url, start_index=0, user=""):
|
|||||||
'verbose': var.config.getboolean('debug', 'youtube_dl')
|
'verbose': var.config.getboolean('debug', 'youtube_dl')
|
||||||
}
|
}
|
||||||
|
|
||||||
cookie = var.config.get('youtube_dl', 'cookie_file')
|
cookie = var.config.get('youtube_dl', 'cookie_file', fallback=None)
|
||||||
if cookie:
|
if cookie:
|
||||||
ydl_opts['cookiefile'] = var.config.get('youtube_dl', 'cookie_file')
|
ydl_opts['cookiefile'] = var.config.get('youtube_dl', 'cookie_file', fallback=None)
|
||||||
|
|
||||||
user_agent = var.config.get('youtube_dl', 'user_agent')
|
user_agent = var.config.get('youtube_dl', 'user_agent', fallback=None)
|
||||||
if user_agent:
|
if user_agent:
|
||||||
youtube_dl.utils.std_headers['User-Agent'] = var.config.get('youtube_dl', 'user_agent')
|
youtube_dl.utils.std_headers['User-Agent'] = var.config.get('youtube_dl', 'user_agent')
|
||||||
|
|
||||||
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
|
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
|
||||||
attempts = var.config.getint('bot', 'download_attempts')
|
attempts = var.config.getint('bot', 'download_attempts', fallback=2)
|
||||||
for i in range(attempts):
|
for i in range(attempts):
|
||||||
items = []
|
items = []
|
||||||
try:
|
try:
|
||||||
|
42
mumbleBot.py
42
mumbleBot.py
@ -40,12 +40,12 @@ class MumbleBot:
|
|||||||
signal.signal(signal.SIGINT, self.ctrl_caught)
|
signal.signal(signal.SIGINT, self.ctrl_caught)
|
||||||
self.cmd_handle = {}
|
self.cmd_handle = {}
|
||||||
|
|
||||||
self.stereo = var.config.getboolean('bot', 'stereo')
|
self.stereo = var.config.getboolean('bot', 'stereo', fallback=True)
|
||||||
|
|
||||||
if args.channel:
|
if args.channel:
|
||||||
self.channel = args.channel
|
self.channel = args.channel
|
||||||
else:
|
else:
|
||||||
self.channel = var.config.get("server", "channel")
|
self.channel = var.config.get("server", "channel", fallback=None)
|
||||||
|
|
||||||
var.user = args.user
|
var.user = args.user
|
||||||
var.is_proxified = var.config.getboolean(
|
var.is_proxified = var.config.getboolean(
|
||||||
@ -137,7 +137,7 @@ class MumbleBot:
|
|||||||
# ====== Volume ======
|
# ====== Volume ======
|
||||||
self.volume_helper = util.VolumeHelper()
|
self.volume_helper = util.VolumeHelper()
|
||||||
|
|
||||||
_volume = var.config.getfloat('bot', 'volume')
|
_volume = var.config.getfloat('bot', 'volume', fallback=0.8)
|
||||||
if var.db.has_option('bot', 'volume'):
|
if var.db.has_option('bot', 'volume'):
|
||||||
_volume = var.db.getfloat('bot', 'volume')
|
_volume = var.db.getfloat('bot', 'volume')
|
||||||
self.volume_helper.set_volume(_volume)
|
self.volume_helper.set_volume(_volume)
|
||||||
@ -148,14 +148,14 @@ class MumbleBot:
|
|||||||
self.last_volume_cycle_time = time.time()
|
self.last_volume_cycle_time = time.time()
|
||||||
|
|
||||||
self._ducking_volume = 0
|
self._ducking_volume = 0
|
||||||
_ducking_volume = var.config.getfloat("bot", "ducking_volume")
|
_ducking_volume = var.config.getfloat("bot", "ducking_volume", fallback=0.50)
|
||||||
_ducking_volume = var.db.getfloat("bot", "ducking_volume", fallback=_ducking_volume)
|
_ducking_volume = var.db.getfloat("bot", "ducking_volume", fallback=_ducking_volume)
|
||||||
self.volume_helper.set_ducking_volume(_ducking_volume)
|
self.volume_helper.set_ducking_volume(_ducking_volume)
|
||||||
|
|
||||||
self.ducking_threshold = var.config.getfloat("bot", "ducking_threshold")
|
self.ducking_threshold = var.config.getfloat("bot", "ducking_threshold", fallback=5000)
|
||||||
self.ducking_threshold = var.db.getfloat("bot", "ducking_threshold", fallback=self.ducking_threshold)
|
self.ducking_threshold = var.db.getfloat("bot", "ducking_threshold", fallback=self.ducking_threshold)
|
||||||
|
|
||||||
if not var.db.has_option("bot", "ducking") and var.config.getboolean("bot", "ducking") \
|
if not var.db.has_option("bot", "ducking") and var.config.getboolean("bot", "ducking", fallback=False) \
|
||||||
or var.config.getboolean("bot", "ducking"):
|
or var.config.getboolean("bot", "ducking"):
|
||||||
self.is_ducking = True
|
self.is_ducking = True
|
||||||
self.mumble.callbacks.set_callback(pymumble.constants.PYMUMBLE_CLBK_SOUNDRECEIVED,
|
self.mumble.callbacks.set_callback(pymumble.constants.PYMUMBLE_CLBK_SOUNDRECEIVED,
|
||||||
@ -165,7 +165,7 @@ class MumbleBot:
|
|||||||
assert var.config.get("bot", "when_nobody_in_channel") in ['pause', 'pause_resume', 'stop', 'nothing', ''], \
|
assert var.config.get("bot", "when_nobody_in_channel") in ['pause', 'pause_resume', 'stop', 'nothing', ''], \
|
||||||
"Unknown action for when_nobody_in_channel"
|
"Unknown action for when_nobody_in_channel"
|
||||||
|
|
||||||
if var.config.get("bot", "when_nobody_in_channel") in ['pause', 'pause_resume', 'stop']:
|
if var.config.get("bot", "when_nobody_in_channel", fallback='') in ['pause', 'pause_resume', 'stop']:
|
||||||
user_change_callback = \
|
user_change_callback = \
|
||||||
lambda user, action: threading.Thread(target=self.users_changed,
|
lambda user, action: threading.Thread(target=self.users_changed,
|
||||||
args=(user, action), daemon=True).start()
|
args=(user, action), daemon=True).start()
|
||||||
@ -177,7 +177,7 @@ class MumbleBot:
|
|||||||
self._display_rms = False
|
self._display_rms = False
|
||||||
self._max_rms = 0
|
self._max_rms = 0
|
||||||
|
|
||||||
self.redirect_ffmpeg_log = var.config.getboolean('debug', 'redirect_ffmpeg_log')
|
self.redirect_ffmpeg_log = var.config.getboolean('debug', 'redirect_ffmpeg_log', fallback=True)
|
||||||
|
|
||||||
if var.config.getboolean("bot", "auto_check_update"):
|
if var.config.getboolean("bot", "auto_check_update"):
|
||||||
def check_update():
|
def check_update():
|
||||||
@ -202,8 +202,8 @@ class MumbleBot:
|
|||||||
self.log.info(
|
self.log.info(
|
||||||
"\nSIGINT caught, quitting, {} more to kill".format(2 - self.nb_exit))
|
"\nSIGINT caught, quitting, {} more to kill".format(2 - self.nb_exit))
|
||||||
|
|
||||||
if var.config.getboolean('bot', 'save_playlist') \
|
if var.config.getboolean('bot', 'save_playlist', fallback=True) \
|
||||||
and var.config.get("bot", "save_music_library"):
|
and var.config.get("bot", "save_music_library", fallback=True):
|
||||||
self.log.info("bot: save playlist into database")
|
self.log.info("bot: save playlist into database")
|
||||||
var.playlist.save()
|
var.playlist.save()
|
||||||
|
|
||||||
@ -235,7 +235,7 @@ class MumbleBot:
|
|||||||
self.mumble.users.myself.comment(var.config.get('bot', 'comment'))
|
self.mumble.users.myself.comment(var.config.get('bot', 'comment'))
|
||||||
|
|
||||||
def set_avatar(self):
|
def set_avatar(self):
|
||||||
avatar_path = var.config.get('bot', 'avatar')
|
avatar_path = var.config.get('bot', 'avatar', fallback=None)
|
||||||
|
|
||||||
if avatar_path:
|
if avatar_path:
|
||||||
with open(avatar_path, 'rb') as avatar_file:
|
with open(avatar_path, 'rb') as avatar_file:
|
||||||
@ -598,8 +598,8 @@ class MumbleBot:
|
|||||||
|
|
||||||
if self.exit:
|
if self.exit:
|
||||||
self._loop_status = "exited"
|
self._loop_status = "exited"
|
||||||
if var.config.getboolean('bot', 'save_playlist') \
|
if var.config.getboolean('bot', 'save_playlist', fallback=True) \
|
||||||
and var.config.get("bot", "save_music_library"):
|
and var.config.get("bot", "save_music_library", fallback=True):
|
||||||
self.log.info("bot: save playlist into database")
|
self.log.info("bot: save playlist into database")
|
||||||
var.playlist.save()
|
var.playlist.save()
|
||||||
|
|
||||||
@ -841,7 +841,7 @@ if __name__ == '__main__':
|
|||||||
if logfile:
|
if logfile:
|
||||||
print(f"Redirecting stdout and stderr to log file: {logfile}")
|
print(f"Redirecting stdout and stderr to log file: {logfile}")
|
||||||
handler = logging.handlers.RotatingFileHandler(logfile, mode='a', maxBytes=10240, backupCount=3) # Rotate after 10KB, leave 3 old logs
|
handler = logging.handlers.RotatingFileHandler(logfile, mode='a', maxBytes=10240, backupCount=3) # Rotate after 10KB, leave 3 old logs
|
||||||
if var.config.getboolean("bot", "redirect_stderr"):
|
if var.config.getboolean("bot", "redirect_stderr", fallback=False):
|
||||||
sys.stderr = util.LoggerIOWrapper(bot_logger, logging.INFO,
|
sys.stderr = util.LoggerIOWrapper(bot_logger, logging.INFO,
|
||||||
fallback_io_buffer=sys.stderr.buffer)
|
fallback_io_buffer=sys.stderr.buffer)
|
||||||
else:
|
else:
|
||||||
@ -862,13 +862,13 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
sanitized_username = "".join([x if x.isalnum() else "_" for x in username])
|
sanitized_username = "".join([x if x.isalnum() else "_" for x in username])
|
||||||
var.settings_db_path = args.db if args.db is not None else util.solve_filepath(
|
var.settings_db_path = args.db if args.db is not None else util.solve_filepath(
|
||||||
config.get("bot", "database_path") or f"settings-{sanitized_username}.db")
|
config.get("bot", "database_path", fallback="") or f"settings-{sanitized_username}.db")
|
||||||
var.music_db_path = args.music_db if args.music_db is not None else util.solve_filepath(
|
var.music_db_path = args.music_db if args.music_db is not None else util.solve_filepath(
|
||||||
config.get("bot", "music_database_path"))
|
config.get("bot", "music_database_path", fallback="") or "music.db")
|
||||||
|
|
||||||
var.db = SettingsDatabase(var.settings_db_path)
|
var.db = SettingsDatabase(var.settings_db_path)
|
||||||
|
|
||||||
if var.config.get("bot", "save_music_library"):
|
if var.config.get("bot", "save_music_library", fallback=True):
|
||||||
var.music_db = MusicDatabase(var.music_db_path)
|
var.music_db = MusicDatabase(var.music_db_path)
|
||||||
else:
|
else:
|
||||||
var.music_db = MusicDatabase(":memory:")
|
var.music_db = MusicDatabase(":memory:")
|
||||||
@ -889,7 +889,7 @@ if __name__ == '__main__':
|
|||||||
if args.lang:
|
if args.lang:
|
||||||
lang = args.lang
|
lang = args.lang
|
||||||
else:
|
else:
|
||||||
lang = var.config.get('bot', 'language')
|
lang = var.config.get('bot', 'language', fallback='en_US')
|
||||||
|
|
||||||
if lang not in supported_languages:
|
if lang not in supported_languages:
|
||||||
raise KeyError(f"Unsupported language {lang}")
|
raise KeyError(f"Unsupported language {lang}")
|
||||||
@ -901,7 +901,7 @@ if __name__ == '__main__':
|
|||||||
# ======================
|
# ======================
|
||||||
var.cache = MusicCache(var.music_db)
|
var.cache = MusicCache(var.music_db)
|
||||||
|
|
||||||
if var.config.getboolean("bot", "refresh_cache_on_startup"):
|
if var.config.getboolean("bot", "refresh_cache_on_startup", fallback=True):
|
||||||
var.cache.build_dir_cache()
|
var.cache.build_dir_cache()
|
||||||
|
|
||||||
# ======================
|
# ======================
|
||||||
@ -911,7 +911,7 @@ if __name__ == '__main__':
|
|||||||
if var.db.has_option("playlist", "playback_mode"):
|
if var.db.has_option("playlist", "playback_mode"):
|
||||||
playback_mode = var.db.get('playlist', 'playback_mode')
|
playback_mode = var.db.get('playlist', 'playback_mode')
|
||||||
else:
|
else:
|
||||||
playback_mode = var.config.get('bot', 'playback_mode')
|
playback_mode = var.config.get('bot', 'playback_mode', fallback="one-shot")
|
||||||
|
|
||||||
if playback_mode in ["one-shot", "repeat", "random", "autoplay"]:
|
if playback_mode in ["one-shot", "repeat", "random", "autoplay"]:
|
||||||
var.playlist = media.playlist.get_playlist(playback_mode)
|
var.playlist = media.playlist.get_playlist(playback_mode)
|
||||||
@ -925,7 +925,7 @@ if __name__ == '__main__':
|
|||||||
command.register_all_commands(var.bot)
|
command.register_all_commands(var.bot)
|
||||||
|
|
||||||
# load playlist
|
# load playlist
|
||||||
if var.config.getboolean('bot', 'save_playlist'):
|
if var.config.getboolean('bot', 'save_playlist', fallback=True):
|
||||||
var.bot_logger.info("bot: load playlist from previous session")
|
var.bot_logger.info("bot: load playlist from previous session")
|
||||||
var.playlist.load()
|
var.playlist.load()
|
||||||
|
|
||||||
|
15
util.py
15
util.py
@ -323,8 +323,7 @@ def youtube_search(query):
|
|||||||
import json
|
import json
|
||||||
|
|
||||||
try:
|
try:
|
||||||
cookie_file = var.config.get('youtube_dl', 'cookie_file')
|
cookie = json.loads(var.config.get('bot', 'youtube_query_cookie', fallback='{}'))
|
||||||
cookie = parse_cookie_file(cookie_file) if cookie_file else {}
|
|
||||||
r = requests.get("https://www.youtube.com/results", cookies=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)
|
||||||
@ -575,15 +574,3 @@ def check_extra_config(config, template):
|
|||||||
extra.append((key, opt))
|
extra.append((key, opt))
|
||||||
|
|
||||||
return extra
|
return extra
|
||||||
|
|
||||||
|
|
||||||
def parse_cookie_file(cookiefile):
|
|
||||||
# https://stackoverflow.com/a/54659484/1584825
|
|
||||||
|
|
||||||
cookies = {}
|
|
||||||
with open (cookiefile, 'r') as fp:
|
|
||||||
for line in fp:
|
|
||||||
if not re.match(r'^#', line):
|
|
||||||
lineFields = line.strip().split('\t')
|
|
||||||
cookies[lineFields[5]] = lineFields[6]
|
|
||||||
return cookies
|
|
||||||
|
118
web/package-lock.json
generated
118
web/package-lock.json
generated
@ -1987,16 +1987,16 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/browserslist": {
|
"node_modules/browserslist": {
|
||||||
"version": "4.19.1",
|
"version": "4.14.7",
|
||||||
"resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.19.1.tgz",
|
"resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.14.7.tgz",
|
||||||
"integrity": "sha512-u2tbbG5PdKRTUoctO3NBD8FQ5HdPh1ZXPHzp1rwaa5jTc+RV9/+RlWiAIKmjRPQF+xbGM9Kklj5bZQFa2s/38A==",
|
"integrity": "sha512-BSVRLCeG3Xt/j/1cCGj1019Wbty0H+Yvu2AOuZSuoaUWn3RatbL33Cxk+Q4jRMRAbOm0p7SLravLjpnT6s0vzQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"caniuse-lite": "^1.0.30001286",
|
"caniuse-lite": "^1.0.30001157",
|
||||||
"electron-to-chromium": "^1.4.17",
|
"colorette": "^1.2.1",
|
||||||
|
"electron-to-chromium": "^1.3.591",
|
||||||
"escalade": "^3.1.1",
|
"escalade": "^3.1.1",
|
||||||
"node-releases": "^2.0.1",
|
"node-releases": "^1.1.66"
|
||||||
"picocolors": "^1.0.0"
|
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"browserslist": "cli.js"
|
"browserslist": "cli.js"
|
||||||
@ -2060,14 +2060,10 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/caniuse-lite": {
|
"node_modules/caniuse-lite": {
|
||||||
"version": "1.0.30001304",
|
"version": "1.0.30001161",
|
||||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001304.tgz",
|
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001161.tgz",
|
||||||
"integrity": "sha512-bdsfZd6K6ap87AGqSHJP/s1V+U6Z5lyrcbBu3ovbCCf8cSYpwTtGrCBObMpJqwxfTbLW6YTIdbb1jEeTelcpYQ==",
|
"integrity": "sha512-JharrCDxOqPLBULF9/SPa6yMcBRTjZARJ6sc3cuKrPfyIk64JN6kuMINWqA99Xc8uElMFcROliwtz0n9pYej+g==",
|
||||||
"dev": true,
|
"dev": true
|
||||||
"funding": {
|
|
||||||
"type": "opencollective",
|
|
||||||
"url": "https://opencollective.com/browserslist"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"node_modules/chalk": {
|
"node_modules/chalk": {
|
||||||
"version": "2.4.2",
|
"version": "2.4.2",
|
||||||
@ -2515,9 +2511,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/electron-to-chromium": {
|
"node_modules/electron-to-chromium": {
|
||||||
"version": "1.4.60",
|
"version": "1.3.607",
|
||||||
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.60.tgz",
|
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.607.tgz",
|
||||||
"integrity": "sha512-h53hbEiKC6hijelDgxgkgAUC3PKyR7TmIfvjHnBjUGPMg/3sBuTyG6eDormw+lY24uUJvHkUPzB8dpK8b2u3Sw==",
|
"integrity": "sha512-h2SYNaBnlplGS0YyXl8oJWokfcNxVjJANQfMCsQefG6OSuAuNIeW+A8yGT/ci+xRoBb3k2zq1FrOvkgoKBol8g==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/emoji-regex": {
|
"node_modules/emoji-regex": {
|
||||||
@ -3409,9 +3405,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/glob-parent": {
|
"node_modules/glob-parent": {
|
||||||
"version": "5.1.2",
|
"version": "5.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.1.tgz",
|
||||||
"integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==",
|
"integrity": "sha512-FnI+VGOpnlGHWZxthPGR+QhR78fuiK0sNLkHQv+bL9fQi57lNNdquIbna/WrfROrolq8GK5Ek6BiMwqL/voRYQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"is-glob": "^4.0.1"
|
"is-glob": "^4.0.1"
|
||||||
@ -4304,9 +4300,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/nanoid": {
|
"node_modules/nanoid": {
|
||||||
"version": "3.2.0",
|
"version": "3.1.23",
|
||||||
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.23.tgz",
|
||||||
"integrity": "sha512-fmsZYa9lpn69Ad5eDn7FMcnnSR+8R34W9qJEijxYhTbfOWzr22n1QxCMzXLK+ODyW2973V3Fux959iQoUxzUIA==",
|
"integrity": "sha512-FiB0kzdP0FFVGDKlRLEQ1BgDzU87dy5NnzjeW9YZNt+/c3+q82EQDUwniSAUxp/F0gFNI1ZhKU1FqYsMuqZVnw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"bin": {
|
"bin": {
|
||||||
"nanoid": "bin/nanoid.cjs"
|
"nanoid": "bin/nanoid.cjs"
|
||||||
@ -4338,9 +4334,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/node-releases": {
|
"node_modules/node-releases": {
|
||||||
"version": "2.0.1",
|
"version": "1.1.67",
|
||||||
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.67.tgz",
|
||||||
"integrity": "sha512-CqyzN6z7Q6aMeF/ktcMVTzhAHCEpf8SOarwpzpf8pNBY2k5/oM34UHldUwp8VKI7uxct2HxSRdJjBaZeESzcxA==",
|
"integrity": "sha512-V5QF9noGFl3EymEwUYzO+3NTDpGfQB4ve6Qfnzf3UNydMhjQRVPR1DZTuvWiLzaFJYw2fmDwAfnRNEVb64hSIg==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/normalize-package-data": {
|
"node_modules/normalize-package-data": {
|
||||||
@ -4672,9 +4668,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/path-parse": {
|
"node_modules/path-parse": {
|
||||||
"version": "1.0.7",
|
"version": "1.0.6",
|
||||||
"resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz",
|
"resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz",
|
||||||
"integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==",
|
"integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/path-type": {
|
"node_modules/path-type": {
|
||||||
@ -4686,12 +4682,6 @@
|
|||||||
"node": ">=8"
|
"node": ">=8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/picocolors": {
|
|
||||||
"version": "1.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz",
|
|
||||||
"integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"node_modules/picomatch": {
|
"node_modules/picomatch": {
|
||||||
"version": "2.2.2",
|
"version": "2.2.2",
|
||||||
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.2.tgz",
|
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.2.tgz",
|
||||||
@ -7993,16 +7983,16 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"browserslist": {
|
"browserslist": {
|
||||||
"version": "4.19.1",
|
"version": "4.14.7",
|
||||||
"resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.19.1.tgz",
|
"resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.14.7.tgz",
|
||||||
"integrity": "sha512-u2tbbG5PdKRTUoctO3NBD8FQ5HdPh1ZXPHzp1rwaa5jTc+RV9/+RlWiAIKmjRPQF+xbGM9Kklj5bZQFa2s/38A==",
|
"integrity": "sha512-BSVRLCeG3Xt/j/1cCGj1019Wbty0H+Yvu2AOuZSuoaUWn3RatbL33Cxk+Q4jRMRAbOm0p7SLravLjpnT6s0vzQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"caniuse-lite": "^1.0.30001286",
|
"caniuse-lite": "^1.0.30001157",
|
||||||
"electron-to-chromium": "^1.4.17",
|
"colorette": "^1.2.1",
|
||||||
|
"electron-to-chromium": "^1.3.591",
|
||||||
"escalade": "^3.1.1",
|
"escalade": "^3.1.1",
|
||||||
"node-releases": "^2.0.1",
|
"node-releases": "^1.1.66"
|
||||||
"picocolors": "^1.0.0"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"buffer-from": {
|
"buffer-from": {
|
||||||
@ -8044,9 +8034,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"caniuse-lite": {
|
"caniuse-lite": {
|
||||||
"version": "1.0.30001304",
|
"version": "1.0.30001161",
|
||||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001304.tgz",
|
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001161.tgz",
|
||||||
"integrity": "sha512-bdsfZd6K6ap87AGqSHJP/s1V+U6Z5lyrcbBu3ovbCCf8cSYpwTtGrCBObMpJqwxfTbLW6YTIdbb1jEeTelcpYQ==",
|
"integrity": "sha512-JharrCDxOqPLBULF9/SPa6yMcBRTjZARJ6sc3cuKrPfyIk64JN6kuMINWqA99Xc8uElMFcROliwtz0n9pYej+g==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"chalk": {
|
"chalk": {
|
||||||
@ -8398,9 +8388,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"electron-to-chromium": {
|
"electron-to-chromium": {
|
||||||
"version": "1.4.60",
|
"version": "1.3.607",
|
||||||
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.60.tgz",
|
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.607.tgz",
|
||||||
"integrity": "sha512-h53hbEiKC6hijelDgxgkgAUC3PKyR7TmIfvjHnBjUGPMg/3sBuTyG6eDormw+lY24uUJvHkUPzB8dpK8b2u3Sw==",
|
"integrity": "sha512-h2SYNaBnlplGS0YyXl8oJWokfcNxVjJANQfMCsQefG6OSuAuNIeW+A8yGT/ci+xRoBb3k2zq1FrOvkgoKBol8g==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"emoji-regex": {
|
"emoji-regex": {
|
||||||
@ -9084,9 +9074,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"glob-parent": {
|
"glob-parent": {
|
||||||
"version": "5.1.2",
|
"version": "5.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.1.tgz",
|
||||||
"integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==",
|
"integrity": "sha512-FnI+VGOpnlGHWZxthPGR+QhR78fuiK0sNLkHQv+bL9fQi57lNNdquIbna/WrfROrolq8GK5Ek6BiMwqL/voRYQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"is-glob": "^4.0.1"
|
"is-glob": "^4.0.1"
|
||||||
@ -9754,9 +9744,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"nanoid": {
|
"nanoid": {
|
||||||
"version": "3.2.0",
|
"version": "3.1.23",
|
||||||
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.23.tgz",
|
||||||
"integrity": "sha512-fmsZYa9lpn69Ad5eDn7FMcnnSR+8R34W9qJEijxYhTbfOWzr22n1QxCMzXLK+ODyW2973V3Fux959iQoUxzUIA==",
|
"integrity": "sha512-FiB0kzdP0FFVGDKlRLEQ1BgDzU87dy5NnzjeW9YZNt+/c3+q82EQDUwniSAUxp/F0gFNI1ZhKU1FqYsMuqZVnw==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"natural-compare": {
|
"natural-compare": {
|
||||||
@ -9782,9 +9772,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node-releases": {
|
"node-releases": {
|
||||||
"version": "2.0.1",
|
"version": "1.1.67",
|
||||||
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.67.tgz",
|
||||||
"integrity": "sha512-CqyzN6z7Q6aMeF/ktcMVTzhAHCEpf8SOarwpzpf8pNBY2k5/oM34UHldUwp8VKI7uxct2HxSRdJjBaZeESzcxA==",
|
"integrity": "sha512-V5QF9noGFl3EymEwUYzO+3NTDpGfQB4ve6Qfnzf3UNydMhjQRVPR1DZTuvWiLzaFJYw2fmDwAfnRNEVb64hSIg==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"normalize-package-data": {
|
"normalize-package-data": {
|
||||||
@ -10039,9 +10029,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"path-parse": {
|
"path-parse": {
|
||||||
"version": "1.0.7",
|
"version": "1.0.6",
|
||||||
"resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz",
|
"resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz",
|
||||||
"integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==",
|
"integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"path-type": {
|
"path-type": {
|
||||||
@ -10050,12 +10040,6 @@
|
|||||||
"integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==",
|
"integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"picocolors": {
|
|
||||||
"version": "1.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz",
|
|
||||||
"integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"picomatch": {
|
"picomatch": {
|
||||||
"version": "2.2.2",
|
"version": "2.2.2",
|
||||||
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.2.tgz",
|
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.2.tgz",
|
||||||
|
Loading…
Reference in New Issue
Block a user