feat: add paged NAS photo browser with metadata filters and previews
Community checks / verify (push) Skipped
Verify Frame Flow / verify (push) Failing after 7m29s

This commit is contained in:
渡口浪人
2026-10-23 19:59:02 +08:00
parent 8ce4aafb93
commit 6ebc5e7afb
14 changed files with 579 additions and 25 deletions
+20 -3
View File
@@ -88,6 +88,9 @@ class PhotoSources:
self.db, self.settings, self.assets = db, settings, assets
self.cache = {}
self.api_items = {}
from pigway_frame_flow.providers.source_browser import SourceBrowser
self.browser = SourceBrowser(self)
self.synology = SynologyPhotos(settings)
# Register provider secrets before request IDs or errors can be reflected.
for row in self.list():
@@ -584,7 +587,16 @@ class PhotoSources:
def read(self, source_id, item_id=None, *, target_size=(1200, 1600)):
source = self.get(source_id)
items = self.catalog(source_id, target_size=target_size)
browsed = (
self.browser.cached(source_id, item_id)
if item_id and source.kind == "synology-photos"
else None
)
items = (
[browsed[1]]
if browsed
else self.catalog(source_id, target_size=target_size)
)
if not item_id:
items = eligible(self.db, source_id, items)
if not items:
@@ -641,13 +653,18 @@ class PhotoSources:
raise FlowError(E.NOT_FOUND, "Photo is unavailable", 404) from None
elif source.kind == "synology-photos":
data = self.synology.download(
self.api_items[source_id][item["id"]], space=source.people_space
browsed[2] if browsed else self.api_items[source_id][item["id"]],
space=source.people_space,
)
if source.folder_caption:
caption = dict(item.get("caption") or {})
try:
caption["people"] = " & ".join(
self.synology.item_people(item["id"], space=source.people_space)
[p["name"] for p in item.get("people", []) if p["name"]]
if browsed
else self.synology.item_people(
item["id"], space=source.people_space
)
)
except FlowError:
# Optional labels must not prevent displaying a valid photo.