diff --git a/media_server/services/browser_service.py b/media_server/services/browser_service.py index 2569194..bdf18fd 100644 --- a/media_server/services/browser_service.py +++ b/media_server/services/browser_service.py @@ -121,24 +121,28 @@ class BrowserService: return "other" @staticmethod - def get_duration(file_path: Path) -> Optional[float]: - """Get duration of a media file in seconds (header-only read). + def get_media_info(file_path: Path) -> dict: + """Get duration and bitrate of a media file (header-only read). Args: file_path: Path to the media file. Returns: - Duration in seconds, or None if unavailable. + Dict with 'duration' (float or None) and 'bitrate' (int or None). """ + result = {"duration": None, "bitrate": None} if not HAS_MUTAGEN: - return None + return result try: audio = MutagenFile(str(file_path)) - if audio is not None and hasattr(audio, "info") and hasattr(audio.info, "length"): - return round(audio.info.length, 2) + if audio is not None and hasattr(audio, "info"): + if hasattr(audio.info, "length"): + result["duration"] = round(audio.info.length, 2) + if hasattr(audio.info, "bitrate") and audio.info.bitrate: + result["bitrate"] = audio.info.bitrate except Exception: pass - return None + return result @staticmethod def browse_directory( @@ -255,9 +259,12 @@ class BrowserService: item["modified"] = None if item["is_media"]: - item["duration"] = BrowserService.get_duration(item_path) + info = BrowserService.get_media_info(item_path) + item["duration"] = info["duration"] + item["bitrate"] = info["bitrate"] else: item["duration"] = None + item["bitrate"] = None return { "folder_id": folder_id, diff --git a/media_server/static/css/styles.css b/media_server/static/css/styles.css index c9b6462..e0f99a5 100644 --- a/media_server/static/css/styles.css +++ b/media_server/static/css/styles.css @@ -1542,23 +1542,12 @@ min-width: 0; } -.browser-list-type { - font-size: 0.625rem; - text-transform: uppercase; - font-weight: 600; - color: var(--text-secondary); - padding: 0.15rem 0.5rem; - background: var(--bg-primary); - border-radius: 4px; +.browser-list-bitrate { + font-size: 0.75rem; + color: var(--text-muted); white-space: nowrap; -} - -.browser-list-type.audio { - color: var(--accent); -} - -.browser-list-type.video { - color: #3b82f6; + min-width: 55px; + text-align: right; } .browser-list-duration { diff --git a/media_server/static/index.html b/media_server/static/index.html index 2ba3afa..40e8094 100644 --- a/media_server/static/index.html +++ b/media_server/static/index.html @@ -193,7 +193,6 @@