237 lines
11 KiB
HTML
237 lines
11 KiB
HTML
{% macro dirlisting(dir, path='') -%}
|
|
<ul class="list-group">
|
|
{% for subdirname, subdirobj in dir.get_subdirs().items() %}
|
|
{%- set subdirpath = os.path.relpath(subdirobj.fullpath, music_library.fullpath) %}
|
|
{%- set subdirid = subdirpath.replace("/","-") %}
|
|
<li class="directory list-group-item list-group-item-primary">
|
|
<span>{{ subdirpath }}/ </span>
|
|
<div class="btn-group" role="group">
|
|
<form method="post" class="directory">
|
|
<input type="text" value="{{ subdirpath }}" name="add_folder" hidden>
|
|
<button type="submit" class="btn btn-secondary">Add all tracks from this folder</button>
|
|
</form>
|
|
<form method="post" class="directory">
|
|
<input type="text" value="{{ subdirpath }}" name="add_folder_recursively" hidden>
|
|
<button type="submit" class="btn btn-secondary">Add all tracks from this folder (recursively)</button>
|
|
</form>
|
|
<form action="./download" method="get" class="directory">
|
|
<input type="text" value="{{ subdirpath }}" name="directory" hidden>
|
|
<button type="submit" class="btn btn-secondary">Download entire directory</button>
|
|
</form>
|
|
<button class="btn btn-primary" type="button" data-toggle="collapse"
|
|
data-target="#multiCollapse-{{ subdirid }}" aria-expanded="true"
|
|
aria-controls="multiCollapse-{{ subdirid }}">Toggle Collapse</button>
|
|
</div>
|
|
</li>
|
|
<div class="collapse multi-collapse" id="multiCollapse-{{ subdirid }}">
|
|
{{- dirlisting(subdirobj, subdirpath) -}}
|
|
</div>
|
|
{% endfor %}
|
|
{%- set files = dir.get_files() %}
|
|
{%- if files %}
|
|
{% for file in files %}
|
|
{% set filepath = os.path.relpath(os.path.join(dir.fullpath, file), music_library.fullpath) %}
|
|
<li class="file list-group-item">
|
|
<div class="btn-group" role="group">
|
|
<form method="post" class="file file_add">
|
|
<input type="text" value="{{ filepath }}" name="add_file" hidden>
|
|
<button type="submit" class="btn btn-primary">Add</button>
|
|
</form>
|
|
<form action="./download" method="get" class="file file_download">
|
|
<input type="text" value="{{ filepath }}" name="file" hidden>
|
|
<button type="submit" class="btn btn-primary">Download</button>
|
|
</form>
|
|
</div> {{ filepath }}
|
|
</li>
|
|
{% endfor %}
|
|
{%- endif %}
|
|
</ul>
|
|
{%- endmacro %}
|
|
|
|
<!DOCTYPE html>
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>botamusique web interface</title>
|
|
<link rel="stylesheet" href="/static/css/bootstrap.min.css">
|
|
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
|
|
<META HTTP-EQUIV="Expires" CONTENT="-1">
|
|
</head>
|
|
|
|
<body>
|
|
<div class="container">
|
|
<div class="row">
|
|
<div class="col">
|
|
<div id="playlist" class="card">
|
|
<div class="card-header">
|
|
<h2 class="card-title">Play List</h2>
|
|
</div>
|
|
|
|
<div class="card-body">
|
|
<div>
|
|
Currently Playing :
|
|
{% if playlist|length > 0 %}
|
|
{% if 'url' in playlist[0] %}
|
|
<a href="{{ playlist[0]['url'] }}">{{ playlist[0]['url'] }}</a>
|
|
{% elif 'path' in playlist[0] %}
|
|
{{ playlist[0]['path'] }}
|
|
{% endif %}
|
|
{% else %}
|
|
No music
|
|
{% endif %}
|
|
</div>
|
|
<form method="post">
|
|
<input type="text" value="randomize" name="action" hidden>
|
|
<button type="submit" class="btn btn-primary">Randomize playlist</button>
|
|
</form>
|
|
|
|
<table class="table">
|
|
<thead>
|
|
<tr>
|
|
<th scope="col">#</th>
|
|
<th scope="col">Type</th>
|
|
<th scope="col">Title</th>
|
|
<th scope="col">Url/Path</th>
|
|
<th scope="col">Action</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for m in playlist[1:] %}
|
|
<tr>
|
|
<th scope="row">{{ loop.index }}</th>
|
|
<td>{{ m['type'] }}</td>
|
|
<td>
|
|
{% if 'title' in m %}
|
|
({{ m['title'] }})
|
|
{% else %}
|
|
No title
|
|
{% endif %}
|
|
</td>
|
|
<td>
|
|
{% if 'url' in m %}
|
|
<a href="{{ m['url'] }}">{{ m['url'] }}</a>
|
|
{% elif 'path' in m %}
|
|
{{ m['path'] }}
|
|
{% endif %}
|
|
</td>
|
|
<td>
|
|
<form method="post">
|
|
<input type="text" value="{{ loop.index }}" name="delete_music" hidden>
|
|
<button type="submit" class="btn btn-primary">Remove</button>
|
|
</form>
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col">
|
|
<div id="browser" class="card">
|
|
<div class="card-header">
|
|
<h2 class="card-title">Music library</h2>
|
|
</div>
|
|
|
|
<div class="card-body">
|
|
<div class="btn-group" role="group">
|
|
<form action="./download" method="get" class="directory form1">
|
|
<input type="text" value="./" name="directory" hidden>
|
|
<button type="submit" class="btn btn-primary">Download entire music library</button>
|
|
</form>
|
|
<form method="post" class="directory form3">
|
|
<input type="text" value="./" name="add_folder_recursively" hidden>
|
|
<button type="submit" class="btn btn-primary">Add all tracks from music library
|
|
(recursively)</button>
|
|
</form>
|
|
</div>
|
|
<br />
|
|
{{ dirlisting(music_library) }}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="upload" class="container">
|
|
<div class="row">
|
|
<div class="col">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h5 class="card-title">Upload File</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<form action="./upload" method="post" enctype="multipart/form-data">
|
|
<div class="input-group">
|
|
<div class="custom-file">
|
|
<input type="file" name="file" class="custom-file-input" id="uploadSelectFile"
|
|
aria-describedby="uploadSubmit" value="Browse Music file" />
|
|
<label class="custom-file-label" for="uploadSelectFile">Choose file</label>
|
|
</div>
|
|
<div class="input-group-append">
|
|
<span class="input-group-text">Upload To</span>
|
|
<input class="form-control" list="targetdirs" id="targetdir" name="targetdir"
|
|
placeholder="uploads" />
|
|
<datalist id="targetdirs">
|
|
<option value="uploads">
|
|
{% for dir in music_library.get_subdirs_recursively() %}
|
|
<option value="{{ dir }}">
|
|
{% endfor %}
|
|
</datalist>
|
|
<button class="btn btn-outline-secondary" type="submit"
|
|
id="uploadSubmit">Upload</button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h5 class="card-title">Add URL</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<form method="post">
|
|
<label>Add Youtube/Soundcloud URL :</label>
|
|
<input class="form-control" type="text" name="add_url">
|
|
<button type="submit" class="btn btn-primary">Add URL</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h5 class="card-title">Add Radio</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<form method="post">
|
|
<label>Add Radio URL :</label>
|
|
<input class="form-control" type="text" name="add_radio">
|
|
<button type="submit" class="btn btn-primary">Add Radio</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script src="/static/js/jquery-3.4.1.min.js" crossorigin="anonymous"></script>
|
|
<script src="/static/js/bootstrap.bundle.min.js" crossorigin="anonymous"></script>
|
|
<script>
|
|
$('#uploadSelectFile').on('change', function () {
|
|
//get the file name
|
|
var fileName = $(this).val().replace('C:\\fakepath\\', " ");
|
|
//replace the "Choose a file" label
|
|
$(this).next('.custom-file-label').html(fileName);
|
|
})
|
|
</script>
|
|
</body>
|
|
|
|
</html> |