new names

This commit is contained in:
j 2017-05-15 19:03:28 +02:00
parent ed4b2fde61
commit 867abbf74d
2 changed files with 8 additions and 7 deletions

View file

@ -1,5 +1,4 @@
#!/usr/bin/python3 #!/usr/bin/python3
import subprocess
import os import os
import sys import sys
from glob import glob from glob import glob
@ -34,14 +33,14 @@ playlist = 'play.m3u'
today = datetime.date.today() today = datetime.date.today()
seconds_since_midnight = time.time() - time.mktime(today.timetuple()) seconds_since_midnight = time.time() - time.mktime(today.timetuple())
prefix = '' prefix = 'video/'
if os.path.exists('local'): if os.path.exists('local'):
prefix = '/srv/pandora/static/render/' prefix = '/srv/pandora/static/render/'
files = [] files = []
videos = {} videos = {}
for letter in string.ascii_uppercase: 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]) random.shuffle(videos[letter])
for i in range(10): for i in range(10):

View file

@ -18,19 +18,21 @@ os.chdir(folder)
if os.path.exists(lock): if os.path.exists(lock):
sys.exit(0) 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 i in range(10):
for letter in string.ascii_uppercase: for letter in string.ascii_lowercase:
name = '%02d/%s.mp4' % (i, letter) name = '%s%02d.1080p.mp4' % (letter, i)
url = '%s/%s' % (base, name) url = '%s/%s' % (base, name)
name = 'video/' + name
folder = os.path.dirname(name) folder = os.path.dirname(name)
if not os.path.exists(folder): if not os.path.exists(folder):
os.makedirs(folder) os.makedirs(folder)
if os.path.exists(name): if os.path.exists(name):
head = requests.head(url) head = requests.head(url)
mtime = time.mktime(datetime.datetime.strptime(head.headers.get("Last-Modified"), "%a, %d %b %Y %X GMT").timetuple()) 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: else:
get = True get = True
if get: if get: