don't save 404
This commit is contained in:
parent
777f884a25
commit
6b0d0b4db6
1 changed files with 11 additions and 8 deletions
|
@ -70,6 +70,7 @@ def update_video(url, name):
|
||||||
print(url)
|
print(url)
|
||||||
try:
|
try:
|
||||||
r = requests.get(url, stream=True)
|
r = requests.get(url, stream=True)
|
||||||
|
if r.status_code == 200:
|
||||||
with open('%s.tmp' % name, 'wb') as fd:
|
with open('%s.tmp' % name, 'wb') as fd:
|
||||||
shutil.copyfileobj(r.raw, fd)
|
shutil.copyfileobj(r.raw, fd)
|
||||||
ox.avinfo('%s.tmp' % name)['duration']
|
ox.avinfo('%s.tmp' % name)['duration']
|
||||||
|
@ -78,6 +79,8 @@ def update_video(url, name):
|
||||||
os.utime(name, (mtime, mtime))
|
os.utime(name, (mtime, mtime))
|
||||||
ox.avinfo(name)['duration']
|
ox.avinfo(name)['duration']
|
||||||
get_subtitle(url.replace('1080p.mp4', lang + '.srt'), name.replace('.mp4', '.srt'))
|
get_subtitle(url.replace('1080p.mp4', lang + '.srt'), name.replace('.mp4', '.srt'))
|
||||||
|
else:
|
||||||
|
raise Exception('failed to download %s (%s)' % (url, r.status_code))
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
os.unlink(lock)
|
os.unlink(lock)
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
Loading…
Reference in a new issue