This commit is contained in:
j 2017-10-04 11:02:34 +02:00
parent b1f2b4b43d
commit 651607e354

View file

@ -33,10 +33,16 @@ if os.path.exists(conf):
def get_subtitle(url, name):
try:
r = requests.get(url, stream=True)
with open('%s.tmp' % name, 'wb') as fd:
shutil.copyfileobj(r.raw, fd)
r = requests.get(url)
if r.status_code == 200:
with open('%s.tmp' % name, 'w') as fd:
fd.write(r.text)
shutil.move('%s.tmp' % name, name)
else:
print('%s failed (%s)' % (url, r.status_code))
except KeyboardInterrupt:
os.unlink(lock)
sys.exit(-1)
except:
pass
@ -90,6 +96,7 @@ def update_videos():
update_video(url, name)
os.unlink(lock)
if __name__ == '__main__':
if len(sys.argv) > 1 and sys.argv[1] == 'subtitles':
get_all_subtitles()