284 lines
14 KiB
HTML
284 lines
14 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">
|
|
<link rel="stylesheet" href="/static/css/custom.css">
|
|
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
|
|
<META HTTP-EQUIV="Expires" CONTENT="-1">
|
|
</head>
|
|
|
|
<body>
|
|
<div class="container">
|
|
<div class="bs-docs-section">
|
|
<div class="page-header" id="banner">
|
|
<h1>botamusique Web Interface</h1>
|
|
</div>
|
|
</div>
|
|
<div class="bs-docs-section">
|
|
<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>
|
|
<p> <b>Currently Playing: </b>
|
|
{% if playlist.length() > 0 %}
|
|
{% if 'url' in playlist.current_item() %}
|
|
<a href="{{ playlist.current_item()['url'] }}">{{ playlist.current_item()['url'] }}</a>
|
|
{% elif 'path' in playlist.current_item() %}
|
|
{{ playlist.current_item()['path'] }}
|
|
{% endif %}
|
|
{% else %}
|
|
No music
|
|
{% endif %}
|
|
</p>
|
|
</div>
|
|
<div class="line">
|
|
<form method="post">
|
|
<input type="text" value="randomize" name="action" hidden>
|
|
<button type="submit" class="btn btn-primary btn-space">Randomize playlist</button>
|
|
</form>
|
|
<form method="post">
|
|
<input type="text" value="stop" name="action" hidden>
|
|
<button type="submit" class="btn btn-danger btn-space">Stop</button>
|
|
</form>
|
|
</div>
|
|
|
|
<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.playlist %}
|
|
{% if loop.index0 == playlist.current_index %}
|
|
<tr class="table-active">
|
|
{% else %}
|
|
<tr>
|
|
{% endif %}
|
|
<th scope="row">{{ loop.index }}</th>
|
|
<td>{{ m['type'].capitalize() }}</td>
|
|
<td>
|
|
<div class="playlist-title"">
|
|
{% if 'thumbnail' in m %}
|
|
<img width="80" src="data:image/PNG;base64,{{ m['thumbnail'] }}"/>
|
|
{% else %}
|
|
<img width="80" src="/static/image/unknown-album.png"/>
|
|
{% endif %}
|
|
</div>
|
|
<div class="playlist-artwork">
|
|
{% if 'title' in m and m['title'].strip() %}
|
|
<b>{{ m['title'] }}</b>
|
|
{% else %}
|
|
<b>{{ m['url'] }}</b>
|
|
{% endif %}
|
|
<br>
|
|
{% if 'artist' in m %}
|
|
{{ m['artist'] }}
|
|
{% else %}
|
|
Unknown Artist
|
|
{% endif %}
|
|
</div>
|
|
</td>
|
|
<td>
|
|
{% if 'url' in m %}
|
|
<a href="{{ m['url'] }}">{{ m['url'] }}</a>
|
|
{% elif 'path' in m %}
|
|
{{ m['path'] }}
|
|
{% endif %}
|
|
</td>
|
|
<td>
|
|
<div class="line">
|
|
<form method="post">
|
|
<input type="text" value="{{ loop.index0 }}" name="play_music" hidden>
|
|
<button type="submit" class="btn btn-success btn-sm btn-space">Play</button>
|
|
</form>
|
|
<form method="post">
|
|
<input type="text" value="{{ loop.index0 }}" name="delete_music" hidden>
|
|
<button type="submit" class="btn btn-danger btn-sm btn-space">Remove</button>
|
|
</form>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="bs-docs-section">
|
|
<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>
|
|
|
|
<div id="upload" class="container">
|
|
<div class="bs-docs-section">
|
|
<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>
|
|
|
|
<div class="bs-docs-section">
|
|
<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>
|
|
</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> |