From 6bce711ea3bf8d2306ac0256034d2c9c5862a879 Mon Sep 17 00:00:00 2001 From: j Date: Wed, 15 Mar 2017 11:08:49 +0100 Subject: [PATCH] play --- playout/play.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/playout/play.py b/playout/play.py index 1babfd8..d7c4d5a 100755 --- a/playout/play.py +++ b/playout/play.py @@ -5,6 +5,8 @@ import sys from glob import glob import datetime import time +import string +import random import ox import mpv @@ -32,10 +34,20 @@ playlist = 'play.m3u' today = datetime.date.today() seconds_since_midnight = time.time() - time.mktime(today.timetuple()) +prefix = '' if os.path.exists('local'): - files = sorted(glob('/srv/pandora/static/render/*/*.mp4')) -else: - files = sorted(glob('*/*.mp4')) + prefix = '/srv/pandora/static/render/' + +files = [] +videos = {} +for letter in string.ascii_uppercase: + videos[letter] = glob('%s*/%s.mp4' % (prefix, letter)) + random.shuffle(videos[letter]) + +for i in range(10): + for letter in string.ascii_uppercase: + files.append(videos[letter][i]) + position = 0 while position < seconds_since_midnight: f = files.pop(0)