diff --git a/.gitignore b/.gitignore
index abd32e8..fd7a08d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
-*__pycache__*
\ No newline at end of file
+*__pycache__*
+/Videos/
\ No newline at end of file
diff --git a/README.md b/README.md
index 962e769..d7c083f 100644
--- a/README.md
+++ b/README.md
@@ -10,4 +10,104 @@ Simple Goal List
- FFPlay based playback of video and audio
- Ahead of time downloading of Youtube video content
- Ahead of time uploading of pictures and videos from external devices
-- USB media awareness/playback
\ No newline at end of file
+- USB media awareness/playback
+
+## YouTube download worker
+
+Install `yt-dlp` and make sure its command is on `PATH`. Install FFmpeg as well
+for downloads that need video/audio merging or other postprocessing. The worker
+uses Python's standard library; it does not need Flask.
+
+From the project directory, initialize or upgrade the database, then start the worker:
+
+```sh
+python3 sc_database_generator.py
+python3 youtube_downloader.py
+```
+
+The initializer requires Python 3.12 or newer (the SQLite wrapper uses
+`Connection.autocommit`). It preserves existing jobs when adding the media-name
+and retry-count columns and upgrading the allowed statuses. Existing jobs start
+with a retry count of zero. Stop running workers before upgrading the database.
+The worker polls every five seconds when idle or after a failed attempt;
+use `--poll-interval 10` to change that delay, or `--config /path/to/config.json`
+to select another configuration file.
+
+`config.json` includes `"youtube_download_location": "Videos"`. The folder is
+created automatically. The worker resolves relative storage and database paths
+against the configuration file's directory. Downloaded files are named
+`job-.` to avoid collisions and keep display names out of file paths.
+The default `Videos/` folder is excluded from Git.
+
+### Web interface
+
+Start the Flask app with `python3 sc_webserver.py` and use the home page's
+**Get Video from YouTube** link, or visit `/youtube/download`. Enter a media name
+and a YouTube video URL to queue a job. Invalid submissions show an error without
+creating a job; successful submissions redirect to `/youtube/jobs`.
+
+The jobs page shows pending, downloading, and failed jobs by default, including
+each job's name, URL, status, and failed-attempt count. Check **Include completed
+jobs** and click **Update List** to also show downloaded jobs. Refresh the page
+to see worker updates. Both pages are linked from the home screen.
+
+The download worker must run separately from Flask to process requests; submitting
+a form only adds a pending job. As with the existing upload endpoints, keep this
+interface on a trusted network until access controls are implemented.
+
+Alternatively, queue a job using SQL against `scdb.db`:
+
+```sql
+INSERT INTO youtube_download_job (
+ youtube_download_job_url,
+ youtube_download_job_media_name
+) VALUES (
+ 'https://www.youtube.com/watch?v=VIDEO_ID',
+ 'Desired button name'
+);
+```
+
+Jobs default to `pending`. The worker claims the oldest pending job by ID and
+marks it `downloading` before invoking `yt-dlp` without a shell interpreter.
+After a successful download and postprocessing, it checks that the reported file
+exists inside storage, then atomically inserts a `media` record and marks the job
+`downloaded`. The media record contains the requested display name and the final
+absolute file path. For older jobs or blank names, the video's title is used.
+No playback-option records are created automatically.
+
+`config.json` sets `"youtube_download_max_retries": 3`. This must be a
+non-negative integer; zero allows only the initial attempt. Each failed worker
+attempt increments the job's persistent `youtube_download_job_retry_count`.
+While the count is at or below the limit, the job returns to `pending` for retry
+after the polling delay. When the count exceeds the limit, its status becomes
+`failed` and the worker ignores it, allowing later jobs to run. With the default
+limit, this allows one initial attempt plus three retries (four failed attempts
+total). These are worker attempts; yt-dlp may also retry network requests
+internally. Successful downloads and Ctrl+C interruptions do not increment the
+counter.
+
+To manually retry a failed job with a fresh budget:
+
+```sql
+UPDATE youtube_download_job
+SET youtube_download_job_status = 'pending', youtube_download_job_retry_count = 0
+WHERE youtube_download_job_id = 123
+ AND youtube_download_job_status = 'failed';
+```
+
+Ctrl+C releases an in-flight job, but a forced termination or power loss can leave
+it `downloading`. Once you have confirmed no worker is still handling that job,
+reset it manually (this preserves its retry count):
+
+```sql
+UPDATE youtube_download_job
+SET youtube_download_job_status = 'pending'
+WHERE youtube_download_job_id = 123
+ AND youtube_download_job_status = 'downloading';
+```
+
+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
+```
\ No newline at end of file
diff --git a/TODO.md b/TODO.md
new file mode 100644
index 0000000..367dbb3
--- /dev/null
+++ b/TODO.md
@@ -0,0 +1,83 @@
+# Sanctuary Commander TODO
+
+Sanctuary Commander is the planned successor to Video Commander: a simple,
+web-based interface for managing sanctuary TVs and displaying dynamically added
+media. The current implementation provides the web interface and media-storage
+foundation; playback and device control are still future work.
+
+## Completed foundations
+
+- [x] Set up a Flask web server with configuration loaded from `config.json`.
+- [x] Organize implemented pages into Flask blueprints.
+- [x] Build a Bootstrap-based home page with controls grouped into common tools,
+ playback, and media submission.
+- [x] Create the configured upload directory automatically when the server starts.
+- [x] Implement static-image uploads that save a file and create a media record.
+- [x] Add browser-side upload progress reporting and basic upload error feedback.
+- [x] Implement stream registration with a display name and URL.
+- [x] Provide a SQLite database wrapper and a database initialization script.
+- [x] Define the media catalog and weighted playback-option tables.
+- [x] Add a YouTube download jobs table storing each URL and its status:
+ `pending`, `downloading`, `downloaded`, or `failed`.
+- [x] Store an optional fullscreen playback flag for registered streams.
+- [x] Remove the old preparation and component tables and slideshow scaffolding;
+ retain the media and playback-option tables and their existing records.
+
+## Finish the current workflows
+
+- [ ] Populate the home page with saved media and actionable playback buttons.
+- [ ] Connect the existing placeholder controls to backend actions.
+- [ ] Add input validation for media names, duplicate names, stream URLs, and
+ uploaded files.
+- [ ] Ensure upload destinations remain inside the configured upload directory.
+- [ ] Handle missing form fields, missing files, and storage/database failures
+ with useful error messages.
+- [x] Close request-scoped database connections when requests finish.
+
+## Playback and media preparation
+
+- [ ] Implement FFPlay-based video and audio playback.
+- [ ] Display uploaded static images.
+- [ ] Play registered streams and apply stored playback options.
+- [ ] Support uploading and playing local video files.
+- [x] Download YouTube videos ahead of time for later playback using queued jobs.
+- [x] Implement a download worker that updates job status from `pending` to
+ `downloading` to `downloaded` after the file is saved successfully.
+- [x] Store requested media names on jobs and register successful downloads in the
+ media catalog using the final local file path.
+- [x] Configure download storage (default: `Videos`) and return failed attempts to
+ pending for retry with logged errors.
+- [x] Add a web workflow for submitting YouTube URLs and desired media names.
+- [x] List pending, downloading, and failed jobs, with an opt-in checkbox to include
+ completed jobs.
+- [x] Persist per-job retry counts and mark jobs failed once they exceed the
+ configured retry limit (default: three retries after the initial attempt).
+- [ ] Add increasing retry backoff and recovery of jobs left downloading after a
+ forced termination.
+- [ ] Design a new approach to media preparation tracking, including the role of
+ the existing `media_preparing` flag; do not restore the old preparation table.
+- [ ] Implement background media preparation using the new tracking approach.
+- [ ] Surface preparation status in the web interface.
+- [ ] Track active and default media and implement their intended behavior.
+- [ ] Implement the Disable Video and Blackout Screen controls.
+- [ ] Detect USB media and make it available for playback.
+
+## TV and device control
+
+- [ ] Integrate with Home Assistant.
+- [ ] Implement TV power controls.
+- [ ] Implement TV volume controls.
+- [ ] Implement TV input selection.
+- [ ] Connect the home-page TV controls to the integration.
+
+## End goals and readiness
+
+- [ ] Provide one browser-based location for TV control and media playback.
+- [ ] Let users prepare and submit content dynamically rather than maintaining a
+ static media configuration file.
+- [ ] Keep everyday operation simple for less technically experienced users.
+- [ ] Document installation, dependencies, configuration, and normal operation.
+- [ ] Add automated coverage for upload, stream-registration, preparation,
+ playback, and device-control workflows as they are implemented.
+- [ ] Define appropriate access controls and a production deployment setup before
+ exposing upload or device-control endpoints beyond a trusted environment.
diff --git a/blueprints/configure_stream/configure_stream.py b/blueprints/configure_stream/configure_stream.py
index dcf842c..9943df1 100644
--- a/blueprints/configure_stream/configure_stream.py
+++ b/blueprints/configure_stream/configure_stream.py
@@ -29,5 +29,5 @@ def upload():
["media_id", "media_playback_option", "media_playback_option_weight"],
[new_id, "-fs", 1]
)
-
+
return redirect("/")
diff --git a/blueprints/home/home.html b/blueprints/home/home.html
index 05d1193..b5b124d 100644
--- a/blueprints/home/home.html
+++ b/blueprints/home/home.html
@@ -29,11 +29,11 @@
-
-
Upload a Slideshow of Photos
-
-
- Upload a slideshow of photos, you'll be able to order the photos on the next screen
-
-
-
-
diff --git a/blueprints/upload_slideshow/upload_slideshow.html b/blueprints/upload_slideshow/upload_slideshow.html
deleted file mode 100644
index ad913d6..0000000
--- a/blueprints/upload_slideshow/upload_slideshow.html
+++ /dev/null
@@ -1,46 +0,0 @@
-
-
-