Work to add Youtube downloads, video and image uploads, and the player script

This commit is contained in:
Bradley committed 2026-11-13 17:37:31 -05:00
1 parent a3f55a8c35
commit 92d6473e1d
15 files changed
+1047 -79

No files matched your search

+96 -1
View File
@@ -12,6 +12,101 @@ Simple Goal List
- Ahead of time uploading of pictures and videos from external devices
- USB media awareness/playback
## Fullscreen player
Install FFplay (usually provided by FFmpeg), then run the player in the graphical
session connected to the display:
```sh
python3 player.py
```
The player reads `config.json` beside the script and checks the database every
two seconds. Use `--config /path/to/config.json` for another configuration.
Relative database paths and local media paths are resolved against the config
file's directory; stream URLs are passed through unchanged.
Selection priority is:
1. The lowest-ID row with `media_active = 1`.
2. If none is active, the lowest-ID row with `media_default = 1`.
3. If neither exists, a fullscreen black screen generated by FFplay.
A selected row with a missing or blank URI also displays black. Changes to the
effective selected row or its URI stop the old FFplay process before starting
its replacement. Changes to other rows do not interrupt playback. Unexpected
FFplay exits are retried on the next poll. A finite video holds its last frame
at the end rather than clearing its active flag or automatically selecting
another item. Static images remain displayed until selection changes.
FFplay always starts fullscreen with its banner and progress output disabled.
Only FFplay errors are appended to `ffplay.log` beside `config.json`; stdout is
discarded. Use `--log-file /path/to/errors.log` to choose another log. The player
itself reports selection changes and database/process errors to the console.
Ctrl+C or SIGTERM stops the child process; a child that ignores termination is
killed after two seconds. The player does not modify the database and currently
does not apply `media_playback_option` records.
Until playback buttons are wired up, set selection flags directly in SQLite.
For example, select media ID 3 without temporarily leaving several active rows:
```sql
BEGIN;
UPDATE media SET media_active = 0;
UPDATE media SET media_active = 1 WHERE media_id = 3;
COMMIT;
```
Clear active flags to return to the default. Clear default flags too for black.
Flask and the player run separately; starting the web app alone does not start
playback. The player requires a working graphical display/audio session, not
just an SSH shell without display access.
## Uploading local videos
Use **Upload a Video** on the home page, or visit `/upload/video`. Enter a display
name and select one video. The limit is 5GB (5 × 1024³ bytes), checked both in the
browser and on the server. Common formats including MP4, MKV, MOV, WebM, AVI,
MPEG, and WMV are accepted by extension; the upload does not transcode or inspect
video codecs.
The page displays transfer progress and warns against navigating away. At 100%,
wait for the server to finish saving; only then will the page automatically
return home. Errors remain on the page so the user can retry. JavaScript is
required for this workflow.
Videos use the same `youtube_download_location` configuration as YouTube downloads
(default `Videos`, relative to `config.json`). Files receive unique generated
names, while the entered display name and absolute file path are saved to
`media`. Failed uploads are cleaned up. The separate player can display the
video when its media record is marked active or default.
This route requires Flask 3.1+ for its per-request size limit. Its request limit
includes a small allowance for multipart form overhead without raising other
routes' existing limits. If deploying behind a proxy, configure its request-size
limit and timeouts to permit 5GB uploads plus form overhead. Allow sufficient
space for both Flask's temporary upload and the final video file.
## Uploading static images
Use **Upload a Static Image** on the home page, or visit `/upload/photo`. Enter
an image name and choose one JPG/JPEG, PNG, WebP, BMP, TIFF, or GIF file. Files
are accepted by extension; this workflow does not decode the image or check for
animation. SVG and other active-content formats are not accepted.
Image uploads now use `"image_upload_location": "Images"` in `config.json`,
relative to that file. The folder is created automatically when saving an upload
and excluded from Git. Existing images in the older `uploads` location and their
media records are left unchanged.
The image page has a 100MB (100 × 1024² bytes) file limit in both the browser
and server. Like video uploads, it provides progress feedback, a warning not to
navigate away, and an automatic return home only after saving succeeds. Both pages share the same
upload JavaScript. Errors stay on the page for retry. Files have unique storage
names; the requested display name and absolute path are stored in `media`.
Failed uploads are cleaned up. JavaScript and Flask 3.1+ are required, and proxy
limits, timeouts, and temporary disk space must accommodate large uploads.
## YouTube download worker
Install `yt-dlp` and make sure its command is on `PATH`. Install FFmpeg as well
@@ -109,5 +204,5 @@ WHERE youtube_download_job_id = 123
Run the database and worker tests without downloading any videos:
```sh
python3 -m unittest test.youtube_download_job_test test.youtube_download_web_test -v
python3 -m unittest test.youtube_download_job_test test.youtube_download_web_test test.upload_video_test test.upload_photo_test test.player_test -v
```