From 171f0e85ff9dcf57a0f9b4a31941255442bffce4 Mon Sep 17 00:00:00 2001 From: mrfunkycoda <34271361+mrfunkycoda@users.noreply.github.com> Date: Tue, 5 Dec 2017 14:53:18 +0200 Subject: [PATCH 1/6] Update options.py --- youtube_dl/options.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/youtube_dl/options.py b/youtube_dl/options.py index 4c0455044..2c7349483 100644 --- a/youtube_dl/options.py +++ b/youtube_dl/options.py @@ -563,7 +563,15 @@ def parseOpts(overrideArguments=None): 'Upper bound of a range for randomized sleep before each download ' '(maximum possible number of seconds to sleep). Must only be used ' 'along with --min-sleep-interval.')) - + workarounds.add_option( + '--youtube-prefer-get-video-info', + action='store_true', dest='youtube_prefer_get_video_info', default=False, + help=( + 'By prefering a Youtube link extracted from get_video_info instead ' + 'of the video\'s webpage, Youtube is likely to send a link with the ' + '"content-disposition: Attachment" header added (provided you add the ' + '"&title=...." option to the link)')) + verbosity = optparse.OptionGroup(parser, 'Verbosity / Simulation Options') verbosity.add_option( '-q', '--quiet', From 641ce63f35f1a9165ed45ff520cde7d40a9693e0 Mon Sep 17 00:00:00 2001 From: mrfunkycoda <34271361+mrfunkycoda@users.noreply.github.com> Date: Tue, 5 Dec 2017 14:56:44 +0200 Subject: [PATCH 2/6] Update youtube.py adding support for the --youtube-prefer-get-video-info workaround option --- youtube_dl/extractor/youtube.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/youtube_dl/extractor/youtube.py b/youtube_dl/extractor/youtube.py index 9943dddc1..d9a56cc68 100644 --- a/youtube_dl/extractor/youtube.py +++ b/youtube_dl/extractor/youtube.py @@ -1550,7 +1550,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor): if args.get('livestream') == '1' or args.get('live_playback') == 1: is_live = True sts = ytplayer_config.get('sts') - if not video_info or self._downloader.params.get('youtube_include_dash_manifest', True): + if not video_info or self._downloader.params.get('youtube_include_dash_manifest', True) or self._downloader.params.get('youtube_prefer_get_video_info', True): # We also try looking in get_video_info since it may contain different dashmpd # URL that points to a DASH manifest with possibly different itag set (some itags # are missing from DASH manifest pointed by webpage's dashmpd, some - from DASH @@ -1558,7 +1558,9 @@ class YoutubeIE(YoutubeBaseInfoExtractor): # The general idea is to take a union of itags of both DASH manifests (for example # video with such 'manifest behavior' see https://github.com/rg3/youtube-dl/issues/6093) self.report_video_info_webpage_download(video_id) - for el in ('info', 'embedded', 'detailpage', 'vevo', ''): + # el=detailpage makes the resulting extracted urls ignore the 'title' parameter, thus, omiting the content-disposition: Attachment header + # that's why it should be the last option: + for el in ('info', 'embedded', 'vevo', '', 'detailpage'): query = { 'video_id': video_id, 'ps': 'default', @@ -1593,7 +1595,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor): # due to YouTube measures against IP ranges of hosting providers. # Working around by preferring the first succeeded video_info containing # the token if no such video_info yet was found. - if 'token' not in video_info: + if 'token' not in video_info or self._downloader.params.get('youtube_prefer_get_video_info', True): video_info = get_video_info break if 'token' not in video_info: From 50bc8d67dcc54c739c6101dea53d6066b1bfc1da Mon Sep 17 00:00:00 2001 From: mrfunkycoda <34271361+mrfunkycoda@users.noreply.github.com> Date: Tue, 5 Dec 2017 15:08:33 +0200 Subject: [PATCH 3/6] Update youtube.py --- youtube_dl/extractor/youtube.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/youtube_dl/extractor/youtube.py b/youtube_dl/extractor/youtube.py index d9a56cc68..9b162ae71 100644 --- a/youtube_dl/extractor/youtube.py +++ b/youtube_dl/extractor/youtube.py @@ -1558,9 +1558,13 @@ class YoutubeIE(YoutubeBaseInfoExtractor): # The general idea is to take a union of itags of both DASH manifests (for example # video with such 'manifest behavior' see https://github.com/rg3/youtube-dl/issues/6093) self.report_video_info_webpage_download(video_id) - # el=detailpage makes the resulting extracted urls ignore the 'title' parameter, thus, omiting the content-disposition: Attachment header - # that's why it should be the last option: - for el in ('info', 'embedded', 'vevo', '', 'detailpage'): + if self._downloader.params.get('youtube_prefer_get_video_info', True): + # el=detailpage makes the resulting extracted urls ignore the 'title' parameter, thus, omiting the content-disposition: Attachment header + # that's why it should be the last option: + el_order = ('info', 'embedded', 'vevo', '', 'detailpage') + else: + el_order = ('info', 'embedded', 'detailpage', 'vevo', ''): + for el in el_order: query = { 'video_id': video_id, 'ps': 'default', From e83a61e6eca187cf5854084ea367d2c07259cd16 Mon Sep 17 00:00:00 2001 From: mrfunkycoda <34271361+mrfunkycoda@users.noreply.github.com> Date: Tue, 5 Dec 2017 15:10:58 +0200 Subject: [PATCH 4/6] Update youtube.py --- youtube_dl/extractor/youtube.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youtube_dl/extractor/youtube.py b/youtube_dl/extractor/youtube.py index 9b162ae71..db29bc03b 100644 --- a/youtube_dl/extractor/youtube.py +++ b/youtube_dl/extractor/youtube.py @@ -1563,7 +1563,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor): # that's why it should be the last option: el_order = ('info', 'embedded', 'vevo', '', 'detailpage') else: - el_order = ('info', 'embedded', 'detailpage', 'vevo', ''): + el_order = ('info', 'embedded', 'detailpage', 'vevo', '') for el in el_order: query = { 'video_id': video_id, From 5cada0cf77c5ee83f90895aea4956e8c8ca013a9 Mon Sep 17 00:00:00 2001 From: mrfunkycoda <34271361+mrfunkycoda@users.noreply.github.com> Date: Tue, 5 Dec 2017 15:28:15 +0200 Subject: [PATCH 5/6] Update __init__.py Adding youtube_prefer_get_video_info workaround option --- youtube_dl/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py index ba684a075..153905d9e 100644 --- a/youtube_dl/__init__.py +++ b/youtube_dl/__init__.py @@ -408,6 +408,7 @@ def _real_main(argv=None): 'call_home': opts.call_home, 'sleep_interval': opts.sleep_interval, 'max_sleep_interval': opts.max_sleep_interval, + 'youtube_prefer_get_video_info': opts.youtube_prefer_get_video_info, 'external_downloader': opts.external_downloader, 'list_thumbnails': opts.list_thumbnails, 'playlist_items': opts.playlist_items, From 4938153af5b6188dd4938312cbb26bac1ba7e12d Mon Sep 17 00:00:00 2001 From: mrfunkycoda <34271361+mrfunkycoda@users.noreply.github.com> Date: Tue, 5 Dec 2017 15:30:54 +0200 Subject: [PATCH 6/6] Update YoutubeDL.py Added comment about the youtube_prefer_get_video_info workaround option --- youtube_dl/YoutubeDL.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py index 68721e9ab..36990f3b4 100755 --- a/youtube_dl/YoutubeDL.py +++ b/youtube_dl/YoutubeDL.py @@ -272,6 +272,11 @@ class YoutubeDL(object): Must only be used along with sleep_interval. Actual sleep time will be a random float from range [sleep_interval; max_sleep_interval]. + youtube_prefer_get_video_info: By prefering a Youtube link extracted from + get_video_info instead of the video's webpage, Youtube + is likely to send a link with the + 'content-disposition: Attachment' header added (provided + you add the '&title=....' option to the link) listformats: Print an overview of available video formats and exit. list_thumbnails: Print a table of all thumbnails and exit. match_filter: A function that gets called with the info_dict of