diff --git a/playout/play.py b/playout/play.py index d7c4d5a..8aff09f 100755 --- a/playout/play.py +++ b/playout/play.py @@ -1,5 +1,4 @@ #!/usr/bin/python3 -import subprocess import os import sys from glob import glob @@ -34,14 +33,14 @@ playlist = 'play.m3u' today = datetime.date.today() seconds_since_midnight = time.time() - time.mktime(today.timetuple()) -prefix = '' +prefix = 'video/' if os.path.exists('local'): prefix = '/srv/pandora/static/render/' files = [] videos = {} for letter in string.ascii_uppercase: - videos[letter] = glob('%s*/%s.mp4' % (prefix, letter)) + videos[letter] = glob('%s%s*.mp4' % (prefix, letter.lower())) random.shuffle(videos[letter]) for i in range(10): diff --git a/playout/update.py b/playout/update.py index 3954409..499ac62 100755 --- a/playout/update.py +++ b/playout/update.py @@ -18,19 +18,21 @@ os.chdir(folder) if os.path.exists(lock): sys.exit(0) -with open(lock, 'w') as f: f.write('') +with open(lock, 'w') as f: + f.write('') for i in range(10): - for letter in string.ascii_uppercase: - name = '%02d/%s.mp4' % (i, letter) + for letter in string.ascii_lowercase: + name = '%s%02d.1080p.mp4' % (letter, i) url = '%s/%s' % (base, name) + name = 'video/' + name folder = os.path.dirname(name) if not os.path.exists(folder): os.makedirs(folder) if os.path.exists(name): head = requests.head(url) mtime = time.mktime(datetime.datetime.strptime(head.headers.get("Last-Modified"), "%a, %d %b %Y %X GMT").timetuple()) - get = mtime > os.path.getmtime(name) + get = mtime > os.path.getmtime(name) or int(head.headers.get("Content-Length")) != os.path.getsize(name) else: get = True if get: