mirror of
https://github.com/deunix-educ/mediadeck.git
synced 2026-11-25 04:39:42 +01:00
Add the Media tab: browse sound, image and video files and open them on the PC
Media tab (needs at least one folder, hidden otherwise): - Folders from [media] roots in config.toml, default = the user's Music, Videos and Pictures (XDG, never $HOME); [] disables the tab - Icons per type, subfolders, breadcrumb, back, refresh, All/Sounds/Images/ Videos filter; a tap opens the file on the PC (WebSocket system/open_media) - Three special launchers (audio, image, video), editable on /admin: system default (gio open), installed application (gio launch) or a raw command (allow_custom_command); the file path is appended as the last argument - The client never sends an absolute path: (root, relative path) is resolved server side; refuses "..", hidden entries, symlinks leaving the root, and anything but known media extensions (a script renamed .mp3 is refused) - GET /api/media (Bearer token), listing runs in a thread, 1000 entries max Interface cache: pages are revalidated (Cache-Control: no-cache) and static files are served under /static/<version>/ (immutable cache), so a tablet can no longer keep an old interface after an update. Reproduced and verified: opening the same link serves the cached page, one refresh fixes it for good. Refactors: restapi.py (shared REST helpers), AppPicker (shared by the launcher and opener forms on /admin). Tests: 159 (library escapes, openers, admin API, config, cache headers). Also checked end to end with a real server (fake gio recording its arguments) and headless Chromium. Not tried on the real tablet. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -84,6 +84,19 @@ class ParseConfigTest(unittest.TestCase):
|
||||
with self.subTest(server=server), self.assertRaises(ConfigError):
|
||||
parse_config({"server": {"token": TOKEN, **server}})
|
||||
|
||||
def test_media_roots(self) -> None:
|
||||
self.assertIsNone(parse_config({"server": {"token": TOKEN}}).media_roots) # défaut : dossiers de l'utilisateur
|
||||
self.assertEqual(parse_config({"server": {"token": TOKEN}, "media": {"roots": []}}).media_roots, ())
|
||||
config = parse_config({"server": {"token": TOKEN}, "media": {"roots": ["~/Musique", "/srv/films", "~/Musique"]}})
|
||||
self.assertEqual(config.media_roots, (Path.home() / "Musique", Path("/srv/films")))
|
||||
|
||||
def test_media_roots_are_validated(self) -> None:
|
||||
for roots in ("~/Musique", ["relatif/dossier"], [""], [3], ["~/a", None]):
|
||||
with self.subTest(roots=roots), self.assertRaises(ConfigError):
|
||||
parse_config({"server": {"token": TOKEN}, "media": {"roots": roots}})
|
||||
with self.assertRaises(ConfigError):
|
||||
parse_config({"server": {"token": TOKEN}, "media": []})
|
||||
|
||||
def test_max_volume_bounds(self) -> None:
|
||||
with self.assertRaises(ConfigError):
|
||||
parse_config({"server": {"token": TOKEN}, "audio": {"max_volume": 3}})
|
||||
|
||||
Reference in New Issue
Block a user