Photo source provider plugin architecture #9
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Overview
Implement a plugin architecture for photo sources so the frame can pull photos from multiple backends simultaneously — local directories, cloud services, network shares, etc. Providers are the abstraction layer between "where photos live" and "what the frame displays."
Core Interface
Provider Registry
Providers register themselves on import. The server does
import providers.local,import providers.google_photos, etc. at startup. Or useimportlibto auto-discoverproviders/*.py.Provider Instance Model
Users can add multiple instances of the same provider type (e.g., two different Google Photos accounts, or three local directories). Each instance has:
Unified Photo Pool
When the ESP32 requests
/photo, the server:list_photos()on each (results are cached with a configurable TTL)PhotoRefs into a single pool, tagged with their provider instance IDweightfield)get_photo(ref)on the owning providerCaching Strategy
list_photos()result. Default TTL: 1 hour (same as the frame refresh interval). Cloud providers may want longer TTLs to avoid rate limits.DATA_DIR/thumb_cache/. Keyed by{provider_id}_{photo_id}. Avoids re-downloading thumbnails for the web UI gallery.Auth Patterns
Providers fall into three auth categories:
1. No auth (local, NAS mount)
Config is just a path. No special flow.
2. Credential-based (FTP, SFTP, WebDAV)
Config includes host/user/password (or key path). Stored in provider config. The web UI collects these in a form and the server stores them. Passwords should be stored in an env var or separate secrets file, not in
settings.json.3. OAuth2 (Google Photos, potentially others)
Requires a browser-based consent flow:
photos.haunt.house/api/providers/{id}/oauth/callbackThe server needs a
GET /api/providers/{id}/oauth/startendpoint that returns the consent URL, and aGET /api/providers/{id}/oauth/callbackendpoint that handles the redirect.Web UI Changes
Provider management page (
/settingsor section on main page)config_schema()Gallery changes
API Endpoints
File Structure
Migration from Current System
The current
PHOTOS_DIRlocal directory becomes the defaultlocalprovider instance, auto-created on first startup if no providers are configured. Existing per-image settings keyed by filename remain compatible — they'll match against thePhotoRef.namefrom the local provider.Implementation Order