diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 4a56a65..75318a6 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -1,5 +1,5 @@ # Vérifications à chaque push / pull request, et release Gitea avec le paquet FreeStore -# sur un tag « vX.Y.Z » (qui doit correspondre à « version » dans manifest.json). +# sur un tag « vX.Y.Z » (qui doit correspondre à « version » dans app/manifest.json). # Le téléversement sur la console FreeFactory reste manuel (pas d'API connue). name: CI @@ -61,7 +61,7 @@ jobs: env: TAG: ${{ gitea.ref_name }} run: | - VERSION=$(python3 -c "import json; print(json.load(open('manifest.json'))['version'])") + VERSION=$(python3 -c "import json; print(json.load(open('app/manifest.json'))['version'])") if [ "$TAG" != "v$VERSION" ]; then echo "Le tag $TAG ne correspond pas à la version du manifest (v$VERSION)." exit 1 diff --git a/CLAUDE.md b/CLAUDE.md index fe4b216..a6ff8ca 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -6,6 +6,11 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co A Jellyfin client for the Freebox Player (Revolution), written in pure QML (no C++). The app runs inside the Freebox's QML runtime via the `fbx.application` module, The UI follows the Jellyfin Android TV app's flow and conventions. UI text is in French. +## Layout + +- `app/` — the application itself, the only directory served to / packaged for the Player (`manifest.json`, `Jellyfin.qml`, `icon.png`, `Components/`, `Core/`, `Shared/`, `Views/`, plus the QtCreator project `Jellyfin.fbxproject`). Paths in the Architecture section are relative to `app/`. +- `src/freebox_jellyfin/` — Python dev tooling; `tools/preview.qml` — desktop preview wrapper; `dist/`, `deploy.log` — generated at the repo root. + ## Build / run There is no build system or test suite. @@ -13,24 +18,24 @@ There is no build system or test suite. **Local preview on the PC** (no Freebox needed): `fbx.application` from [libfbxqml](https://github.com/fbx/libfbxqml) is pure QML (a fullscreen `Window` scaled to a 720p virtual height), so the app runs with Qt 5's `qmlscene`. - Prerequisites: `sudo apt install qmlscene qml-module-qtmultimedia qtdeclarative5-dev-tools`, and libfbxqml cloned next to the repo (`../libfbxqml`, override with `LIBFBXQML=`). -- Dev tooling is the Python package `freebox_jellyfin` (`src/freebox_jellyfin/`, uv project, Python 3.14, stdlib only): `uv sync`, then `uv run freebox-jellyfin ` (also `python -m freebox_jellyfin`). `project.py` locates the repo root (dir with `manifest.json` + `Jellyfin.qml`, from cwd then from the module), libfbxqml and qmlscene. `tools/` now only holds `preview.qml`. -- `uv run freebox-jellyfin preview` — 1280×720 window via `tools/preview.qml`; `--fullscreen` runs `Jellyfin.qml` as the box would. +- Dev tooling is the Python package `freebox_jellyfin` (`src/freebox_jellyfin/`, uv project, Python 3.14, stdlib only): `uv sync`, then `uv run freebox-jellyfin ` (also `python -m freebox_jellyfin`). `project.py` locates `REPO_DIR` (dir with `pyproject.toml` + `app/manifest.json`, from cwd then from the module) and `APP_DIR` (`app/`), libfbxqml and qmlscene. `tools/` now only holds `preview.qml`. +- `uv run freebox-jellyfin preview` — 1280×720 window via `tools/preview.qml`; `--fullscreen` runs `app/Jellyfin.qml` as the box would. - `QT_QPA_PLATFORM=offscreen uv run freebox-jellyfin preview` — headless run, useful to catch QML warnings. - HTTPS on the PC works with the system `qmlscene` (Qt 5.15 + OpenSSL 3). PyQt5 wheels from pip bundle a Qt built for OpenSSL 1.x and cannot do TLS here. -- Lint: `qmllint Jellyfin.qml Components/*.qml Core/*.qml Shared/*.qml Views/*.qml` -- `uv run freebox-jellyfin check` — serves the repo over HTTP and loads it with `qmlscene` (offscreen, software renderer) like the box does; fails on any Qt warning not coming from libfbxqml. Run it after touching imports, `qmldir` files or singletons. -- **Reproduce the box's loading mode**: the Player loads the app over HTTP, which behaves differently from local files (see constraints below). Check with `python3 -m http.server 8765 --directory .` then `QT_QPA_PLATFORM=offscreen qmlscene -I ../libfbxqml http://127.0.0.1:8765/Jellyfin.qml` — it must print no warnings. +- Lint: `cd app && qmllint Jellyfin.qml Components/*.qml Core/*.qml Shared/*.qml Views/*.qml` +- `uv run freebox-jellyfin check` — serves `app/` over HTTP and loads it with `qmlscene` (offscreen, software renderer) like the box does; fails on any Qt warning not coming from libfbxqml. Run it after touching imports, `qmldir` files or singletons. +- **Reproduce the box's loading mode**: the Player loads the app over HTTP, which behaves differently from local files (see constraints below). Check with `python3 -m http.server 8765 --directory app` then `QT_QPA_PLATFORM=offscreen qmlscene -I ../libfbxqml http://127.0.0.1:8765/Jellyfin.qml` — it must print no warnings. - The desktop has Qt 5.15 while the box targets QtQuick 2.5: code that runs locally can still use APIs too new for the box. **CI** (`.gitea/workflows/ci.yml`, Gitea Actions on the `ubuntu-latest` runner image): installs uv (pinned 0.12.9, which fetches Python 3.14) and on every push/PR runs `uv run --locked freebox-jellyfin package` (manifest + qmllint + archive) and `… check`; package uploaded as artifact (`upload-artifact@v3`/`download-artifact@v3`: v4 only works on recent Gitea versions). On tag `vX.Y.Z` matching `manifest.json` `version`, creates a Gitea release with the package attached (API calls with the job's `GITHUB_TOKEN`). Verified locally by replaying the `check` job's steps in a clean `ubuntu:24.04` container; the release job has not run yet. -**FreeStore package**: `freebox-jellyfin package` → `dist/-.tar.gz` (gitignored). Replicates the QtCreator plugin's "Make FreeStore Package": same file selection as `Jellyfin.fbxproject` (QML/JS/images/fonts/`qmldir`/`manifest.json`, excluding `tools/`, `src/`, `dist/` and hidden dirs), manifest checks (identifier `\w+(\.\w+)+`, `version` x.y.z equal to `Session.clientVersion`, entry-point files present), `qmllint` on all sources, ustar tar with directory entries, gzipped. Upload is manual on the FreeFactory console (http://factory.free.fr), followed by Free's review. +**FreeStore package**: `freebox-jellyfin package` → `dist/-.tar.gz` (gitignored). Replicates the QtCreator plugin's "Make FreeStore Package": same file selection as `Jellyfin.fbxproject` (QML/JS/images/fonts/`qmldir`/`manifest.json` under `app/`, hidden dirs excluded; archive paths relative to `app/`), manifest checks (identifier `\w+(\.\w+)+`, `version` x.y.z equal to `Session.clientVersion`, entry-point files present), `qmllint` on all sources, ustar tar with directory entries, gzipped. Upload is manual on the FreeFactory console (http://factory.free.fr), followed by Free's review. -**Deploying a test build to the Freebox**: `freebox-jellyfin deploy` (`src/freebox_jellyfin/deploy.py`; Player must be in developer mode). It discovers the Player via SSDP (`fbx:devel`) or takes `--box `, serves the repo over HTTP, calls JSON-RPC `debug_qml_app` on `http:///pub/devel`, and streams the app's stdout/stderr until it exits. `--server ` and `--user name[:password]` (both repeatable) serve a virtual `dev-config.json` next to the app; at startup `Session.loadDevConfig()` adds each listed server and stores users in `Session.devUsers`, which `UserSelectView` merges with public users (one-click sign-in when a password is given; never log passwords) (only when the app is loaded over HTTP; 404 otherwise, ignored) — the workaround for the lack of persistence in dev mode. Output is also written to `deploy.log` (repo root, gitignored, overwritten each run) — read it to diagnose on-box failures. The Player fetches files lazily from that HTTP server, so the script must keep running while the app is in use. This replicates the "Run" of the official QtCreator plugin, whose own setup is: +**Deploying a test build to the Freebox**: `freebox-jellyfin deploy` (`src/freebox_jellyfin/deploy.py`; Player must be in developer mode). It discovers the Player via SSDP (`fbx:devel`) or takes `--box `, serves `app/` over HTTP, calls JSON-RPC `debug_qml_app` on `http:///pub/devel`, and streams the app's stdout/stderr until it exits. `--server ` and `--user name[:password]` (both repeatable) serve a virtual `dev-config.json` next to the app; at startup `Session.loadDevConfig()` adds each listed server and stores users in `Session.devUsers`, which `UserSelectView` merges with public users (one-click sign-in when a password is given; never log passwords) (only when the app is loaded over HTTP; 404 otherwise, ignored) — the workaround for the lack of persistence in dev mode. Output is also written to `deploy.log` (repo root, gitignored, overwritten each run) — read it to diagnose on-box failures. The Player fetches files lazily from that HTTP server, so the script must keep running while the app is in use. This replicates the "Run" of the official QtCreator plugin, whose own setup is: - SDK setup: https://dev.freebox.fr/sdk/player.html (Windows: https://github.com/fbx/freebox-qtcreator-plugin/issues/8) -- Open `Jellyfin.fbxproject` in QtCreator with the Freebox plugin; the run target deploys to a Freebox Player on the LAN (configured in `Jellyfin.fbxproject.user`, which is machine-specific). -- `Jellyfin.fbxproject` packages every QML/JS/image/font/`qmldir` file under the repo root plus `manifest.json` — new files are picked up automatically. +- Open `app/Jellyfin.fbxproject` in QtCreator with the Freebox plugin; the run target deploys to a Freebox Player on the LAN (configured in `Jellyfin.fbxproject.user`, which is machine-specific). +- `Jellyfin.fbxproject` packages every QML/JS/image/font/`qmldir` file under `app/` plus `manifest.json` — new files are picked up automatically. ## Architecture diff --git a/Components/FocusButton.qml b/app/Components/FocusButton.qml similarity index 100% rename from Components/FocusButton.qml rename to app/Components/FocusButton.qml diff --git a/Components/Logo.qml b/app/Components/Logo.qml similarity index 100% rename from Components/Logo.qml rename to app/Components/Logo.qml diff --git a/Components/MediaCard.qml b/app/Components/MediaCard.qml similarity index 100% rename from Components/MediaCard.qml rename to app/Components/MediaCard.qml diff --git a/Components/MediaRow.qml b/app/Components/MediaRow.qml similarity index 100% rename from Components/MediaRow.qml rename to app/Components/MediaRow.qml diff --git a/Components/Page.qml b/app/Components/Page.qml similarity index 100% rename from Components/Page.qml rename to app/Components/Page.qml diff --git a/Components/ServerItem.qml b/app/Components/ServerItem.qml similarity index 100% rename from Components/ServerItem.qml rename to app/Components/ServerItem.qml diff --git a/Components/TextField.qml b/app/Components/TextField.qml similarity index 100% rename from Components/TextField.qml rename to app/Components/TextField.qml diff --git a/Components/UserCard.qml b/app/Components/UserCard.qml similarity index 100% rename from Components/UserCard.qml rename to app/Components/UserCard.qml diff --git a/Components/VideoSurface.qml b/app/Components/VideoSurface.qml similarity index 100% rename from Components/VideoSurface.qml rename to app/Components/VideoSurface.qml diff --git a/Components/qmldir b/app/Components/qmldir similarity index 100% rename from Components/qmldir rename to app/Components/qmldir diff --git a/Core/DeviceProfile.js b/app/Core/DeviceProfile.js similarity index 100% rename from Core/DeviceProfile.js rename to app/Core/DeviceProfile.js diff --git a/Core/Navigator.qml b/app/Core/Navigator.qml similarity index 100% rename from Core/Navigator.qml rename to app/Core/Navigator.qml diff --git a/Core/Session.qml b/app/Core/Session.qml similarity index 100% rename from Core/Session.qml rename to app/Core/Session.qml diff --git a/Core/qmldir b/app/Core/qmldir similarity index 100% rename from Core/qmldir rename to app/Core/qmldir diff --git a/Jellyfin.fbxproject b/app/Jellyfin.fbxproject similarity index 100% rename from Jellyfin.fbxproject rename to app/Jellyfin.fbxproject diff --git a/Jellyfin.fbxproject.user b/app/Jellyfin.fbxproject.user similarity index 100% rename from Jellyfin.fbxproject.user rename to app/Jellyfin.fbxproject.user diff --git a/Jellyfin.qml b/app/Jellyfin.qml similarity index 100% rename from Jellyfin.qml rename to app/Jellyfin.qml diff --git a/Shared/Format.js b/app/Shared/Format.js similarity index 100% rename from Shared/Format.js rename to app/Shared/Format.js diff --git a/Shared/Remote.js b/app/Shared/Remote.js similarity index 100% rename from Shared/Remote.js rename to app/Shared/Remote.js diff --git a/Shared/Theme.qml b/app/Shared/Theme.qml similarity index 100% rename from Shared/Theme.qml rename to app/Shared/Theme.qml diff --git a/Shared/qmldir b/app/Shared/qmldir similarity index 100% rename from Shared/qmldir rename to app/Shared/qmldir diff --git a/Views/DetailsView.qml b/app/Views/DetailsView.qml similarity index 100% rename from Views/DetailsView.qml rename to app/Views/DetailsView.qml diff --git a/Views/HomeView.qml b/app/Views/HomeView.qml similarity index 100% rename from Views/HomeView.qml rename to app/Views/HomeView.qml diff --git a/Views/LibraryView.qml b/app/Views/LibraryView.qml similarity index 100% rename from Views/LibraryView.qml rename to app/Views/LibraryView.qml diff --git a/Views/LoginView.qml b/app/Views/LoginView.qml similarity index 100% rename from Views/LoginView.qml rename to app/Views/LoginView.qml diff --git a/Views/PlayerView.qml b/app/Views/PlayerView.qml similarity index 100% rename from Views/PlayerView.qml rename to app/Views/PlayerView.qml diff --git a/Views/SeasonView.qml b/app/Views/SeasonView.qml similarity index 100% rename from Views/SeasonView.qml rename to app/Views/SeasonView.qml diff --git a/Views/ServerAddView.qml b/app/Views/ServerAddView.qml similarity index 100% rename from Views/ServerAddView.qml rename to app/Views/ServerAddView.qml diff --git a/Views/ServerSelectView.qml b/app/Views/ServerSelectView.qml similarity index 100% rename from Views/ServerSelectView.qml rename to app/Views/ServerSelectView.qml diff --git a/Views/UserSelectView.qml b/app/Views/UserSelectView.qml similarity index 100% rename from Views/UserSelectView.qml rename to app/Views/UserSelectView.qml diff --git a/icon.png b/app/icon.png similarity index 100% rename from icon.png rename to app/icon.png diff --git a/manifest.json b/app/manifest.json similarity index 100% rename from manifest.json rename to app/manifest.json diff --git a/readme.md b/readme.md index 0ce0aae..697e967 100644 --- a/readme.md +++ b/readme.md @@ -7,6 +7,8 @@ Cette application permet d'utiliser jellyfin sur la freebox. +L'application (QML envoyé au Player) est dans `app/` ; le reste du dépôt est l'outillage de développement. + # Configurer un environment de travail [Documentation pour le SDK de la freebox](https://dev.freebox.fr/sdk/player.html). Pour Windows, [voir ce billet sur Github](https://github.com/fbx/freebox-qtcreator-plugin/issues/8). @@ -51,9 +53,9 @@ La commande sert les fichiers du projet au Player et affiche les logs de l'appli uv run freebox-jellyfin package # crée dist/com.stilobique.jellyfin-.tar.gz ``` -Pour une nouvelle version, modifier `version` dans `manifest.json` **et** `clientVersion` dans `Core/Session.qml` (la commande refuse de créer le paquet si elles diffèrent). +Pour une nouvelle version, modifier `version` dans `app/manifest.json` **et** `clientVersion` dans `app/Core/Session.qml` (la commande refuse de créer le paquet si elles diffèrent). -La commande reproduit « Make FreeStore Package » du plugin QtCreator : il vérifie `manifest.json` et la syntaxe QML/JS (`qmllint`), puis crée l'archive à téléverser sur la console [FreeFactory](http://factory.free.fr) (compte développeur requis, validation par Free avant publication). +La commande reproduit « Make FreeStore Package » du plugin QtCreator : elle vérifie `app/manifest.json` et la syntaxe QML/JS (`qmllint`), puis crée l'archive à téléverser sur la console [FreeFactory](http://factory.free.fr) (compte développeur requis, validation par Free avant publication). ## Intégration continue Le workflow Gitea Actions `.gitea/workflows/ci.yml` : diff --git a/src/freebox_jellyfin/check_load.py b/src/freebox_jellyfin/check_load.py index 6ed3967..3a9bd20 100644 --- a/src/freebox_jellyfin/check_load.py +++ b/src/freebox_jellyfin/check_load.py @@ -13,7 +13,7 @@ import sys import tempfile import threading -from .project import PROJECT_DIR, libfbxqml, qmlscene +from .project import APP_DIR, libfbxqml, qmlscene # Messages attendus hors de la box : Settings de libfbxqml (pas d'objet App sur PC). EXPECTED = ("/libfbxqml/", "qml: Setting", "qml: Getting settings failed") @@ -38,7 +38,7 @@ def problems(output): def run(duration): lib, scene = libfbxqml(), qmlscene() server = _Server( - ("127.0.0.1", 0), functools.partial(_Quiet, directory=str(PROJECT_DIR))) + ("127.0.0.1", 0), functools.partial(_Quiet, directory=str(APP_DIR))) threading.Thread(target=server.serve_forever, daemon=True).start() url = "http://127.0.0.1:%d/Jellyfin.qml" % server.server_address[1] print("Chargement de %s pendant %g s…" % (url, duration), flush=True) diff --git a/src/freebox_jellyfin/deploy.py b/src/freebox_jellyfin/deploy.py index bf738cf..25edded 100755 --- a/src/freebox_jellyfin/deploy.py +++ b/src/freebox_jellyfin/deploy.py @@ -2,7 +2,7 @@ Reproduit le « Run » du plugin QtCreator Freebox (github.com/fbx/freebox-qtcreator-plugin) : 1. trouve le Player sur le réseau local (SSDP, type « fbx:devel ») ou utilise --box ; - 2. sert le dossier du projet en HTTP (le Player y télécharge manifest.json et les QML) ; + 2. sert le dossier app/ en HTTP (le Player y télécharge manifest.json et les QML) ; 3. appelle la méthode JSON-RPC « debug_qml_app » sur http:///pub/devel ; 4. affiche stdout/stderr de l'application jusqu'à sa fermeture (ou Ctrl+C). @@ -23,9 +23,9 @@ import threading import time import urllib.request -from .project import PROJECT_DIR +from .project import APP_DIR, REPO_DIR -PROJECT_DIR = str(PROJECT_DIR) +APP_DIR, REPO_DIR = str(APP_DIR), str(REPO_DIR) SSDP_ADDR = ("239.255.255.250", 1900) SSDP_TYPE = "fbx:devel" @@ -87,7 +87,7 @@ class QuietHandler(http.server.SimpleHTTPRequestHandler): def serve_project(bind_ip, verbose, dev_config=None): QuietHandler.verbose = verbose QuietHandler.dev_config = dev_config - handler = functools.partial(QuietHandler, directory=PROJECT_DIR) + handler = functools.partial(QuietHandler, directory=APP_DIR) server = http.server.ThreadingHTTPServer((bind_ip, 0), handler) threading.Thread(target=server.serve_forever, daemon=True).start() return server @@ -158,7 +158,7 @@ def main(argv=None): parser.add_argument("--user", action="extend", nargs="+", default=[], metavar="NOM[:MOT_DE_PASSE]", help="compte(s) affiché(s) sur l'écran « Qui regarde ? » ; avec mot de passe, " "connexion en un clic (ex. --user alice:mdp bob, ou --user répété)") - parser.add_argument("--log", default=os.path.join(PROJECT_DIR, "deploy.log"), + parser.add_argument("--log", default=os.path.join(REPO_DIR, "deploy.log"), help="fichier de log, écrasé à chaque lancement (défaut : deploy.log ; vide pour désactiver)") args = parser.parse_args(argv) @@ -189,7 +189,7 @@ def main(argv=None): server = serve_project(me, args.verbose, dev_config) port = server.server_address[1] manifest_url = "http://%s:%d/manifest.json" % (me, port) - print("Projet servi sur %s" % manifest_url) + print("Application servie sur %s" % manifest_url) if args.server: print("Serveurs de test proposés à l'app : %s" % ", ".join(args.server)) if users: # les mots de passe ne sont jamais affichés diff --git a/src/freebox_jellyfin/package.py b/src/freebox_jellyfin/package.py index 0089ec1..bd0b147 100755 --- a/src/freebox_jellyfin/package.py +++ b/src/freebox_jellyfin/package.py @@ -3,7 +3,7 @@ Reproduit « Outils > Freebox SDK > Make FreeStore Package » du plugin QtCreator Freebox (github.com/fbx/freebox-qtcreator-plugin, src/freestorepackager.cc) : - fichiers inclus comme dans Jellyfin.fbxproject : QML, JS, images, polices, qmldir et - manifest.json (tools/ et src/ sont exclus : l'outillage PC n'a rien à faire sur la box) ; + manifest.json, pris dans app/ uniquement (l'outillage PC n'a rien à faire sur la box) ; - vérifications : manifest.json (identifiant, version identique à Session.clientVersion, points d'entrée existants), JSON valides, syntaxe QML/JS (qmllint, s'il est installé) ; @@ -22,24 +22,21 @@ import sys import tarfile import time -from .project import PROJECT_DIR +from .project import APP_DIR, REPO_DIR -PROJECT_DIR = str(PROJECT_DIR) +APP_DIR, REPO_DIR = str(APP_DIR), str(REPO_DIR) # Types de fichiers repris de Jellyfin.fbxproject (QmlFiles, JavaScriptFiles, ImageFiles, Files). EXTENSIONS = {".qml", ".js", ".png", ".jpg", ".jpeg", ".gif", ".svg", ".bmp", ".webp", ".ttf", ".otf", ".woff"} NAMES = {"qmldir", "manifest.json"} -EXCLUDED_DIRS = {"tools", "dist", "src"} def collect_files(): files = [] - for root, dirs, names in os.walk(PROJECT_DIR): - rel_root = os.path.relpath(root, PROJECT_DIR) - # Dossiers cachés (.git, .idea…) et dossiers d'outillage exclus. - dirs[:] = sorted(d for d in dirs if not d.startswith(".") - and not (rel_root == "." and d in EXCLUDED_DIRS)) + for root, dirs, names in os.walk(APP_DIR): + rel_root = os.path.relpath(root, APP_DIR) + dirs[:] = sorted(d for d in dirs if not d.startswith(".")) # dossiers cachés exclus for name in sorted(names): if name in NAMES or os.path.splitext(name)[1].lower() in EXTENSIONS: files.append(os.path.normpath(os.path.join(rel_root, name))) @@ -48,7 +45,7 @@ def collect_files(): def check_manifest(files): """Mêmes règles que fileformat/manifest.cc du plugin. Renvoie le manifest.""" - path = os.path.join(PROJECT_DIR, "manifest.json") + path = os.path.join(APP_DIR, "manifest.json") if not os.path.exists(path): raise ValueError("manifest.json manquant") manifest = json.load(open(path, encoding="utf-8")) @@ -76,7 +73,7 @@ def check_manifest(files): if not isinstance(version, str) or not re.fullmatch(r"\d+\.\d+\.\d+", version): raise ValueError("manifest.json : « version » absente ou invalide (forme attendue : 1.2.3)") # La version envoyée à Jellyfin (Session.clientVersion) doit rester la même. - session = open(os.path.join(PROJECT_DIR, "Core", "Session.qml"), encoding="utf-8").read() + session = open(os.path.join(APP_DIR, "Core", "Session.qml"), encoding="utf-8").read() client = re.search(r'clientVersion:\s*"([^"]*)"', session) if not client or client.group(1) != version: raise ValueError("version du manifest (%s) différente de Session.clientVersion (%s)" @@ -90,12 +87,12 @@ def check_manifest(files): def check_sources(files): for name in files: if name.endswith(".json"): - json.load(open(os.path.join(PROJECT_DIR, name), encoding="utf-8")) + json.load(open(os.path.join(APP_DIR, name), encoding="utf-8")) qmllint = shutil.which("qmllint") if not qmllint: print("Attention : qmllint introuvable, syntaxe QML/JS non vérifiée.") return - sources = [os.path.join(PROJECT_DIR, f) for f in files if f.endswith((".qml", ".js"))] + sources = [os.path.join(APP_DIR, f) for f in files if f.endswith((".qml", ".js"))] result = subprocess.run([qmllint] + sources, capture_output=True, text=True) if result.returncode != 0: raise ValueError("erreurs de syntaxe QML/JS :\n" + (result.stdout + result.stderr).strip()) @@ -123,7 +120,7 @@ def build_archive(files, output): if directory not in seen_dirs: seen_dirs.add(directory) archive.addfile(info(directory, True)) - data = open(os.path.join(PROJECT_DIR, name), "rb").read() + data = open(os.path.join(APP_DIR, name), "rb").read() archive.addfile(info(name.replace(os.sep, "/"), False, len(data)), io.BytesIO(data)) @@ -140,7 +137,7 @@ def main(argv=None): sys.exit("Paquet non créé : %s" % error) output = args.output or os.path.join( - PROJECT_DIR, "dist", "%s-%s.tar.gz" % (manifest["identifier"], manifest["version"])) + REPO_DIR, "dist", "%s-%s.tar.gz" % (manifest["identifier"], manifest["version"])) build_archive(files, output) print("Paquet créé : %s — version %s (%d fichiers, %.1f Ko)" % ( os.path.relpath(output, os.getcwd()), manifest["version"], len(files), os.path.getsize(output) / 1024)) diff --git a/src/freebox_jellyfin/preview.py b/src/freebox_jellyfin/preview.py index 017189c..1b95d3e 100644 --- a/src/freebox_jellyfin/preview.py +++ b/src/freebox_jellyfin/preview.py @@ -2,7 +2,7 @@ import argparse import os -from .project import PROJECT_DIR, libfbxqml, qmlscene +from .project import APP_DIR, REPO_DIR, libfbxqml, qmlscene def main(argv=None): @@ -11,5 +11,5 @@ def main(argv=None): help="lance Jellyfin.qml en plein écran, comme sur la box (sinon fenêtre 1280x720)") args = parser.parse_args(argv) lib, scene = libfbxqml(), qmlscene() - qml = PROJECT_DIR / ("Jellyfin.qml" if args.fullscreen else "tools/preview.qml") + qml = APP_DIR / "Jellyfin.qml" if args.fullscreen else REPO_DIR / "tools" / "preview.qml" os.execv(scene, [scene, "-I", str(lib), str(qml)]) diff --git a/src/freebox_jellyfin/project.py b/src/freebox_jellyfin/project.py index e93e826..439e943 100644 --- a/src/freebox_jellyfin/project.py +++ b/src/freebox_jellyfin/project.py @@ -1,4 +1,8 @@ -"""Emplacements partagés par les commandes : racine du projet QML, libfbxqml et qmlscene.""" +"""Emplacements partagés par les commandes : dépôt, application QML, libfbxqml et qmlscene. + +REPO_DIR : racine du dépôt (outils, dist/, deploy.log) ; +APP_DIR : REPO_DIR/app, seul dossier envoyé au Freebox Player (manifest.json, QML, images). +""" import os import shutil import sys @@ -6,20 +10,21 @@ from pathlib import Path def _find_root() -> Path: - """Dossier contenant manifest.json : depuis le dossier courant, sinon depuis ce module.""" + """Dossier contenant app/manifest.json : depuis le dossier courant, sinon depuis ce module.""" for start in (Path.cwd(), Path(__file__).resolve().parent): for folder in (start, *start.parents): - if (folder / "manifest.json").is_file() and (folder / "Jellyfin.qml").is_file(): + if (folder / "app" / "manifest.json").is_file() and (folder / "pyproject.toml").is_file(): return folder sys.exit("Projet introuvable : lancez la commande depuis le dépôt Jellyfin-Freebox.") -PROJECT_DIR = _find_root() +REPO_DIR = _find_root() +APP_DIR = REPO_DIR / "app" def libfbxqml() -> Path: """libfbxqml (module fbx.application en QML pur) : ../libfbxqml, ou $LIBFBXQML.""" - path = Path(os.environ.get("LIBFBXQML", PROJECT_DIR.parent / "libfbxqml")) + path = Path(os.environ.get("LIBFBXQML", REPO_DIR.parent / "libfbxqml")) if not (path / "fbx").is_dir(): sys.exit("libfbxqml introuvable : git clone https://github.com/fbx/libfbxqml.git %s" % path) return path diff --git a/tools/preview.qml b/tools/preview.qml index cc764f1..915a052 100644 --- a/tools/preview.qml +++ b/tools/preview.qml @@ -1,13 +1,13 @@ import QtQuick 2.5 import QtQuick.Window 2.2 -// Aperçu sur PC : charge Jellyfin.qml puis repasse la fenêtre en 1280x720 +// Aperçu sur PC : charge app/Jellyfin.qml puis repasse la fenêtre en 1280x720 // (fbx.application.Application force le plein écran au démarrage). QtObject { property var app: null Component.onCompleted: { - var component = Qt.createComponent("../Jellyfin.qml"); + var component = Qt.createComponent("../app/Jellyfin.qml"); if (component.status === Component.Error) { console.error(component.errorString()); Qt.quit();