get text
This commit is contained in:
parent
b1f2b4b43d
commit
651607e354
1 changed files with 11 additions and 4 deletions
|
@ -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)
|
||||
shutil.move('%s.tmp' % name, name)
|
||||
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()
|
||||
|
|
Loading…
Reference in a new issue