Other campuses' LTC: match against North Attleboro's plan order, not only the songs with timecode
With the weekend's set not on Tracks yet, every campus song looked out of order. The campuses now pair with the home plan itself; a song the home set has no timecode for yet is matched but neither faulted nor written, and the campuses are not looked at at all until the home set gives some timecode. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
+14
-8
@@ -655,12 +655,16 @@ def match_in_order(na_songs, campus_songs):
|
||||
return pairs, skipped
|
||||
|
||||
|
||||
def campus_ltc(rc, na_songs, campus, plan):
|
||||
"""One other campus's plan against the home timecode: its songs in home order, each with the
|
||||
timecode it should carry and what its LTC note says now."""
|
||||
def campus_ltc(rc, na_plan, na_songs, campus, plan):
|
||||
"""One other campus's plan against the home timecode: its songs in the home plan's order, each
|
||||
with the timecode the home set gives that song (None while the set has none) and what its LTC
|
||||
note says now."""
|
||||
note = rc.get("ltc_note", "LTC")
|
||||
pairs, skipped = match_in_order(na_songs, plan_songs(rc, plan))
|
||||
songs = [{"item": it, "title": it["title"], "tracks": s["tracks"], "pco": (it["notes"].get(note) or "").strip()} for it, s in pairs]
|
||||
pairs, skipped = match_in_order(plan_songs(rc, na_plan), plan_songs(rc, plan))
|
||||
songs = []
|
||||
for it, home in pairs:
|
||||
tc = next((s["tracks"] for s in na_songs if same(home["title"], s["title"])), None)
|
||||
songs.append({"item": it, "title": it["title"], "tracks": tc, "pco": (it["notes"].get(note) or "").strip()})
|
||||
return {"name": campus.get("name") or campus.get("short") or str(campus.get("service_type")), "short": campus.get("short") or (campus.get("name") or "?")[:2].upper(),
|
||||
"service_type": str(campus.get("service_type")), "plan_id": plan["id"], "dates": plan.get("dates", ""), "songs": songs, "skipped": skipped}
|
||||
|
||||
@@ -669,6 +673,8 @@ def eval_campus_ltc(rc, result, line):
|
||||
"""The other campus's notes must say the home timecode for every matched song."""
|
||||
tag = result["short"]
|
||||
for s in result["songs"]:
|
||||
if s["tracks"] is None: # the home set has no timecode for it yet: the home line says so
|
||||
continue
|
||||
if not s["pco"]:
|
||||
line.fault(ERR, "%s NO LTC %s" % (tag, short(s["title"], 12)), "%s: %s has no %s note; the tracks start it at %s" % (
|
||||
result["name"], s["title"], rc.get("ltc_note", "LTC"), s["tracks"]))
|
||||
@@ -1070,12 +1076,12 @@ def look(cfg, now=None, data_dir=None, sources=None):
|
||||
LAST["ltc"] = [dict(s, item={"id": s["item"]["id"], "note_ids": s["item"]["note_ids"]}) for s in na_songs]
|
||||
LAST["service_type"], LAST["plan_id"] = plan.get("service_type"), plan["id"]
|
||||
others = []
|
||||
for campus in rc.get("ltc_campuses") or []:
|
||||
for campus in (rc.get("ltc_campuses") or []) if na_songs else []: # nothing to give the others yet
|
||||
if not campus.get("service_type"):
|
||||
continue
|
||||
try:
|
||||
cplan = src["pco_campus"](campus["service_type"])
|
||||
res = campus_ltc(rc, na_songs, campus, cplan)
|
||||
res = campus_ltc(rc, plan, na_songs, campus, cplan)
|
||||
eval_campus_ltc(rc, res, lines["timecode"])
|
||||
others.append(dict(res, songs=[dict(s, item={"id": s["item"]["id"], "note_ids": s["item"]["note_ids"]}) for s in res["songs"]]))
|
||||
except Exception as e: # noqa: BLE001 - one campus's plan down must not hide the home one
|
||||
@@ -1140,7 +1146,7 @@ class Poller(threading.Thread):
|
||||
|
||||
def write_ltc(rc, songs, service_type, plan_id):
|
||||
"""Write the tracks' timecode into PCO's LTC note of every song where it is missing or different."""
|
||||
todo = [s for s in songs if s["pco"] != s["tracks"]]
|
||||
todo = [s for s in songs if s["tracks"] and s["pco"] != s["tracks"]]
|
||||
if not todo:
|
||||
return True
|
||||
if not (service_type and plan_id):
|
||||
|
||||
Reference in New Issue
Block a user