only audio for recent 10 minute log

This commit is contained in:
lelo 2025-12-25 20:59:59 +00:00
parent 5015075694
commit 311fd89a54
2 changed files with 26 additions and 12 deletions

View File

@ -249,9 +249,23 @@ def return_folder_yesterday():
def return_file_access():
"""Return recent file access logs from memory (the last 10 minutes)."""
"""Return recent audio file access logs from memory (the last 10 minutes)."""
global file_access_temp
if file_access_temp:
def is_audio(entry):
"""Check whether a log entry references an audio file."""
mime_val = (entry[3] or "").lower()
if mime_val.startswith("audio/"):
return True
path_val = (entry[1] or "").lower()
return path_val.endswith((
".mp3", ".wav", ".flac", ".m4a", ".aac",
".ogg", ".wma", ".aiff", ".alac", ".opus"
))
if not file_access_temp:
return []
# Create a timezone-aware cutoff time
cutoff_time = datetime.now(timezone.utc).astimezone() - timedelta(minutes=10)
# Only keep entries with timestamps greater than or equal to cutoff_time
@ -259,9 +273,8 @@ def return_file_access():
entry for entry in file_access_temp
if datetime.fromisoformat(entry[0]) >= cutoff_time
]
return file_access_temp
else:
return []
# Only expose audio file accesses to the UI
return [entry for entry in file_access_temp if is_audio(entry)]
def return_file_access_with_geo():

View File

@ -101,7 +101,8 @@
{% block content %}
<div class="page-content">
<div class="section-header">
<h2 style="margin: 0;">Verbindungen der letzten 10 Minuten</h2>
<h2 style="margin: 0;">Verbindungen der letzten 10 Minuten (nur Audio)</h2>
<p class="text-muted" style="margin: 4px 0 0 0;">Diese Ansicht listet ausschließlich Zugriffe auf Audio-Dateien.</p>
<div class="stats">
<div class="stat-item">
<div class="stat-label">Last Connection</div>