Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
524fc6ef54
|
|||
|
cdacbd9d8f
|
|||
|
c4d18aa680
|
|||
|
7da1443d09
|
|||
|
771f557bae
|
|||
|
4c87869392
|
|||
|
2e5d1ce78a
|
|||
|
005a70ca65
|
|||
|
aea43550c4
|
|||
|
d301da7f09
|
|||
|
d5c38e322c
|
|||
|
46ba681137
|
|||
|
a2d50eccb0
|
|||
|
090676d82e
|
|||
|
6d598bde26
|
|||
|
69c8540e83
|
|||
|
a295ca6861
|
|||
|
36c98ed2ef
|
@@ -0,0 +1,3 @@
|
||||
NAVIDROME_MUSIC_FOLDER="/opt/navidrome/music"
|
||||
BIND_ADDRESS="192.168.2.24"
|
||||
BIND_PORT="5001"
|
||||
+2
-1
@@ -1,4 +1,5 @@
|
||||
venv/
|
||||
setup.sh
|
||||
navidrome-upload.service
|
||||
.idea/
|
||||
.idea/
|
||||
.env
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
# Navidrome Upload Utility
|
||||
# Arian Nasr
|
||||
# March 6, 2026
|
||||
|
||||
import os
|
||||
from flask import Flask, request, render_template
|
||||
from werkzeug.utils import secure_filename
|
||||
|
||||
UPLOAD_FOLDER = '/opt/navidrome/music'
|
||||
UPLOAD_FOLDER = os.environ.get('NAVIDROME_MUSIC_FOLDER', '/opt/navidrome/music')
|
||||
BIND_ADDRESS = os.environ.get('BIND_ADDRESS', '0.0.0.0')
|
||||
BIND_PORT = int(os.environ.get('BIND_PORT', 5001))
|
||||
ALLOWED_EXTENSIONS = {'flac', 'mp3', 'wav'}
|
||||
|
||||
app = Flask(__name__)
|
||||
@@ -12,25 +18,24 @@ def allowed_file(filename):
|
||||
return '.' in filename and \
|
||||
filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
|
||||
|
||||
@app.route('/ping')
|
||||
def ping():
|
||||
return 'pong', 200
|
||||
|
||||
@app.route('/', methods=['GET', 'POST'])
|
||||
def upload_file():
|
||||
if request.method == 'POST':
|
||||
if 'file' not in request.files:
|
||||
return render_template('error.html', error_message='No file part in the request'), 400
|
||||
files = request.files.getlist('file')
|
||||
for file in files:
|
||||
if file.filename == '':
|
||||
return render_template('error.html', error_message='No selected file'), 400
|
||||
if file and allowed_file(file.filename):
|
||||
for key, file in request.files.items():
|
||||
if key.startswith('file') and file and allowed_file(file.filename) and file.filename != '':
|
||||
filename = secure_filename(file.filename)
|
||||
file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
|
||||
else:
|
||||
return render_template('error.html', error_message=f'File "{file.filename}" is not allowed. Allowed types: {", ".join(ALLOWED_EXTENSIONS)}'), 400
|
||||
return render_template('error.html', error_message=f'File is not allowed.'), 400
|
||||
|
||||
return render_template('success.html', success_message=f'{len(files)} file(s) uploaded successfully!')
|
||||
return render_template('success.html', success_message=f'{len(request.files)} file(s) uploaded successfully!'), 200
|
||||
|
||||
return render_template('index.html')
|
||||
return render_template('index.html'), 200
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(host='192.168.2.24', port=5001, debug=False)
|
||||
app.run(host=BIND_ADDRESS, port=BIND_PORT, debug=False)
|
||||
|
||||
+1
-1
@@ -4,4 +4,4 @@ Flask==3.1.3
|
||||
itsdangerous==2.2.0
|
||||
Jinja2==3.1.6
|
||||
MarkupSafe==3.0.3
|
||||
Werkzeug==3.1.6
|
||||
Werkzeug==3.1.7
|
||||
Vendored
+1
File diff suppressed because one or more lines are too long
@@ -0,0 +1,10 @@
|
||||
body {
|
||||
background-color: #252526;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
.dropzone {
|
||||
background: #3e3e42 !important;
|
||||
border-radius: 2rem !important;
|
||||
border-style: dashed !important;
|
||||
border-color: #FFFFFF !important;
|
||||
}
|
||||
Vendored
+1
File diff suppressed because one or more lines are too long
@@ -4,12 +4,7 @@
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Error - Upload Music</title>
|
||||
<style>
|
||||
body {
|
||||
background-color: #2B2726;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
</style>
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
<h1>Error</h1>
|
||||
|
||||
+14
-12
@@ -4,18 +4,20 @@
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Upload Music</title>
|
||||
<style>
|
||||
body {
|
||||
background-color: #2B2726;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
</style>
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}" type="text/css" />
|
||||
<script src="{{ url_for('static', filename='js/dropzone.min.js') }}"></script>
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/dropzone.min.css') }}" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
<h1>Upload new File</h1>
|
||||
<form method=post enctype=multipart/form-data>
|
||||
<input type=file name=file multiple>
|
||||
<input type=submit value=Upload>
|
||||
</form>
|
||||
<script>
|
||||
Dropzone.options.myDropzone = {
|
||||
parallelUploads: 4,
|
||||
uploadMultiple: true,
|
||||
acceptedFiles: 'audio/*'
|
||||
};
|
||||
</script>
|
||||
<form action="/"
|
||||
class="dropzone"
|
||||
id="my-dropzone"></form>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
||||
@@ -4,12 +4,7 @@
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Success - Upload Music</title>
|
||||
<style>
|
||||
body {
|
||||
background-color: #2B2726;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
</style>
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
<h1>Success</h1>
|
||||
|
||||
Reference in New Issue
Block a user