X-Git-Url: http://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=youtube_dl%2Fdownloader%2Ffragment.py;h=6f6fb4a77a9dc2b3e4e4278bc51b12755bc709ee;hb=ee093a0ea04d973cc6dbd0d53b57c976a9e68dad;hp=50c8254a4f20c840c9bfa6617716823af881b4ac;hpb=290f64dbaa3a8c187d47b72b3c808bd52d15a6e8;p=youtube-dl.git diff --git a/youtube_dl/downloader/fragment.py b/youtube_dl/downloader/fragment.py index 50c8254a4..6f6fb4a77 100644 --- a/youtube_dl/downloader/fragment.py +++ b/youtube_dl/downloader/fragment.py @@ -46,9 +46,11 @@ class FragmentFD(FileDownloader): Dictionary of downloader related data. May contain following data: current_fragment: Dictionary with current (being downloaded) fragment data: - index: Index of current fragment among all fragments + index: 0-based index of current fragment among all fragments fragment_count: Total count of fragments + + This feature is experimental and file format may change in future. """ def report_retry_fragment(self, err, frag_index, count, retries): @@ -149,12 +151,15 @@ class FragmentFD(FileDownloader): if self.__do_ytdl_file(ctx): if os.path.isfile(encodeFilename(self.ytdl_filename(ctx['filename']))): self._read_ytdl_file(ctx) + if ctx['fragment_index'] > 0 and resume_len == 0: + self.report_error( + 'Inconsistent state of incomplete fragment download. ' + 'Restarting from the beginning...') + ctx['fragment_index'] = resume_len = 0 + self._write_ytdl_file(ctx) else: self._write_ytdl_file(ctx) - if ctx['fragment_index'] > 0: - assert resume_len > 0 - else: - assert resume_len == 0 + assert ctx['fragment_index'] == 0 dest_stream, tmpfilename = sanitize_open(tmpfilename, open_mode)