aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRemita Amine <remitamine@gmail.com>2019-05-25 23:14:47 +0100
committerRemita Amine <remitamine@gmail.com>2019-05-25 23:15:59 +0100
commit0d297518904f8537e8103052d19f0940a272413d (patch)
tree891c27db72cc5f535caefa00654f5e43c4fa2b6e
parent25b83c2a0e29c75372f0ce26d2b4ecf493e8b28c (diff)
downloadyoutube-dl-0d297518904f8537e8103052d19f0940a272413d.tar.xz
[youtube] improve DRM protected videos detection(#1774)
-rw-r--r--youtube_dl/extractor/youtube.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/youtube_dl/extractor/youtube.py b/youtube_dl/extractor/youtube.py
index 06005f8d2..5f1957a59 100644
--- a/youtube_dl/extractor/youtube.py
+++ b/youtube_dl/extractor/youtube.py
@@ -1789,9 +1789,6 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
raise ExtractorError(
'YouTube said: %s' % unavailable_message, expected=True, video_id=video_id)
- if video_info.get('license_info'):
- raise ExtractorError('This video is DRM protected.', expected=True)
-
video_details = try_get(
player_response, lambda x: x['videoDetails'], dict) or {}
@@ -1927,7 +1924,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
formats = []
for url_data_str in encoded_url_map.split(','):
url_data = compat_parse_qs(url_data_str)
- if 'itag' not in url_data or 'url' not in url_data:
+ if 'itag' not in url_data or 'url' not in url_data or url_data.get('drm_families'):
continue
stream_type = int_or_none(try_get(url_data, lambda x: x['stream_type'][0]))
# Unsupported FORMAT_STREAM_TYPE_OTF
@@ -2323,6 +2320,9 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
'"token" parameter not in video info for unknown reason',
video_id=video_id)
+ if not formats and (video_info.get('license_info') or try_get(player_response, lambda x: x['streamingData']['licenseInfos'])):
+ raise ExtractorError('This video is DRM protected.', expected=True)
+
self._sort_formats(formats)
self.mark_watched(video_id, video_info, player_response)