[downloader/f4m] Fragment filenames must be sanitized
because the fragment was written to a file with a sanitized name by http_dl.download()
This commit is contained in:
parent
d0fd305023
commit
233c1c0e76
|
@ -396,8 +396,9 @@ class F4mFD(FileDownloader):
|
||||||
success = http_dl.download(frag_filename, {'url': url})
|
success = http_dl.download(frag_filename, {'url': url})
|
||||||
if not success:
|
if not success:
|
||||||
return False
|
return False
|
||||||
with open(frag_filename, 'rb') as down:
|
(down, frag_sanitized) = sanitize_open(frag_filename, 'rb')
|
||||||
down_data = down.read()
|
down_data = down.read()
|
||||||
|
down.close()
|
||||||
reader = FlvReader(down_data)
|
reader = FlvReader(down_data)
|
||||||
while True:
|
while True:
|
||||||
_, box_type, box_data = reader.read_box_info()
|
_, box_type, box_data = reader.read_box_info()
|
||||||
|
@ -405,9 +406,9 @@ class F4mFD(FileDownloader):
|
||||||
dest_stream.write(box_data)
|
dest_stream.write(box_data)
|
||||||
break
|
break
|
||||||
if live:
|
if live:
|
||||||
os.remove(frag_filename)
|
os.remove(encodeFilename(frag_sanitized))
|
||||||
else:
|
else:
|
||||||
frags_filenames.append(frag_filename)
|
frags_filenames.append(frag_sanitized)
|
||||||
except (compat_urllib_error.HTTPError, ) as err:
|
except (compat_urllib_error.HTTPError, ) as err:
|
||||||
if live and (err.code == 404 or err.code == 410):
|
if live and (err.code == 404 or err.code == 410):
|
||||||
# We didn't keep up with the live window. Continue
|
# We didn't keep up with the live window. Continue
|
||||||
|
@ -430,7 +431,7 @@ class F4mFD(FileDownloader):
|
||||||
elapsed = time.time() - start
|
elapsed = time.time() - start
|
||||||
self.try_rename(tmpfilename, filename)
|
self.try_rename(tmpfilename, filename)
|
||||||
for frag_file in frags_filenames:
|
for frag_file in frags_filenames:
|
||||||
os.remove(frag_file)
|
os.remove(encodeFilename(frag_file))
|
||||||
|
|
||||||
fsize = os.path.getsize(encodeFilename(filename))
|
fsize = os.path.getsize(encodeFilename(filename))
|
||||||
self._hook_progress({
|
self._hook_progress({
|
||||||
|
|
Loading…
Reference in New Issue