aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornyuszika7h <nyuszika7h@gmail.com>2021-11-19 02:49:51 +0100
committerGitHub <noreply@github.com>2021-11-19 07:19:51 +0530
commit6b993ca765753e0b04d65ec70cf787a2e9f94639 (patch)
tree5cc8d9576877890a7081e585d3cb2d3a93a2de3e
parentdd2a987d3f412dc61422ad13cf7b60920be8af6e (diff)
downloadhypervideo-pre-6b993ca765753e0b04d65ec70cf787a2e9f94639.tar.lz
hypervideo-pre-6b993ca765753e0b04d65ec70cf787a2e9f94639.tar.xz
hypervideo-pre-6b993ca765753e0b04d65ec70cf787a2e9f94639.zip
[hls] Better FairPlay DRM detection (#1661)
Authored by: nyuszika7h
-rw-r--r--yt_dlp/downloader/hls.py9
-rw-r--r--yt_dlp/extractor/common.py8
2 files changed, 13 insertions, 4 deletions
diff --git a/yt_dlp/downloader/hls.py b/yt_dlp/downloader/hls.py
index 61312c5ba..e932fd6ae 100644
--- a/yt_dlp/downloader/hls.py
+++ b/yt_dlp/downloader/hls.py
@@ -77,6 +77,15 @@ class HlsFD(FragmentFD):
message = ('The stream has AES-128 encryption and neither ffmpeg nor pycryptodomex are available; '
'Decryption will be performed natively, but will be extremely slow')
if not can_download:
+ has_drm = re.search('|'.join([
+ r'#EXT-X-FAXS-CM:', # Adobe Flash Access
+ r'#EXT-X-(?:SESSION-)?KEY:.*?URI="skd://', # Apple FairPlay
+ ]), s)
+ if has_drm and not self.params.get('allow_unplayable_formats'):
+ self.report_error(
+ 'This video is DRM protected; Try selecting another format with --format or '
+ 'add --check-formats to automatically fallback to the next best format')
+ return False
message = message or 'Unsupported features have been detected'
fd = FFmpegFD(self.ydl, self.params)
self.report_warning(f'{message}; extraction will be delegated to {fd.get_basename()}')
diff --git a/yt_dlp/extractor/common.py b/yt_dlp/extractor/common.py
index 6f0650296..a47364d07 100644
--- a/yt_dlp/extractor/common.py
+++ b/yt_dlp/extractor/common.py
@@ -2035,10 +2035,10 @@ class InfoExtractor(object):
video_id=None):
formats, subtitles = [], {}
- if '#EXT-X-FAXS-CM:' in m3u8_doc: # Adobe Flash Access
- return formats, subtitles
-
- has_drm = re.search(r'#EXT-X-(?:SESSION-)?KEY:.*?URI="skd://', m3u8_doc)
+ has_drm = re.search('|'.join([
+ r'#EXT-X-FAXS-CM:', # Adobe Flash Access
+ r'#EXT-X-(?:SESSION-)?KEY:.*?URI="skd://', # Apple FairPlay
+ ]), m3u8_doc)
def format_url(url):
return url if re.match(r'^https?://', url) else compat_urlparse.urljoin(m3u8_url, url)