"""SurfeX FR ad "Condo" (dust-free sanding, built on Arthur test.mov). Song: Sole Mare, "Late Checkout".
118.0 BPM, bar 2.0339s. Song in 44.871 (song bar 22, full groove). The 2-bar dip (song bars 30-31) =
ad 16.27-20.34 under "Et quand c'est fini...", the beat returns at ad 20.34 = APRES (flash) + "on dirait un plancher neuf".
Arthur test.mov = 8 shots (0-3.09 parked sander, 3.09-6.30 edger by the window, 6.30-12.60 dark floor walk,
12.60-15.52 drum on fresh wood, 15.52-18.89 edger close, 18.89-22.23 vacuum hose, 22.23-24.94 red belt): never cut across one.
Usage: /usr/bin/python3 build.py [scale]  |  /usr/bin/python3 build.py finish
"""
import os, sys
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "shared"))
os.chdir(os.path.dirname(os.path.abspath(__file__)))
from adkit import *
BAR = 4*60/118.0; b = lambda n: round(n*BAR, 3)
Z = lambda n: f"{AZ}/{n}"; ART = "../assets/arthur_test.mov"
fr = lambda s: round(s*FPS); F = lambda *ts: [fr(t) for t in ts]
cfg = dict(song="../music/late_checkout.mp3", song_in=44.871, end=b(17.5),
 shots=[
  dict(v=ART, a=6.4, t0=0, t1=b(2), z=(1.0, 1.06), grade="arthur"),        # condo, dark scratched floor
  dict(v=ART, a=0.5, t0=b(2), t1=b(3), grade="arthur"),                    # parked sander: "peur de la poussière?"
  dict(v=ART, a=22.4, t0=b(3), t1=b(4), z=(1.05, 1.0), grade="arthur"),    # red belt drum: "sans poussière"
  dict(v=ART, a=19.2, t0=b(4), t1=b(5), grade="arthur"),                   # vacuum hose: "aspiré à la machine"
  dict(v=ART, a=12.8, t0=b(5), t1=b(6), pan=(0.01, 0), grade="arthur"),    # drum on fresh wood
  dict(v=ART, a=15.6, t0=b(6), t1=b(7), grade="arthur"),                   # edger close: "les bordures"
  dict(v=ART, a=3.2, t0=b(7), t1=b(8), grade="arthur"),                    # edger by the window: "jusqu'au mur"
  dict(p=Z("7510686721.JPG"), t0=b(8), t1=b(10), z=(1.0, 1.10), grade="before"),   # the dip: raw strip vs old dark floor
  dict(v=Z("IMG_0376.MOV"), a=2.0, t0=b(10), t1=b(12), z=(1.06, 1.0), grade="after"),   # APRES: finished dark floor
  dict(v=Z("IMG_3573.MOV"), a=0.0, t0=b(12), t1=b(14), grade="after"),
  dict(v=Z("IMG_0376.MOV"), a=7.0, t0=b(14), t1=b(17.5), z=(1.0, 1.05), grade="after"),  # CTA
 ],
 fx=["whipR", "push", "whipL", "whipU", "spin", "whipD", "soft", "flash", "whipL", "push"],
 body="""
<div class="el blkT" id="t1"><div class="hd" style="font-size:110px;line-height:.98">EN CONDO?</div>
  <div class="scr" style="font-size:120px;margin-top:-2px;white-space:nowrap">planchers égratignés</div></div>
<div class="el blkB" id="t2"><div class="hd" style="font-size:96px;line-height:.98">PEUR DE LA</div>
  <div class="scr" style="font-size:170px;margin-top:-8px">poussière?</div></div>
<div class="el blkB" id="t3"><div class="hd" style="font-size:104px;line-height:1.0">SANS</div>
  <div class="hd" style="font-size:104px;line-height:1.0">POUSSIÈRE.</div><div class="scr" style="font-size:120px;margin-top:-2px">aspiré à la machine</div></div>
<div class="el blkB" id="t4"><div class="hd" style="font-size:92px;line-height:1.0">LES BORDURES,</div>
  <div class="scr" style="font-size:150px;margin-top:-6px">à la main</div></div>
<div class="el blkC" id="t5"><div class="hd" style="font-size:104px;line-height:1.0">ET QUAND</div>
  <div class="scr" style="font-size:170px;margin-top:-8px">c'est fini...</div></div>
<div class="el blkT" id="t6"><div class="hd" style="font-size:104px;line-height:1.0">COMME NEUF.</div>
  <div class="scr" style="font-size:132px;margin-top:-4px">sans rien remplacer</div></div>
""" + cta(["MONTRÉAL,", "LAVAL,"], "Rive-Sud, Rive-Nord", None, "Remplissez le formulaire", "Soumission gratuite"),
 seq=lambda T: [
  ["t1", fr(T.w(0,"en")), fr(b(2))-2, "T", F(T.w(0,"en"), T.w(0,"égratignés"))],
  ["t2", fr(T.w(1,"peur")), fr(T.w(2,"avec"))-1, "B", F(T.w(1,"peur"), T.w(1,"poussière"))],
  ["t3", fr(T.w(2,"sans")), fr(b(6))-2, "B", F(T.w(2,"sans"), T.w(2,"poussière"), T.w(2,"aspiré"))],
  ["t4", fr(T.w(3,"les")), fr(b(8))-2, "B", F(T.w(3,"les"), T.w(3,"main"))],
  ["t5", fr(T.w(4,"et")), fr(b(10))-1, "C", F(T.w(4,"et"), T.w(4,"c'est"))],
  ["t6", fr(T.w(5,"dirait")), fr(T.p(5)[1])+12, "T", F(T.w(5,"dirait"), T.w(5,"sans"))],
  ["cta", fr(T.w(6,"montréal")), 99999, "T", F(T.w(6,"montréal"), T.w(6,"laval"), T.w(6,"rive"), T.w(7,"remplissez"))]],
 labels=lambda T: [[fr(b(3))+4, fr(b(6))-2, "01 Sablage"], [fr(b(6))+2, fr(b(8))-1, "02 Bordures"],
                   [fr(b(8))+2, fr(b(10))-1, "Avant"], [fr(b(10)), fr(b(11))-2, "Après"]],
 sfx=[("SF/sander_drum.mp3", b(2), -17, 0.0, b(6)-b(2), 0.5), ("SF/sander_edger.mp3", b(6), -21, 0.0, b(8)-b(6), 0.4),
      ("SF/reverse_riser.mp3", b(10)-3.0, -6, 0.0, 3.0, 0.05), ("SF/slam_impact.mp3", b(10)-0.01, -5, 0.0, 2.4, 0.6)],
)
run(cfg)
