mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-09-06 10:59:36 +02:00
[npo] Improve DRM detection
This commit is contained in:
parent
b8526c78f9
commit
8cb10807ed
@ -181,10 +181,7 @@ def suitable(cls, url):
|
||||
|
||||
def _real_extract(self, url):
|
||||
video_id = self._match_id(url)
|
||||
try:
|
||||
return self._get_info(url, video_id)
|
||||
except ExtractorError:
|
||||
return self._get_old_info(video_id)
|
||||
return self._get_info(url, video_id) or self._get_old_info(video_id)
|
||||
|
||||
def _get_info(self, url, video_id):
|
||||
token = self._download_json(
|
||||
@ -206,6 +203,7 @@ def _get_info(self, url, video_id):
|
||||
|
||||
player_token = player['token']
|
||||
|
||||
drm = False
|
||||
format_urls = set()
|
||||
formats = []
|
||||
for profile in ('hls', 'dash-widevine', 'dash-playready', 'smooth'):
|
||||
@ -227,7 +225,8 @@ def _get_info(self, url, video_id):
|
||||
if not stream_url or stream_url in format_urls:
|
||||
continue
|
||||
format_urls.add(stream_url)
|
||||
if stream.get('protection') is not None:
|
||||
if stream.get('protection') is not None or stream.get('keySystemOptions') is not None:
|
||||
drm = True
|
||||
continue
|
||||
stream_type = stream.get('type')
|
||||
stream_ext = determine_ext(stream_url)
|
||||
@ -246,6 +245,11 @@ def _get_info(self, url, video_id):
|
||||
'url': stream_url,
|
||||
})
|
||||
|
||||
if not formats:
|
||||
if drm:
|
||||
raise ExtractorError('This video is DRM protected.', expected=True)
|
||||
return
|
||||
|
||||
self._sort_formats(formats)
|
||||
|
||||
info = {
|
||||
|
Loading…
Reference in New Issue
Block a user