From ac84916974745ac4a7ff37c952b3ca8cbbca93d0 Mon Sep 17 00:00:00 2001 From: nemesbak Date: Sat, 30 May 2026 01:06:58 +0200 Subject: [PATCH] fix(vod): preserve advanced-refresh metadata and fix youtube_trailer key - Use 'youtube_trailer' key (matching api_views.py and advanced refresh) instead of orphaned 'trailer' key that was never consumed. - On basic sync, only write director/actors/release_date to custom_properties when the field is currently empty. This prevents basic sync from overwriting richer data previously stored by refresh_movie_advanced_data, while still populating those fields for movies that have never had an advanced refresh run. Tested: logic verified against all three scenarios (preserve existing rich data, populate empty fields, youtube_trailer key propagation). Co-Authored-By: Claude Sonnet 4.6 --- apps/vod/tasks.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/apps/vod/tasks.py b/apps/vod/tasks.py index 78ad7389..b74ffcba 100644 --- a/apps/vod/tasks.py +++ b/apps/vod/tasks.py @@ -453,7 +453,7 @@ def process_movie_batch(account, batch, categories, relations, scan_start_time=N custom_props = {} if trailer: - custom_props['trailer'] = trailer + custom_props['youtube_trailer'] = trailer if director: custom_props['director'] = director if actors: @@ -573,9 +573,18 @@ def process_movie_batch(account, batch, categories, relations, scan_start_time=N # Merge incoming props into the existing dict so that # detailed_info and other keys written by advanced refresh # are not lost when a basic sync runs afterwards. + # For metadata fields (director/actors/release_date), only + # write if the field is empty — advanced refresh may have + # stored richer data that basic sync must not overwrite. existing_cp = movie.custom_properties or {} incoming_cp = value or {} - merged = {**existing_cp, **incoming_cp} + merged = dict(existing_cp) + for k, v in incoming_cp.items(): + if k in ('director', 'actors', 'release_date'): + if not existing_cp.get(k): + merged[k] = v + else: + merged[k] = v if merged != existing_cp: movie.custom_properties = merged updated = True