Show bitrate in browser, remove type labels and Play All text
- Extract bitrate alongside duration in browse_directory via get_media_info - Display bitrate in large card view metadata (duration · bitrate · size) - Replace Audio/Video type badge with bitrate column in list view - Remove Play All button text, keep icon only - Add formatBitrate helper function Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user