Skip to content

Commit ccbf4a4

Browse files
committed
syncer: more robust change detection
1 parent 466f4ac commit ccbf4a4

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

syncer.py

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ def asset_to_tiles(asset):
2727
"x2": 1920,
2828
"y2": 1080,
2929
"config": {
30+
"fade_time": 0.5,
3031
"layer": -5,
3132
"looped": True,
32-
"fade_time": 0.5,
3333
},
3434
}
3535
)
@@ -82,19 +82,25 @@ def asset_to_tiles(asset):
8282

8383

8484
pages = []
85+
assets_visible = set()
8586
for asset in get_all_live_assets():
8687
pages.append(
8788
{
88-
"tiles": asset_to_tiles(asset),
89+
"auto_duration": 10,
90+
"duration": 10,
8991
"interaction": {"key": ""},
9092
"layout_id": -1, # Use first layout
9193
"overlap": 0,
92-
"auto_duration": 10,
93-
"duration": 10,
94+
"tiles": asset_to_tiles(asset),
9495
}
9596
)
97+
assets_visible.add(asset["id"])
9698

97-
log.info("There are currently {} pages visible".format(len(pages)))
99+
log.info(
100+
"There are currently {} pages visible with asset ids: {}".format(
101+
len(pages), ", ".join([str(i) for i in sorted(assets_visible)])
102+
)
103+
)
98104

99105
for setup_id in CONFIG["SETUP_IDS"]:
100106
slog = getLogger(f"Setup {setup_id}")
@@ -105,8 +111,19 @@ def asset_to_tiles(asset):
105111
for schedule in config["schedules"]:
106112
if schedule["name"] == "User Content":
107113
slog.info('Found schedule "User Content"')
114+
assets_shown = set()
115+
116+
for page in schedule["pages"]:
117+
for tile in page["tiles"]:
118+
if tile["type"] in ("image", "rawvideo"):
119+
assets_shown.add(tile["asset"])
108120

109-
if pages != schedule["pages"]:
121+
slog.info(
122+
"schedule shows assets: {}".format(
123+
", ".join([str(i) for i in sorted(assets_shown)])
124+
)
125+
)
126+
if assets_visible != assets_shown:
110127
schedule["pages"] = pages
111128
setup_changed = True
112129

0 commit comments

Comments
 (0)