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):
|
def get_subtitle(url, name):
|
||||||
try:
|
try:
|
||||||
r = requests.get(url, stream=True)
|
r = requests.get(url)
|
||||||
with open('%s.tmp' % name, 'wb') as fd:
|
if r.status_code == 200:
|
||||||
shutil.copyfileobj(r.raw, fd)
|
with open('%s.tmp' % name, 'w') as fd:
|
||||||
|
fd.write(r.text)
|
||||||
shutil.move('%s.tmp' % name, name)
|
shutil.move('%s.tmp' % name, name)
|
||||||
|
else:
|
||||||
|
print('%s failed (%s)' % (url, r.status_code))
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
os.unlink(lock)
|
||||||
|
sys.exit(-1)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -90,6 +96,7 @@ def update_videos():
|
||||||
update_video(url, name)
|
update_video(url, name)
|
||||||
os.unlink(lock)
|
os.unlink(lock)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
if len(sys.argv) > 1 and sys.argv[1] == 'subtitles':
|
if len(sys.argv) > 1 and sys.argv[1] == 'subtitles':
|
||||||
get_all_subtitles()
|
get_all_subtitles()
|
||||||
|
|
Loading…
Reference in a new issue