add playout
This commit is contained in:
parent
e80e6baf43
commit
77df4a4151
4 changed files with 1022 additions and 0 deletions
35
playout/update.py
Executable file
35
playout/update.py
Executable file
|
|
@ -0,0 +1,35 @@
|
|||
#!/usr/bin/python3
|
||||
import os
|
||||
import requests
|
||||
import string
|
||||
import time
|
||||
import datetime
|
||||
import shutil
|
||||
|
||||
base = 'https://cdosea.0x2620.org/static/render'
|
||||
|
||||
folder = os.path.abspath(os.path.dirname(__file__))
|
||||
os.chdir(folder)
|
||||
|
||||
for i in range(10):
|
||||
for letter in string.ascii_uppercase:
|
||||
name = '%02d/%s.mp4' % (i, letter)
|
||||
url = '%s/%s' % (base, 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)
|
||||
else:
|
||||
get = True
|
||||
if get:
|
||||
try:
|
||||
#print(url)
|
||||
r = requests.get(url)
|
||||
with open('%s.tmp' % name, 'wb') as fd:
|
||||
shutil.copyfileobj(r.raw, fd)
|
||||
shutil.move('%s.tmp' % name, name)
|
||||
except:
|
||||
pass
|
||||
Loading…
Add table
Add a link
Reference in a new issue