Add more controls (#71)
* add more ducking command * fix current music command * provide more controls, like pause, resume, clear. * add more controls in the web interface * refactored and improved: 1. move get_music_tag_info to util, and 2. refined logic related to it. 3. now playlist will check for tag info thus update_music_tag_info is useless and was removed 4. add "add folder" feature to !file asked in #65, 5. fix bugs related to !file * truncate file list if too long * fixed several tiny bugs * fixed several tiny bugs continue * fixed several tiny bugs continue continue * fixed several tiny bugs continue**3 * fixed several tiny bugs continue**4 * added !filematch command to add files that match a regex pattern. * truncate long message * fix web interface delete file issue * refresh after delete file * add regex to listfile command * refactored command part, added partial match support for commands * organized * added random command * typo * typo * Fixed many bugs. * Added workaround for azlux/pymumble#44 to fix the memory leak. * changed logging style. * fixed bugs related to random and resume * fix now playing * fixed issue related to download * fixed issue related to download 2 * fixed thumbnail issue * fixed add url problem in web interface * REFACTORED, turned db.ini into sqlite3 database. * fixed remove song problem * fixed radio get title problem. auto download if tmp file is deleted * fixed current index not loaded from database * fixed: order of songs loaded from the database * fixed: some obscure bugs. beautified error of commands * added a workaround for TerryGeng/botamusique#1. * beautified * fixed: channel not loaded in the config * fixed: auto checked for updates * fixed: mysterious bug: sometimes "now playing" string cannot be properly displayed. The real reason is: do use <br />, do not use <br>. I tried hours to find out this. * chore: unified debug messages that refer to music items * feav: fetch ffmpeg stderr mentioned in #72, reformatted logs. * fix: async download not working * fix: async download not working, still * fix: async download not working, finished * feat: queue command: ▶current playing item◀ * feat: support more than one command prefix * chore: added some WARNINGs into default config file to avoid people to touch it. * refactor: packed all string contants into constants.py, just to avoid people messing it around. * refactor: required by azlux. Added a configuration.example.ini to keep people away from configuration.default.ini
This commit is contained in:
@ -37,10 +37,10 @@
|
||||
<input type="text" value="{{ subdirpath }}" name="directory" hidden>
|
||||
<button type="submit" class="btn btn-primary btn-sm btn-space"><i class="fa fa-download" aria-hidden="true"></i></button>
|
||||
</form>
|
||||
<form method="post">
|
||||
<input type="text" value="{{ subdirpath }}" name="delete_folder" hidden>
|
||||
<button type="submit" class="btn btn-danger btn-sm btn-space"><i class="fas fa-trash-alt"></i></button>
|
||||
</form>
|
||||
<button type="submit" class="btn btn-danger btn-sm btn-space"
|
||||
onclick="request('/post', {delete_folder : '{{ subdirpath }}'}, true)">
|
||||
<i class="fas fa-trash-alt"></i>
|
||||
</button>
|
||||
</div>
|
||||
</li>
|
||||
<div class="collapse multi-collapse" id="multiCollapse-{{ subdirid }}">
|
||||
@ -81,10 +81,10 @@
|
||||
<input type="text" value="{{ filepath }}" name="file" hidden>
|
||||
<button type="submit" class="btn btn-primary btn-sm btn-space"><i class="fa fa-download" aria-hidden="true"></i></button>
|
||||
</form>
|
||||
<form method="post">
|
||||
<input type="text" value="{{ filepath }}" name="delete_music_file" hidden>
|
||||
<button type="submit" class="btn btn-danger btn-sm btn-space"><i class="fas fa-trash-alt"></i></button>
|
||||
</form>
|
||||
<button type="submit" class="btn btn-danger btn-sm btn-space"
|
||||
onclick="request('/post', {delete_music_file : '{{ filepath }}'}, true)">
|
||||
<i class="fas fa-trash-alt"></i>
|
||||
</button>
|
||||
</div>
|
||||
</li>
|
||||
{% endfor %}
|
||||
@ -124,8 +124,19 @@
|
||||
onclick="request('/post', {action : 'randomize'})">
|
||||
<i class="fas fa-random" aria-hidden="true"></i>
|
||||
</button>
|
||||
<button type="button" class="btn btn-danger btn-space"
|
||||
onclick="request('/post', {action : 'stop'})">
|
||||
|
||||
<button type="button" id="play-btn" class="btn btn-info btn-space"
|
||||
onclick="request('/post', {action : 'resume'})" disabled>
|
||||
<i class="fas fa-play" aria-hidden="true"></i>
|
||||
</button>
|
||||
|
||||
<button type="button" id="pause-btn" class="btn btn-warning btn-space"
|
||||
onclick="request('/post', {action : 'pause'})" disabled>
|
||||
<i class="fas fa-pause" aria-hidden="true"></i>
|
||||
</button>
|
||||
|
||||
<button type="button" id="stop-btn" class="btn btn-danger btn-space"
|
||||
onclick="request('/post', {action : 'stop'})" disabled>
|
||||
<i class="fas fa-stop" aria-hidden="true"></i>
|
||||
</button>
|
||||
</div>
|
||||
@ -208,7 +219,7 @@
|
||||
<div class="card-body">
|
||||
<form action="./upload" method="post" enctype="multipart/form-data">
|
||||
<div class="row" style="margin-bottom: 5px;">
|
||||
<div id="uploadBox" class="col-lg-8 input-group">
|
||||
<div id="uploadBox" class="col-lg-7 input-group">
|
||||
<div id="uploadField" style="display: flex; width: 100%">
|
||||
<div class="custom-file btn-space">
|
||||
<input type="file" name="file[]" class="custom-file-input" id="uploadSelectFile"
|
||||
@ -227,10 +238,9 @@
|
||||
<option value="{{ dir }}">
|
||||
{% endfor %}
|
||||
</datalist>
|
||||
|
||||
<button class="btn btn-outline-secondary" type="submit"
|
||||
id="uploadSubmit">Upload</button>
|
||||
</div>
|
||||
<button class="btn btn-primary btn-space" type="submit"
|
||||
id="uploadSubmit" style="margin-left: -5px;">Upload!</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@ -239,7 +249,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bs-docs-section">
|
||||
<div class="bs-docs-section" style="margin-bottom: 150px;">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="card">
|
||||
@ -247,13 +257,12 @@
|
||||
<h5 class="card-title">Add URL</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form method="post">
|
||||
<label>Add Youtube/Soundcloud URL</label>
|
||||
<div class="input-group">
|
||||
<input class="form-control btn-space" type="text" name="add_url">
|
||||
<button type="submit" class="btn btn-primary">Add URL</button>
|
||||
</div>
|
||||
</form>
|
||||
<label>Add Youtube/Soundcloud URL</label>
|
||||
<div class="input-group">
|
||||
<input class="form-control btn-space" type="text" id="add_url_input" placeholder="URL...">
|
||||
<button type="submit" class="btn btn-primary"
|
||||
onclick="request('/post', {add_url : $('#add_url_input')[0].value })">Add URL</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -263,13 +272,12 @@
|
||||
<h5 class="card-title">Add Radio</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form method="post">
|
||||
<label>Add Radio URL</label>
|
||||
<div class="input-group">
|
||||
<input class="form-control btn-space" type="text" name="add_radio">
|
||||
<button type="submit" class="btn btn-primary">Add Radio</button>
|
||||
</div>
|
||||
</form>
|
||||
<label>Add Radio URL</label>
|
||||
<div class="input-group">
|
||||
<input class="form-control btn-space" type="text" id="add_radio_input" placeholder="Radio Address...">
|
||||
<button type="submit" class="btn btn-primary"
|
||||
onclick="request('/post', {add_radio : $('#add_radio_input')[0].value })">Add Radio</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -294,27 +302,35 @@
|
||||
|
||||
var playlist_ver = 0;
|
||||
|
||||
function request(url, _data){
|
||||
function request(url, _data, refresh=false){
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/post',
|
||||
data : _data,
|
||||
statusCode : {
|
||||
200 : function(data) {
|
||||
if (data.ver > playlist_ver) {
|
||||
if (data.ver !== playlist_ver) {
|
||||
updatePlaylist();
|
||||
playlist_ver = data.ver;
|
||||
}
|
||||
updateControls(data.empty, data.play);
|
||||
}
|
||||
}
|
||||
});
|
||||
if(refresh){
|
||||
location.reload()
|
||||
}
|
||||
}
|
||||
|
||||
function displayPlaylist(data){
|
||||
// console.info(data);
|
||||
$("#playlist-table tr").remove();
|
||||
$.each(data, function(index, item){
|
||||
|
||||
var items = data.items;
|
||||
$.each(items, function(index, item){
|
||||
$("#playlist-table").append(item);
|
||||
})
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function updatePlaylist(){
|
||||
@ -327,6 +343,23 @@
|
||||
});
|
||||
}
|
||||
|
||||
function updateControls(empty, play){
|
||||
if(empty){
|
||||
$("#play-btn").prop("disabled", true);
|
||||
$("#pause-btn").prop("disabled", true);
|
||||
$("#stop-btn").prop("disabled", true);
|
||||
}else{
|
||||
if(play){
|
||||
$("#play-btn").prop("disabled", true);
|
||||
$("#pause-btn").prop("disabled", false);
|
||||
$("#stop-btn").prop("disabled", false);
|
||||
}else{
|
||||
$("#play-btn").prop("disabled", false);
|
||||
$("#pause-btn").prop("disabled", true);
|
||||
$("#stop-btn").prop("disabled", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check the version of playlist to see if update is needed.
|
||||
setInterval(function(){
|
||||
@ -335,10 +368,11 @@
|
||||
url : '/post',
|
||||
statusCode : {
|
||||
200 : function(data){
|
||||
if(data.ver > playlist_ver){
|
||||
if(data.ver !== playlist_ver){
|
||||
updatePlaylist();
|
||||
playlist_ver = data.ver;
|
||||
}
|
||||
updateControls(data.empty, data.play);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user