fixed: playlist update problem in web interface
This commit is contained in:
parent
bbe208d162
commit
b18c70c146
@ -1,4 +1,4 @@
|
||||
# botamusique
|
||||
# <img src="static/image/logo.png" alt="botamusique" style="zoom:33%;" /> botamusique
|
||||
|
||||
Botamusique is a [Mumble](https://www.mumble.info/) music bot.
|
||||
Predicted functionalities will be those people would expect from any classic music player.
|
||||
@ -24,7 +24,6 @@ Predicted functionalities will be those people would expect from any classic mus
|
||||
|
||||

|
||||
|
||||
|
||||
-----
|
||||
## Menu
|
||||
1. [Installation](#installation)
|
||||
|
25
command.py
25
command.py
@ -238,10 +238,11 @@ def cmd_play_file(bot, user, text, command, parameter, do_not_refresh_cache=Fals
|
||||
msgs = [constants.strings('multiple_file_added')]
|
||||
|
||||
for music_wrapper in music_wrappers:
|
||||
var.playlist.append(music_wrapper)
|
||||
log.info("cmd: add to playlist: " + music_wrapper.format_debug_string())
|
||||
msgs.append("{} ({})".format(music_wrapper.item().title, music_wrapper.item().path))
|
||||
|
||||
var.playlist.extend(music_wrappers)
|
||||
|
||||
send_multi_lines(bot, msgs, None)
|
||||
return
|
||||
|
||||
@ -1035,6 +1036,22 @@ def cmd_search_library(bot, user, text, command, parameter):
|
||||
|
||||
def cmd_shortlist(bot, user, text, command, parameter):
|
||||
global song_shortlist, log
|
||||
if parameter.strip() == "*":
|
||||
msgs = [constants.strings('multiple_file_added') + "<ul>"]
|
||||
music_wrappers = []
|
||||
for kwargs in song_shortlist:
|
||||
kwargs['user'] = user
|
||||
music_wrapper = get_cached_wrapper_from_scrap(bot, **kwargs)
|
||||
music_wrappers.append(music_wrapper)
|
||||
log.info("cmd: add to playlist: " + music_wrapper.format_debug_string())
|
||||
msgs.append("<li>[{}] <b>{}</b></li>".format(music_wrapper.item().type, music_wrapper.item().title))
|
||||
|
||||
var.playlist.extend(music_wrappers)
|
||||
|
||||
msgs.append("</ul>")
|
||||
send_multi_lines(bot, msgs, None, "")
|
||||
return
|
||||
|
||||
try:
|
||||
indexes = [int(i) for i in parameter.split(" ")]
|
||||
except ValueError:
|
||||
@ -1043,18 +1060,22 @@ def cmd_shortlist(bot, user, text, command, parameter):
|
||||
|
||||
if len(indexes) > 1:
|
||||
msgs = [constants.strings('multiple_file_added') + "<ul>"]
|
||||
music_wrappers = []
|
||||
for index in indexes:
|
||||
if 1 <= index <= len(song_shortlist):
|
||||
kwargs = song_shortlist[index - 1]
|
||||
kwargs['user'] = user
|
||||
music_wrapper = get_cached_wrapper_from_scrap(bot, **kwargs)
|
||||
var.playlist.append(music_wrapper)
|
||||
music_wrappers.append(music_wrapper)
|
||||
log.info("cmd: add to playlist: " + music_wrapper.format_debug_string())
|
||||
msgs.append("<li>[{}] <b>{}</b></li>".format(music_wrapper.item().type, music_wrapper.item().title))
|
||||
else:
|
||||
var.playlist.extend(music_wrappers)
|
||||
bot.send_msg(constants.strings('bad_parameter', command=command), text)
|
||||
return
|
||||
|
||||
var.playlist.extend(music_wrappers)
|
||||
|
||||
msgs.append("</ul>")
|
||||
send_multi_lines(bot, msgs, None, "")
|
||||
return
|
||||
|
@ -61,7 +61,7 @@ class ReverseProxied(object):
|
||||
|
||||
|
||||
web = Flask(__name__)
|
||||
web.config['TEMPLATES_AUTO_RELOAD'] = True
|
||||
#web.config['TEMPLATES_AUTO_RELOAD'] = True
|
||||
log = logging.getLogger("bot")
|
||||
user = 'Remote Control'
|
||||
|
||||
@ -463,12 +463,15 @@ def library():
|
||||
|
||||
if request.form['action'] == 'add':
|
||||
items = dicts_to_items(var.bot, var.music_db.query_music(condition))
|
||||
music_wrappers = []
|
||||
for item in items:
|
||||
music_wrapper = get_cached_wrapper(item, user)
|
||||
var.playlist.append(music_wrapper)
|
||||
music_wrappers.append(music_wrapper)
|
||||
|
||||
log.info("cmd: add to playlist: " + music_wrapper.format_debug_string())
|
||||
|
||||
var.playlist.extend(music_wrappers)
|
||||
|
||||
return redirect("./", code=302)
|
||||
elif request.form['action'] == 'delete':
|
||||
items = dicts_to_items(var.bot, var.music_db.query_music(condition))
|
||||
|
2
static/css/bootstrap.min.css
vendored
2
static/css/bootstrap.min.css
vendored
File diff suppressed because one or more lines are too long
BIN
static/image/logo.png
Normal file
BIN
static/image/logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
@ -14,7 +14,7 @@
|
||||
<div class="container">
|
||||
<div class="bs-docs-section">
|
||||
<div class="page-header" id="banner">
|
||||
<h1><i class="fa fa-music" aria-hidden="true"></i> botamusique Web Interface</h1>
|
||||
<h1><img src="static/image/logo.png" style="width: 200px;" /> botamusique Web Interface</h1>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bs-docs-section">
|
||||
@ -96,7 +96,7 @@
|
||||
</tr>
|
||||
<tr id="playlist-expand" class="table-dark" style="display: none;">
|
||||
<td colspan="4" style="text-align:center;">
|
||||
<a class="text-muted" href="javascript:">See items <span class="playlist-expand-item-range"></span> on the playlist.</a>
|
||||
<a class="text-muted" href="javascript:">See item <span class="playlist-expand-item-range"></span> on the playlist.</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="playlist-item-template" style="display: none;">
|
||||
@ -650,7 +650,8 @@
|
||||
updatePlaylist();
|
||||
}
|
||||
if(data.current_index !== playlist_current_index){
|
||||
if(data.current_index > playlist_range_to || data.current_index < playlist_range_from){
|
||||
if((data.current_index > playlist_range_to || data.current_index < playlist_range_from)
|
||||
&& data.current_index !== -1) {
|
||||
playlist_range_from = 0;
|
||||
playlist_range_to = 0;
|
||||
updatePlaylist();
|
||||
|
Loading…
x
Reference in New Issue
Block a user