playout
This commit is contained in:
parent
1da2ac0475
commit
a1c5108b45
2 changed files with 25 additions and 8 deletions
|
@ -31,15 +31,22 @@ playlist = 'play.m3u'
|
|||
|
||||
today = datetime.date.today()
|
||||
seconds_since_midnight = time.time() - time.mktime(today.timetuple())
|
||||
files = sorted(glob('*/*.mp4'))
|
||||
|
||||
if os.path.exists('local'):
|
||||
files = sorted(glob('/srv/pandora/static/render/*/*.mp4'))
|
||||
else:
|
||||
files = sorted(glob('*/*.mp4'))
|
||||
position = 0
|
||||
while position < seconds_since_midnight:
|
||||
f = files.pop(0)
|
||||
try:
|
||||
position += ox.avinfo(f)['duration']
|
||||
files.append(f)
|
||||
except:
|
||||
pass
|
||||
|
||||
with open(playlist, 'w') as f:
|
||||
f.write('\n'.join(sorted(glob('*/*.mp4'))))
|
||||
f.write('\n'.join(files))
|
||||
|
||||
player.loadlist(playlist)
|
||||
while True:
|
||||
|
|
|
@ -5,12 +5,21 @@ import string
|
|||
import time
|
||||
import datetime
|
||||
import shutil
|
||||
import sys
|
||||
import socket
|
||||
import ox
|
||||
|
||||
socket.setdefaulttimeout(10)
|
||||
|
||||
base = 'https://cdosea.0x2620.org/static/render'
|
||||
|
||||
lock = '/tmp/update.lock'
|
||||
folder = os.path.abspath(os.path.dirname(__file__))
|
||||
os.chdir(folder)
|
||||
|
||||
if os.path.exists(lock):
|
||||
sys.exit(0)
|
||||
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)
|
||||
|
@ -26,10 +35,11 @@ for i in range(10):
|
|||
get = True
|
||||
if get:
|
||||
try:
|
||||
#print(url)
|
||||
r = requests.get(url)
|
||||
r = requests.get(url, stream=True)
|
||||
with open('%s.tmp' % name, 'wb') as fd:
|
||||
shutil.copyfileobj(r.raw, fd)
|
||||
ox.avinfo('%s.tmp' % name)['duration']
|
||||
shutil.move('%s.tmp' % name, name)
|
||||
except:
|
||||
pass
|
||||
print(url, 'failed')
|
||||
os.unlink(lock)
|
||||
|
|
Loading…
Reference in a new issue