Fix issue with partial downloads

When using --start or --end, only keep the segments which have been
downloaded, and skip the rest.
This commit is contained in:
Ivan Habunek 2020-09-03 11:59:44 +02:00
parent ac37f179ef
commit a245ffb6a4
No known key found for this signature in database
GPG Key ID: CDBD63C43A30BB95

View File

@ -284,8 +284,14 @@ def _download_video(video_id, args):
path_map = download_files(base_uri, target_dir, vod_paths, args.max_workers)
# Make a modified playlist which references downloaded VODs
for segment in playlist.segments:
segment.uri = path_map[segment.uri]
# Keep only the downloaded segments and skip the rest
org_segments = playlist.segments.copy()
playlist.segments.clear()
for segment in org_segments:
if segment.uri in path_map:
segment.uri = path_map[segment.uri]
playlist.segments.append(segment)
playlist_path = target_dir + "playlist_downloaded.m3u8"
playlist.dump(playlist_path)