summary refs log tree commit diff
diff options
context:
space:
mode:
authorAntti Ajanki <antti.ajanki@iki.fi>2015-05-03 11:04:14 +0300
committerAntti Ajanki <antti.ajanki@iki.fi>2015-05-03 11:31:42 +0300
commit233c1c0e76d64c9e13dc8968bfd8a014c49e66a8 (patch)
tree35b3316a4d83f067ab3b55591aa2d576c5638796
parentd0fd305023b37f7776485679a74e422eade26c13 (diff)
downloadyoutube-dl-233c1c0e76d64c9e13dc8968bfd8a014c49e66a8.tar.gz
youtube-dl-233c1c0e76d64c9e13dc8968bfd8a014c49e66a8.tar.xz
youtube-dl-233c1c0e76d64c9e13dc8968bfd8a014c49e66a8.zip
[downloader/f4m] Fragment filenames must be sanitized
because the fragment was written to a file with a sanitized name by
http_dl.download()
-rw-r--r--youtube_dl/downloader/f4m.py23
1 files changed, 12 insertions, 11 deletions
diff --git a/youtube_dl/downloader/f4m.py b/youtube_dl/downloader/f4m.py
index b1a858c45..3cb07e15f 100644
--- a/youtube_dl/downloader/f4m.py
+++ b/youtube_dl/downloader/f4m.py
@@ -396,18 +396,19 @@ class F4mFD(FileDownloader):
                 success = http_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
@@ -430,7 +431,7 @@ class F4mFD(FileDownloader):
         elapsed = time.time() - start
         self.try_rename(tmpfilename, filename)
         for frag_file in frags_filenames:
-            os.remove(frag_file)
+            os.remove(encodeFilename(frag_file))
 
         fsize = os.path.getsize(encodeFilename(filename))
         self._hook_progress({