Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
1d582eec8f
|
@@ -1,3 +0,0 @@
|
|||||||
NAVIDROME_MUSIC_FOLDER="/opt/navidrome/music"
|
|
||||||
BIND_ADDRESS="192.168.2.24"
|
|
||||||
BIND_PORT="5001"
|
|
||||||
@@ -2,4 +2,3 @@ venv/
|
|||||||
setup.sh
|
setup.sh
|
||||||
navidrome-upload.service
|
navidrome-upload.service
|
||||||
.idea/
|
.idea/
|
||||||
.env
|
|
||||||
|
|||||||
@@ -1,47 +0,0 @@
|
|||||||
[Unit]
|
|
||||||
Description=Navidrome Music Uploader Service
|
|
||||||
After=network.target,navidrome.service
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Type=simple
|
|
||||||
User=navidrome-uploader
|
|
||||||
Group=navidrome-uploader
|
|
||||||
WorkingDirectory=/opt/navidrome-uploader
|
|
||||||
Environment="PATH=/opt/navidrome-uploader/venv/bin"
|
|
||||||
EnvironmentFile=/etc/default/navidrome-uploader/.env
|
|
||||||
ExecStart=/opt/navidrome-uploader/venv/bin/gunicorn -c gunicorn.conf.py main:app
|
|
||||||
Restart=on-failure
|
|
||||||
RestartSec=30
|
|
||||||
|
|
||||||
NoNewPrivileges=yes
|
|
||||||
CapabilityBoundingSet=
|
|
||||||
AmbientCapabilities=
|
|
||||||
|
|
||||||
ProtectSystem=strict
|
|
||||||
ProtectHome=yes
|
|
||||||
PrivateTmp=yes
|
|
||||||
ReadWritePaths=/opt/navidrome-uploader
|
|
||||||
InaccessiblePaths=/boot /mnt /media
|
|
||||||
|
|
||||||
PrivateDevices=yes
|
|
||||||
ProtectKernelTunables=yes
|
|
||||||
ProtectKernelModules=yes
|
|
||||||
ProtectKernelLogs=yes
|
|
||||||
ProtectControlGroups=yes
|
|
||||||
ProtectClock=yes
|
|
||||||
ProtectHostname=yes
|
|
||||||
RestrictNamespaces=yes
|
|
||||||
RestrictRealtime=yes
|
|
||||||
RestrictSUIDSGID=yes
|
|
||||||
LockPersonality=yes
|
|
||||||
|
|
||||||
SystemCallFilter=@system-service
|
|
||||||
SystemCallErrorNumber=EPERM
|
|
||||||
|
|
||||||
PrivateNetwork=no
|
|
||||||
RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX
|
|
||||||
UMask=0027
|
|
||||||
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
# gunicorn.conf.py
|
|
||||||
# Arian Nasr
|
|
||||||
# April 4, 2026
|
|
||||||
|
|
||||||
import os
|
|
||||||
|
|
||||||
|
|
||||||
BIND_ADDRESS = os.environ.get('BIND_ADDRESS', '0.0.0.0')
|
|
||||||
BIND_PORT = int(os.environ.get('BIND_PORT', 5001))
|
|
||||||
|
|
||||||
bind = f"{BIND_ADDRESS}:{BIND_PORT}"
|
|
||||||
workers = 2
|
|
||||||
accesslog = "-" # Log to stdout
|
|
||||||
errorlog = "-" # Log to stderr
|
|
||||||
|
|
||||||
# gunicorn -c gunicorn.conf.py main:app
|
|
||||||
@@ -1,12 +1,8 @@
|
|||||||
# Navidrome Upload Utility
|
|
||||||
# Arian Nasr
|
|
||||||
# March 6, 2026
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from flask import Flask, request, render_template
|
from flask import Flask, request, render_template
|
||||||
from werkzeug.utils import secure_filename
|
from werkzeug.utils import secure_filename
|
||||||
|
|
||||||
UPLOAD_FOLDER = os.environ.get('NAVIDROME_MUSIC_FOLDER', '/opt/navidrome/music')
|
UPLOAD_FOLDER = '/opt/navidrome/music'
|
||||||
ALLOWED_EXTENSIONS = {'flac', 'mp3', 'wav'}
|
ALLOWED_EXTENSIONS = {'flac', 'mp3', 'wav'}
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
@@ -16,20 +12,25 @@ def allowed_file(filename):
|
|||||||
return '.' in filename and \
|
return '.' in filename and \
|
||||||
filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
|
filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
|
||||||
|
|
||||||
@app.route('/ping')
|
|
||||||
def ping():
|
|
||||||
return 'pong', 200
|
|
||||||
|
|
||||||
@app.route('/', methods=['GET', 'POST'])
|
@app.route('/', methods=['GET', 'POST'])
|
||||||
def upload_file():
|
def upload_file():
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
for key, file in request.files.items():
|
if 'file' not in request.files:
|
||||||
if key.startswith('file') and file and allowed_file(file.filename) and file.filename != '':
|
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):
|
||||||
filename = secure_filename(file.filename)
|
filename = secure_filename(file.filename)
|
||||||
file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
|
file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
|
||||||
else:
|
else:
|
||||||
return render_template('error.html', error_message=f'File is not allowed.'), 400
|
return render_template('error.html', error_message=f'File "{file.filename}" is not allowed. Allowed types: {", ".join(ALLOWED_EXTENSIONS)}'), 400
|
||||||
|
|
||||||
return render_template('success.html', success_message=f'{len(request.files)} file(s) uploaded successfully!'), 200
|
return render_template('success.html', success_message=f'{len(files)} file(s) uploaded successfully!')
|
||||||
|
|
||||||
return render_template('index.html'), 200
|
return render_template('index.html')
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
app.run(host='192.168.2.24', port=5001, debug=False)
|
||||||
|
|||||||
+2
-3
@@ -1,8 +1,7 @@
|
|||||||
blinker==1.9.0
|
blinker==1.9.0
|
||||||
click==8.3.2
|
click==8.3.1
|
||||||
Flask==3.1.3
|
Flask==3.1.3
|
||||||
itsdangerous==2.2.0
|
itsdangerous==2.2.0
|
||||||
Jinja2==3.1.6
|
Jinja2==3.1.6
|
||||||
MarkupSafe==3.0.3
|
MarkupSafe==3.0.3
|
||||||
Werkzeug==3.1.8
|
Werkzeug==3.1.6
|
||||||
gunicorn==25.3.0
|
|
||||||
|
|||||||
Vendored
-1
File diff suppressed because one or more lines are too long
@@ -1,10 +0,0 @@
|
|||||||
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,9 +4,15 @@
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Error - Upload Music</title>
|
<title>Error - Upload Music</title>
|
||||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}" type="text/css" />
|
<style>
|
||||||
|
body {
|
||||||
|
background-color: #2B2726;
|
||||||
|
color: #FFFFFF;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<button onclick="window.location.href='/outpost.goauthentik.io/sign_out'">Logout</button>
|
||||||
<h1>Error</h1>
|
<h1>Error</h1>
|
||||||
<p>{{ error_message }}</p>
|
<p>{{ error_message }}</p>
|
||||||
<a href="/"><button>Upload another file</button></a>
|
<a href="/"><button>Upload another file</button></a>
|
||||||
|
|||||||
+14
-13
@@ -3,21 +3,22 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<script src="https://s3.2ari.ca/navidrome-upload/dropzone.min.js"></script>
|
||||||
|
<link rel="stylesheet" href="https://s3.2ari.ca/navidrome-upload/dropzone.min.css" type="text/css" />
|
||||||
<title>Upload Music</title>
|
<title>Upload Music</title>
|
||||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}" type="text/css" />
|
<style>
|
||||||
<script src="{{ url_for('static', filename='js/dropzone.min.js') }}"></script>
|
body {
|
||||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/dropzone.min.css') }}" type="text/css" />
|
background-color: #2B2726;
|
||||||
|
color: #FFFFFF;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<script>
|
<button onclick="window.location.href='/outpost.goauthentik.io/sign_out'">Logout</button>
|
||||||
Dropzone.options.myDropzone = {
|
<h1>Upload new File</h1>
|
||||||
parallelUploads: 4,
|
<form method=post enctype=multipart/form-data class="dropzone" id="upload-dropzone">
|
||||||
uploadMultiple: true,
|
<input type=file name=file multiple>
|
||||||
acceptedFiles: 'audio/*'
|
<input type=submit value=Upload>
|
||||||
};
|
</form>
|
||||||
</script>
|
|
||||||
<form action="/"
|
|
||||||
class="dropzone"
|
|
||||||
id="my-dropzone"></form>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -4,9 +4,15 @@
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Success - Upload Music</title>
|
<title>Success - Upload Music</title>
|
||||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}" type="text/css" />
|
<style>
|
||||||
|
body {
|
||||||
|
background-color: #2B2726;
|
||||||
|
color: #FFFFFF;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<button onclick="window.location.href='/outpost.goauthentik.io/sign_out'">Logout</button>
|
||||||
<h1>Success</h1>
|
<h1>Success</h1>
|
||||||
<p>{{ success_message }}</p>
|
<p>{{ success_message }}</p>
|
||||||
<a href="/"><button>Upload another file</button></a>
|
<a href="/"><button>Upload another file</button></a>
|
||||||
|
|||||||
Reference in New Issue
Block a user