diff --git a/app/api/scenes.py b/app/api/scenes.py index 0ad433d..794d141 100644 --- a/app/api/scenes.py +++ b/app/api/scenes.py @@ -1205,6 +1205,7 @@ class EnrichThumbOut(BaseModel): def enrich_thumbnail_from_tube( scene_id: uuid.UUID, session: Annotated[Session, Depends(get_session)], + force: bool = False, ) -> EnrichThumbOut: """Pobiera detail page z dowolnego tube playback_source bez thumbnail_url i wyciąga miniaturkę (og:image / twitter:image / LD-JSON thumbnailUrl / @@ -1213,7 +1214,10 @@ def enrich_thumbnail_from_tube( Update'uje WSZYSTKIE PlaybackSource'y dla tej sceny które nie mają thumb, żeby kolejne otwarcia listy widziały miniaturę niezależnie od source pick. Mobile auto-wywoła to przy otwarciu SceneDetail bez thumb (jak duration). - """ + + `force=true` (przycisk "Refresh thumbnail" na SceneDetail, zgłoszenie d3376a71): + NADPISUJE istniejącą miniaturę świeżą ze strony tube'a — dla zepsutych/stałych + (rotting sxyprn/trafficdeposit, błędna grafika).""" from app.extractors._fetch import browser_get from app.extractors._models import TubePageError from app.extractors.thumb_extract import extract_thumbnail_url @@ -1232,8 +1236,8 @@ def enrich_thumbnail_from_tube( ).scalars().all() sources_with_thumb = [s for s in sources if s.thumbnail_url] - if sources_with_thumb: - # już mamy — idempotent return. + if sources_with_thumb and not force: + # już mamy — idempotent return (force=true pomija, żeby odświeżyć). return EnrichThumbOut( scene_id=scene_id, thumbnail_url=sources_with_thumb[0].thumbnail_url, @@ -1250,10 +1254,10 @@ def enrich_thumbnail_from_tube( continue thumb = extract_thumbnail_url(r.text) if thumb: - # Zapisz na wszystkich źródłach bez thumb (oszczędza duplikat fetch) + # Zapisz na wszystkich źródłach bez thumb (force → też nadpisz istniejące). updated = 0 for s in sources: - if not s.thumbnail_url: + if force or not s.thumbnail_url: s.thumbnail_url = thumb updated += 1 session.commit()