Implement playback viewlog tracking#2670
Open
Alex1981-tech wants to merge 2 commits intoScreenly:masterfrom
Open
Implement playback viewlog tracking#2670Alex1981-tech wants to merge 2 commits intoScreenly:masterfrom
Alex1981-tech wants to merge 2 commits intoScreenly:masterfrom
Conversation
Add playback logging to the viewer: every time an asset starts playing, a record is written to ~/.screenly/viewlog.db with the asset ID, name, mimetype, URI, timestamp, and duration. This implements the previously stubbed-out viewlog feature in the /api/v2/info endpoint. Changes: - viewer/__init__.py: Add _init_viewlog_db(), _log_playback(), and _get_viewlog_db_path() functions. Initialize DB on viewer setup, log each asset playback in asset_loop() - api/views/mixins.py: Replace 'Not yet implemented' placeholder with _get_viewlog() that reads the last entry from viewlog.db - api/views/v2.py: Update InfoViewV2 to use _get_viewlog() and update OpenAPI schema to reflect the actual response format - api/tests/test_info_endpoints.py: Update expected viewlog value from 'Not yet implemented' to 'No data' (when viewlog.db doesn't exist) The viewlog.db is shared between viewer and server containers via the /data/.screenly bind mount, enabling the server to read what the viewer is currently displaying. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
|
@Alex1981-tech, thank you for opening a pull request! I will test and review the changes when I get the chance. |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Author
|
CI update: Fixed |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Implement the previously stubbed-out viewlog feature. The viewer now logs every asset playback to a SQLite database (
viewlog.db), and the/api/v2/infoendpoint returns the last played asset instead of"Not yet implemented".Problem
The
/api/v2/infoendpoint has aviewlogfield that has always returned"Not yet implemented". There's no way to know what the player is currently displaying or what it last played.Solution
Viewer side (
viewer/__init__.py):~/.screenly/viewlog.dbwith aviewlogtableasset_loop(), writes a record with:asset_id,asset_name,mimetype,uri,started_at(UTC ISO),durationAPI side (
api/views/mixins.py,api/views/v2.py):InfoViewMixin._get_viewlog()reads the most recent entry fromviewlog.db"No data"if empty/missingAPI Response (before → after)
Before:
{ "viewlog": "Not yet implemented", ... }After:
{ "viewlog": { "asset_id": "abc123", "asset_name": "My Video", "mimetype": "video", "started_at": "2024-01-15T12:00:00+00:00" }, ... }Or when no playback has occurred:
{ "viewlog": "No data", ... }How It Works
The
viewlog.dbfile lives in~/.screenly/which is shared between the viewer and server containers via the/data/.screenlybind mount. The viewer writes, the server reads.Test plan
viewlog.dbis created and populatedGET /api/v2/info— verifyviewlogfield contains last played asset detailsviewlogreturns"No data""No data"instead of"Not yet implemented"