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.
|
Botamusique is a [Mumble](https://www.mumble.info/) music bot.
|
||||||
Predicted functionalities will be those people would expect from any classic music player.
|
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
|
## Menu
|
||||||
1. [Installation](#installation)
|
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')]
|
msgs = [constants.strings('multiple_file_added')]
|
||||||
|
|
||||||
for music_wrapper in music_wrappers:
|
for music_wrapper in music_wrappers:
|
||||||
var.playlist.append(music_wrapper)
|
|
||||||
log.info("cmd: add to playlist: " + music_wrapper.format_debug_string())
|
log.info("cmd: add to playlist: " + music_wrapper.format_debug_string())
|
||||||
msgs.append("{} ({})".format(music_wrapper.item().title, music_wrapper.item().path))
|
msgs.append("{} ({})".format(music_wrapper.item().title, music_wrapper.item().path))
|
||||||
|
|
||||||
|
var.playlist.extend(music_wrappers)
|
||||||
|
|
||||||
send_multi_lines(bot, msgs, None)
|
send_multi_lines(bot, msgs, None)
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -1035,6 +1036,22 @@ def cmd_search_library(bot, user, text, command, parameter):
|
|||||||
|
|
||||||
def cmd_shortlist(bot, user, text, command, parameter):
|
def cmd_shortlist(bot, user, text, command, parameter):
|
||||||
global song_shortlist, log
|
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:
|
try:
|
||||||
indexes = [int(i) for i in parameter.split(" ")]
|
indexes = [int(i) for i in parameter.split(" ")]
|
||||||
except ValueError:
|
except ValueError:
|
||||||
@ -1043,18 +1060,22 @@ def cmd_shortlist(bot, user, text, command, parameter):
|
|||||||
|
|
||||||
if len(indexes) > 1:
|
if len(indexes) > 1:
|
||||||
msgs = [constants.strings('multiple_file_added') + "<ul>"]
|
msgs = [constants.strings('multiple_file_added') + "<ul>"]
|
||||||
|
music_wrappers = []
|
||||||
for index in indexes:
|
for index in indexes:
|
||||||
if 1 <= index <= len(song_shortlist):
|
if 1 <= index <= len(song_shortlist):
|
||||||
kwargs = song_shortlist[index - 1]
|
kwargs = song_shortlist[index - 1]
|
||||||
kwargs['user'] = user
|
kwargs['user'] = user
|
||||||
music_wrapper = get_cached_wrapper_from_scrap(bot, **kwargs)
|
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())
|
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))
|
msgs.append("<li>[{}] <b>{}</b></li>".format(music_wrapper.item().type, music_wrapper.item().title))
|
||||||
else:
|
else:
|
||||||
|
var.playlist.extend(music_wrappers)
|
||||||
bot.send_msg(constants.strings('bad_parameter', command=command), text)
|
bot.send_msg(constants.strings('bad_parameter', command=command), text)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
var.playlist.extend(music_wrappers)
|
||||||
|
|
||||||
msgs.append("</ul>")
|
msgs.append("</ul>")
|
||||||
send_multi_lines(bot, msgs, None, "")
|
send_multi_lines(bot, msgs, None, "")
|
||||||
return
|
return
|
||||||
|
@ -61,7 +61,7 @@ class ReverseProxied(object):
|
|||||||
|
|
||||||
|
|
||||||
web = Flask(__name__)
|
web = Flask(__name__)
|
||||||
web.config['TEMPLATES_AUTO_RELOAD'] = True
|
#web.config['TEMPLATES_AUTO_RELOAD'] = True
|
||||||
log = logging.getLogger("bot")
|
log = logging.getLogger("bot")
|
||||||
user = 'Remote Control'
|
user = 'Remote Control'
|
||||||
|
|
||||||
@ -463,12 +463,15 @@ def library():
|
|||||||
|
|
||||||
if request.form['action'] == 'add':
|
if request.form['action'] == 'add':
|
||||||
items = dicts_to_items(var.bot, var.music_db.query_music(condition))
|
items = dicts_to_items(var.bot, var.music_db.query_music(condition))
|
||||||
|
music_wrappers = []
|
||||||
for item in items:
|
for item in items:
|
||||||
music_wrapper = get_cached_wrapper(item, user)
|
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())
|
log.info("cmd: add to playlist: " + music_wrapper.format_debug_string())
|
||||||
|
|
||||||
|
var.playlist.extend(music_wrappers)
|
||||||
|
|
||||||
return redirect("./", code=302)
|
return redirect("./", code=302)
|
||||||
elif request.form['action'] == 'delete':
|
elif request.form['action'] == 'delete':
|
||||||
items = dicts_to_items(var.bot, var.music_db.query_music(condition))
|
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="container">
|
||||||
<div class="bs-docs-section">
|
<div class="bs-docs-section">
|
||||||
<div class="page-header" id="banner">
|
<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>
|
</div>
|
||||||
<div class="bs-docs-section">
|
<div class="bs-docs-section">
|
||||||
@ -96,7 +96,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr id="playlist-expand" class="table-dark" style="display: none;">
|
<tr id="playlist-expand" class="table-dark" style="display: none;">
|
||||||
<td colspan="4" style="text-align:center;">
|
<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>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="playlist-item-template" style="display: none;">
|
<tr class="playlist-item-template" style="display: none;">
|
||||||
@ -650,7 +650,8 @@
|
|||||||
updatePlaylist();
|
updatePlaylist();
|
||||||
}
|
}
|
||||||
if(data.current_index !== playlist_current_index){
|
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_from = 0;
|
||||||
playlist_range_to = 0;
|
playlist_range_to = 0;
|
||||||
updatePlaylist();
|
updatePlaylist();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user