36 lines
1 KiB
Python
36 lines
1 KiB
Python
|
#!/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
|