allow all file types

This commit is contained in:
lelo 2025-03-26 17:52:16 +00:00
parent b348b4444f
commit d2dedf51c7
3 changed files with 32 additions and 29 deletions

20
app.py
View File

@ -76,8 +76,8 @@ def list_directory_contents(directory, subpath):
transcription_exists = os.path.isdir(transcription_dir)
# Define allowed file extensions.
allowed_music_exts = ('.mp3',)
allowed_image_exts = ('.jpg', '.jpeg', '.png', '.gif', '.bmp')
music_exts = ('.mp3',)
image_exts = ('.jpg', '.jpeg', '.png', '.gif', '.bmp')
try:
with os.scandir(directory) as it:
@ -94,12 +94,16 @@ def list_directory_contents(directory, subpath):
directories.append({'name': entry.name, 'path': rel_path.replace(os.sep, '/')})
elif entry.is_file(follow_symlinks=False):
lower_name = entry.name.lower()
if lower_name.endswith(allowed_music_exts) or lower_name.endswith(allowed_image_exts):
# implement file type filtering here !!!
#if lower_name.endswith(music_exts) or lower_name.endswith(image_exts):
rel_path = os.path.join(subpath, entry.name) if subpath else entry.name
if lower_name.endswith(allowed_music_exts):
if lower_name.endswith(music_exts):
file_type = 'music'
else:
elif lower_name.endswith(image_exts):
file_type = 'image'
else:
file_type = 'other'
file_entry = {'name': entry.name, 'path': rel_path.replace(os.sep, '/'), 'file_type': file_type}
# Only check for transcription if it's a audio file.
if file_type == 'music' and transcription_exists:
@ -191,10 +195,8 @@ def serve_file(subpath):
mime, _ = mimetypes.guess_type(full_path)
mime = mime or 'application/octet-stream'
if mime and mime.startswith('image/'):
pass # do not log access to images
else:
# logging only for mp3
if mime and mime.startswith('audio/mpeg'):
# HEAD request are coming in to initiate server caching.
# only log initial hits and not the reload of further file parts
range_header = request.headers.get('Range')

View File

@ -16,15 +16,13 @@ SERVER1_MOUNT_POINTS=(
"/mnt/Gottesdienste Speyer"
"/mnt/Besondere Gottesdienste"
"/mnt/Liedersammlung"
"/mnt/Jungschar"
"/mnt/Jugend"
"/mnt/app_share"
)
SERVER1_NFS_SHARES=(
"/volume1/Aufnahme-stereo/010 Gottesdienste ARCHIV"
"/volume1/Aufnahme-stereo/013 Besondere Gottesdienste"
"/volume1/Aufnahme-stereo/014 Liedersammlung"
"/volume1/app.share/Jungschar"
"/volume1/app.share/Jugend"
"/volume1/app_share"
)
# Server 2 Configuration

View File

@ -300,6 +300,9 @@ document.querySelectorAll('.play-file').forEach(link => {
} else if (fileType === 'image') {
// Open the gallery modal for image files.
openGalleryModal(relUrl);
} else {
// serve like a download
window.location.href = `/media/${relUrl}`;
}
});
});