mirror of
https://github.com/deunix-educ/mediadeck.git
synced 2026-11-25 04:39:42 +01:00
Media tab: sort by name, date or size, and thumbnails for videos and sounds
The listing now returns the date (v) and size of every file, not just of images. A selector next to the type filters sorts files by name (natural order, default), date (newest first) or size (largest first), client side; folders stay first and the choice is remembered on the tablet. Video and sound tiles now request /thumb like images (the server already made them). The existing icon fallback covers a sound without a cover. Audio and video tiles with a thumbnail get a border in their type colour. Tests: listing date and size, a Chromium sort test with three files whose name, date and size orders all differ (kept after reload), and a thumbnail test with real ffmpeg. Both UI tests were checked to fail when the feature is reverted. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
+11
-3
@@ -20,6 +20,7 @@ from mediadeck import server as server_module
|
||||
from mediadeck.config import parse_config
|
||||
from mediadeck.launchers import LauncherStore
|
||||
from mediadeck.server import MediaDeckServer
|
||||
from mediadeck.thumbs import Thumbnailer
|
||||
|
||||
DBUS_DAEMON = shutil.which("dbus-daemon")
|
||||
TOKEN = "t" * 32
|
||||
@@ -70,9 +71,11 @@ DESKTOP_ENTRY = "[Desktop Entry]\nType=Application\nName=Fake application\nExec=
|
||||
class Stack:
|
||||
"""Serveur réel + bibliothèque de médias + faux programmes. ``await start()``, puis ``await close()``."""
|
||||
|
||||
def __init__(self, libraries: tuple[str, ...] = ("Musique",)) -> None:
|
||||
def __init__(self, libraries: tuple[str, ...] = ("Musique",), thumbnails: bool = False) -> None:
|
||||
# libraries : dossiers de médias à créer et à déclarer ; vide = onglet Médias désactivé
|
||||
# thumbnails : miniatures par le vrai ffmpeg (cache dans le dossier temporaire)
|
||||
self.libraries = libraries
|
||||
self.thumbnails = thumbnails
|
||||
self.address = ""
|
||||
|
||||
async def start(self) -> None:
|
||||
@@ -135,12 +138,17 @@ class Stack:
|
||||
{
|
||||
"server": {"token": TOKEN, "host": "127.0.0.1"},
|
||||
"features": {"input": False, "power": False},
|
||||
"media": {"roots": [str(tmp / name) for name in self.libraries], "thumbnails": False},
|
||||
"media": {"roots": [str(tmp / name) for name in self.libraries], "thumbnails": self.thumbnails},
|
||||
"launchers": [{"id": "rec", "label": "Recorder", "command": ["recorder", "--fs", "$(reboot)"]}],
|
||||
}
|
||||
)
|
||||
store = LauncherStore(tmp / "launchers.db")
|
||||
with mock.patch.object(server_module, "LauncherStore", lambda: store):
|
||||
# Le cache des miniatures est choisi à l'import du module : on l'impose pour ne pas écrire dans ~/.cache
|
||||
thumbnailer = lambda: Thumbnailer(cache_dir=tmp / "cache" / "thumbs") # noqa: E731
|
||||
with (
|
||||
mock.patch.object(server_module, "LauncherStore", lambda: store),
|
||||
mock.patch.object(server_module, "Thumbnailer", thumbnailer),
|
||||
):
|
||||
self.deck = MediaDeckServer(config)
|
||||
self.client = TestClient(TestServer(self.deck.build_app()))
|
||||
await self.client.start_server()
|
||||
|
||||
Reference in New Issue
Block a user