From c53c6765fd237eb1c9bd6ee2c6c4a3990062d010 Mon Sep 17 00:00:00 2001 From: Kevin Mark Date: Sat, 8 Jul 2017 19:19:30 -0400 Subject: [PATCH] Always truncate files to 10241 bytes with --test This should prevent issues like that in #13449 where the FFmpeg downloader was not reliably trimming to the correct length. --- youtube_dl/downloader/common.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/youtube_dl/downloader/common.py b/youtube_dl/downloader/common.py index 77242dacc..87793e1ee 100644 --- a/youtube_dl/downloader/common.py +++ b/youtube_dl/downloader/common.py @@ -358,7 +358,14 @@ class FileDownloader(object): else '%.2f' % sleep_interval)) time.sleep(sleep_interval) - return self.real_download(filename, info_dict) + real_download_result = self.real_download(filename, info_dict) + + if real_download_result and self.params.get('test', False): + f = open(filename, 'ab') + f.truncate(self._TEST_FILE_SIZE) + f.close() + + return real_download_result def real_download(self, filename, info_dict): """Real download process. Redefine in subclasses."""