Open dundua opened 9 years ago
Seems like this issue has re-emerged. I'm downloading one video format and two audio formats from YouTube in seperate files and when the video file finished it will skip the two audio downloads.
D:\Video\Mindfield>youtube-dl.exe --output "%(uploader)s - %(upload_date)s - %(title)s (%(id)s).%(format_id)s" --format "313,258,251" --add-metadata --write-description --write-thumbnail --limit-rate 3M --ignore-errors --download-archive downloaded.txt -i PLZRRxQcaEjA4qyEuYfAMCazlL0vQDkIj2
[youtube:playlist] PLZRRxQcaEjA4qyEuYfAMCazlL0vQDkIj2: Downloading webpage
[download] Downloading playlist: Mind Field : Season 1
[youtube:playlist] playlist Mind Field : Season 1: Downloading 8 videos
[download] Downloading video 1 of 8
[download] Isolation - Mind Field (Ep 1) has already been recorded in archive
[download] Downloading video 2 of 8
[download] Conformity - Mind Field (Ep 2) has already been recorded in archive
[download] Downloading video 3 of 8
[youtube] zD68reVP0Ek: Downloading webpage
[youtube] zD68reVP0Ek: Downloading video info webpage
[info] zD68reVP0Ek: downloading video in 3 formats
[info] Writing video description to: Vsauce - 20170125 - Destruction - Mind Field (Ep 3) (zD68reVP0Ek).313.description
[youtube] zD68reVP0Ek: Downloading thumbnail ...
[youtube] zD68reVP0Ek: Writing thumbnail to: Vsauce - 20170125 - Destruction - Mind Field (Ep 3) (zD68reVP0Ek).jpg
[download] Resuming download at byte 138622096
[download] Destination: Vsauce - 20170125 - Destruction - Mind Field (Ep 3) (zD68reVP0Ek).313
[download] 100% of 2.90GiB in 20:59
[ffmpeg] Adding metadata to 'Vsauce - 20170125 - Destruction - Mind Field (Ep 3) (zD68reVP0Ek).313'
[download] Destruction - Mind Field (Ep 3) has already been recorded in archive
[download] Destruction - Mind Field (Ep 3) has already been recorded in archive
[download] Downloading video 4 of 8
[youtube] qZXpgf8N6hs: Downloading webpage
[youtube] qZXpgf8N6hs: Downloading video info webpage
[info] qZXpgf8N6hs: downloading video in 3 formats
In lights of the discussions in #7480, i think the following might be a harmonious solution:
--donwload-archive
option unchanged since that's probably the most common use-caseRegarding unreliable formats:
Storing the format selection string which was used to select the format at download time could be useful as well.
I.E. an archive entry might be formatted as follows
[service] [video_id] [format_id] [effective format selection string]
This would support use cases where the format id is instable or irrelevant while also opening up the possibilty to automatically reload better formats once they become available.
The effective format selection string
might be used in the following use case to ensure that the archive entry stored after loading the video won't block the download of the audio file:
youtube-dl -f 'bestvideo,bestaudio' "$url"
The user would occasionally run the following command to refresh on their favourite youtube channel:
youtube-dl --download-archive archive [youtube channel url]
At some point, youtube recodes some videos of this channel and starts serving them in a better format or youtube-dl
improves its "best format" detection.
Now, the user could run their usual command and supply it with the new option that enables checking for the format id. That way, every video that has a better format available now can automatically be reloaded.
youtube-dl
could add support for output-template-like parsing in the download archives filename.
As long as it allows the user to tell youtube-dl
to use a unique archive file for every format_id
or format selection string passed via the -f
option, the whole thing can be worked around.
As a plus, the use of instable format_id
s would happen to the users discretion.
This could also open up the possiblity of nice things like the following if wanted by the user:
youtube-dl --download-archive "archive_%(channel_id)"
Pending implementation of https://github.com/yt-dlp/yt-dlp/commit/a13e684813dccc21f3d71711bf79dafbe943bccb, if needed, see #11580.
The codebases are too different to apply anything like the yt-dlp fix. In the current code, a no-brain change to set a flag for a non-archived multi-format download that disables the in_download_archive()
check in _match_entry()
solves the problem:
--- old/youtube_dl/YoutubeDL.py
+++ new/youtube_dl/YoutubeDL.py
@@ -797,7 +797,7 @@
return 'Skipping %s, because it has exceeded the maximum view count (%d/%d)' % (video_title, view_count, max_views)
if age_restricted(info_dict.get('age_limit'), self.params.get('age_limit')):
return 'Skipping "%s" because it is age restricted' % video_title
- if self.in_download_archive(info_dict):
+ if self.in_download_archive(info_dict) and info_dict.get('__was_in_download_archive') is not False:
return '%s has already been recorded in archive' % video_title
if not incomplete:
@@ -1829,9 +1829,14 @@
if download:
if len(formats_to_download) > 1:
self.to_screen('[info] %s: downloading video in %s formats' % (info_dict['id'], len(formats_to_download)))
+ was_in_download_archive = self.in_download_archive(info_dict)
+ else:
+ was_in_download_archive = None
for format in formats_to_download:
new_info = dict(info_dict)
new_info.update(format)
+ if was_in_download_archive is False:
+ new_info['__was_in_download_archive'] = False
self.process_info(new_info)
# We update the info dict with the best quality format (backwards compatibility)
info_dict.update(formats_to_download[-1])
The --output-template ...
option must be such that different formats of the same id
will get different filenames:
$ python -m youtube_dl -f '18,22' 'https://youtu.be/twcbKbLQUuA?si=n_BeNP14zYxMJOY7' -o '%(title)s-%(id)s-%(format_id)s.%(ext)s' --test --download-archive archive
[youtube] twcbKbLQUuA: Downloading webpage
[info] twcbKbLQUuA: downloading video in 2 formats
[download] Destination: Holy Motors Movie CLIP - Merde (2012) - Denis Lavant, Eva Mendes Movie HD-twcbKbLQUuA-18.mp4
[download] 100% of 10.00KiB in 00:00
[download] Destination: Holy Motors Movie CLIP - Merde (2012) - Denis Lavant, Eva Mendes Movie HD-twcbKbLQUuA-22.mp4
[download] 100% of 10.00KiB in 00:00
$
I have an issue where downloading multiple file formats from a YouTube video will only download the first set of videos. For example, if a format selection is "-f 140+136,171+247" with the archive on with "--download-archive archive.txt", youtube-dl will only download formats 140+136. It will say that the video is already in the archive, and not download formats 171+247.
Example log