cdosea-play/cdoseaplay/lights.py
2017-08-29 19:27:06 +02:00

26 lines
488 B
Python
Executable file

#!/usr/bin/python3
import subprocess
import sys
import os
import time
import ox
from pi import random
path = sys.argv[1]
n = int(os.path.getctime(path) - 1495280000)
duration = ox.avinfo(path)['duration']
seq = random(n * 1000)
pos = 0
lights = []
while pos < duration - 15:
sleep = seq() + 15
light = seq() + 1
if pos + sleep > duration:
break
time.sleep(sleep)
cmd = ['/opt/LanBox-JSONRPC/fade.py', str(light)]
subprocess.Popen(cmd)
pos += sleep