Repository: yt-dlp/yt-dlp

Issue:
ParamountPlus: SAMPLE-AES encryption is not supported yet
### Checklist

- [X] I'm reporting a broken site
- [X] I've verified that I'm running yt-dlp version **2021.11.10.1**. ([update instructions](https://github.com/yt-dlp/yt-dlp#update))
- [X] I've checked that all provided URLs are alive and playable in a browser
- [X] I've checked that all URLs and arguments with special characters are [properly quoted or escaped](https://github.com/ytdl-org/youtube-dl#video-url-contains-an-ampersand-and-im-getting-some-strange-output-1-2839-or-v-is-not-recognized-as-an-internal-or-external-command)
- [X] I've searched the [bugtracker](https://github.com/yt-dlp/yt-dlp/issues?q=) for similar issues including closed ones. DO NOT post duplicates
- [X] I've read the [guidelines for opening an issue](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#opening-an-issue)
- [ ] I've read about [sharing account credentials](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#are-you-willing-to-share-account-details-if-needed) and I'm willing to share it if required

### Region

United States

### Description

Shows seem fine, however, movies can't be extracted anymore.

### Verbose log

```shell
Too long to fit here, https://paste.ee/r/RQgf1/0
```

ParamountPlus: SAMPLE-AES encryption is not supported yet
### Checklist

- [X] I'm reporting a broken site
- [X] I've verified that I'm running yt-dlp version **2021.11.10.1**. ([update instructions](https://github.com/yt-dlp/yt-dlp#update))
- [X] I've checked that all provided URLs are alive and playable in a browser
- [X] I've checked that all URLs and arguments with special characters are [properly quoted or escaped](https://github.com/ytdl-org/youtube-dl#video-url-contains-an-ampersand-and-im-getting-some-strange-output-1-2839-or-v-is-not-recognized-as-an-internal-or-external-command)
- [X] I've searched the [bugtracker](https://github.com/yt-dlp/yt-dlp/issues?q=) for similar issues including closed ones. DO NOT post duplicates
- [X] I've read the [guidelines for opening an issue](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#opening-an-issue)
- [ ] I've read about [sharing account credentials](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#are-you-willing-to-share-account-details-if-needed) and I'm willing to share it if required

### Region

United States

### Description

Shows seem fine, however, movies can't be extracted anymore.

### Verbose log

```shell
Too long to fit here, https://paste.ee/r/RQgf1/0
```



Discussion:
Check if any format is downloadable (`-f all`). If not, the movie is probably entirely DRM and there is nothing to be done other than adding a better error message
Yeah, still no luck. Same logs but for all formats.
FFmpeg did not support HLS SAMPLE-AES decryption until recently:

https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/ff958b38463f6ebd17471c40001287c71698f639

Notably the latest release of FFmpeg as of now (4.4.1) does not support it.
here's leading 6 lines of segment playlist:
```
$ head -n6 stream.m3u8 
#EXTM3U
#EXT-X-VERSION:6
## Generated with https://github.com/google/shaka-packager version 562040e000-release
#EXT-X-TARGETDURATION:7
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-KEY:METHOD=SAMPLE-AES,URI="skd://cbsi.live.ott.irdeto.com/streaming/getckc?CrmId=cbsi&AccountId=cbsi&ContentId=5EKDXPOzdVf9voUqW6oRuocyAEeJGbEc&KeyId=099a9041-b9a0-454b-9bc0-31a046048174",KEYFORMATVERSIONS="1",KEYFORMAT="com.apple.streamingkeydelivery"
```

Yeah, that's FairPlay DRM. Doesn't matter if ffmpeg supports SAMPLE-AES or not, as yt-dlp can't and won't support DRM streams. The only thing that can be done with those streams is to make it detect them as such and show a better error message.

Technically SAMPLE-AES could probably be clearkey too, but I've never seen that so far. Not that we need to hardcode it though, `skd://` and `com.apple.streamingkeydelivery` are telltale signs of FairPlay.
The reason this is not getting picked up as DRM is because the master playlist doesn't have `#EXT-X-KEY`, only the variant playlists do.
Check if any format is downloadable (`-f all`). If not, the movie is probably entirely DRM and there is nothing to be done other than adding a better error message
Yeah, still no luck. Same logs but for all formats.
FFmpeg did not support HLS SAMPLE-AES decryption until recently:

https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/ff958b38463f6ebd17471c40001287c71698f639

Notably the latest release of FFmpeg as of now (4.4.1) does not support it.
here's leading 6 lines of segment playlist:
```
$ head -n6 stream.m3u8 
#EXTM3U
#EXT-X-VERSION:6
## Generated with https://github.com/google/shaka-packager version 562040e000-release
#EXT-X-TARGETDURATION:7
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-KEY:METHOD=SAMPLE-AES,URI="skd://cbsi.live.ott.irdeto.com/streaming/getckc?CrmId=cbsi&AccountId=cbsi&ContentId=5EKDXPOzdVf9voUqW6oRuocyAEeJGbEc&KeyId=099a9041-b9a0-454b-9bc0-31a046048174",KEYFORMATVERSIONS="1",KEYFORMAT="com.apple.streamingkeydelivery"
```

Yeah, that's FairPlay DRM. Doesn't matter if ffmpeg supports SAMPLE-AES or not, as yt-dlp can't and won't support DRM streams. The only thing that can be done with those streams is to make it detect them as such and show a better error message.

Technically SAMPLE-AES could probably be clearkey too, but I've never seen that so far. Not that we need to hardcode it though, `skd://` and `com.apple.streamingkeydelivery` are telltale signs of FairPlay.
The reason this is not getting picked up as DRM is because the master playlist doesn't have `#EXT-X-KEY`, only the variant playlists do.

Resolving patch:
diff --git a/yt_dlp/downloader/hls.py b/yt_dlp/downloader/hls.py
--- a/yt_dlp/downloader/hls.py
+++ b/yt_dlp/downloader/hls.py
@@ -77,6 +77,15 @@ def real_download(self, filename, info_dict):
                 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
--- a/yt_dlp/extractor/common.py
+++ b/yt_dlp/extractor/common.py
@@ -2035,10 +2035,10 @@ def _parse_m3u8_formats_and_subtitles(
             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)


Test patch: