X-Git-Url: http://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;f=youtube_dl%2Fdownloader%2Ff4m.py;h=174180db5bd4e5e42fca7a9feecdf8af4ea5e155;hb=db8f2bfd99fccd3ac4d96b49cf34056962a5652f;hp=275564b5976b9d28a7d67f839c81467029aa5c18;hpb=11bed5827dace09b5483b159476ce9f8c29d6078;p=youtube-dl.git diff --git a/youtube_dl/downloader/f4m.py b/youtube_dl/downloader/f4m.py index 275564b59..174180db5 100644 --- a/youtube_dl/downloader/f4m.py +++ b/youtube_dl/downloader/f4m.py @@ -13,6 +13,8 @@ from ..compat import ( compat_urllib_error, ) from ..utils import ( + encodeFilename, + sanitize_open, struct_pack, struct_unpack, xpath_text, @@ -343,18 +345,19 @@ class F4mFD(FragmentFD): success = ctx['dl'].download(frag_filename, {'url': url}) if not success: return False - with open(frag_filename, 'rb') as down: - down_data = down.read() - reader = FlvReader(down_data) - while True: - _, box_type, box_data = reader.read_box_info() - if box_type == b'mdat': - dest_stream.write(box_data) - break + (down, frag_sanitized) = sanitize_open(frag_filename, 'rb') + down_data = down.read() + down.close() + reader = FlvReader(down_data) + while True: + _, box_type, box_data = reader.read_box_info() + if box_type == b'mdat': + dest_stream.write(box_data) + break if live: - os.remove(frag_filename) + os.remove(encodeFilename(frag_sanitized)) else: - frags_filenames.append(frag_filename) + frags_filenames.append(frag_sanitized) except (compat_urllib_error.HTTPError, ) as err: if live and (err.code == 404 or err.code == 410): # We didn't keep up with the live window. Continue @@ -375,6 +378,6 @@ class F4mFD(FragmentFD): self._finish_frag_download(ctx) for frag_file in frags_filenames: - os.remove(frag_file) + os.remove(encodeFilename(frag_file)) return True