Skip to content

Commit

Permalink
[FragmentFD] Respect --no-continue
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkf committed Mar 11, 2023
1 parent dfa6057 commit e734fe4
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions youtube_dl/downloader/fragment.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ def _download_fragment(self, ctx, frag_url, info_dict, headers=None):
'url': frag_url,
'http_headers': headers or info_dict.get('http_headers'),
}
if ctx['fragment_index'] > 0:
ctx['dl'].params['continuedl'] = True
success = ctx['dl'].download(fragment_filename, fragment_info_dict)
if not success:
return False, None
Expand Down Expand Up @@ -136,10 +138,11 @@ def _prepare_frag_download(self, ctx):
self.to_screen(
'[%s] Total fragments: %s' % (self.FD_NAME, total_frags_str))
self.report_destination(ctx['filename'])
continuedl = self.params.get('continuedl', True)
dl = HttpQuietDownloader(
self.ydl,
{
'continuedl': True,
'continuedl': continuedl,
'quiet': True,
'noprogress': True,
'ratelimit': self.params.get('ratelimit'),
Expand All @@ -162,9 +165,9 @@ def _prepare_frag_download(self, ctx):
'tmpfilename': tmpfilename,
'fragment_index': 0,
})

if self.__do_ytdl_file(ctx):
if os.path.isfile(encodeFilename(self.ytdl_filename(ctx['filename']))):
ytdl_file_exists = os.path.isfile(encodeFilename(self.ytdl_filename(ctx['filename'])))
if continuedl and ytdl_file_exists:
self._read_ytdl_file(ctx)
is_corrupt = ctx.get('ytdl_corrupt') is True
is_inconsistent = ctx['fragment_index'] > 0 and resume_len == 0
Expand All @@ -179,6 +182,10 @@ def _prepare_frag_download(self, ctx):
del ctx['ytdl_corrupt']
self._write_ytdl_file(ctx)
else:
if not continuedl:
if ytdl_file_exists:
self._read_ytdl_file(ctx)
ctx['fragment_index'] = resume_len = 0
self._write_ytdl_file(ctx)
assert ctx['fragment_index'] == 0

Expand Down

0 comments on commit e734fe4

Please sign in to comment.