From ec8b22b1c120d0913d2d7c26418a2693a199b044 Mon Sep 17 00:00:00 2001 From: Simon Sawicki Date: Fri, 20 Dec 2024 21:53:33 +0100 Subject: [PATCH] Remove allow-u from extractors --- yt_dlp/extractor/globo.py | 2 +- yt_dlp/extractor/hotstar.py | 2 +- yt_dlp/extractor/ivi.py | 7 +++++-- yt_dlp/extractor/kaltura.py | 7 ++++++- yt_dlp/extractor/limelight.py | 11 ++++++++--- yt_dlp/extractor/ninecninemedia.py | 3 +-- yt_dlp/extractor/ninenow.py | 2 +- yt_dlp/extractor/nova.py | 3 +-- yt_dlp/extractor/npo.py | 5 ++--- yt_dlp/extractor/prosiebensat1.py | 2 +- yt_dlp/extractor/rai.py | 5 ++--- yt_dlp/extractor/redbee.py | 17 ++++++++++++----- yt_dlp/extractor/ruutu.py | 3 +-- yt_dlp/extractor/shahid.py | 2 +- yt_dlp/extractor/sonyliv.py | 2 +- yt_dlp/extractor/toggle.py | 3 +-- yt_dlp/extractor/toutv.py | 2 +- yt_dlp/extractor/vidio.py | 3 +-- yt_dlp/extractor/youtube.py | 2 +- 19 files changed, 48 insertions(+), 35 deletions(-) diff --git a/yt_dlp/extractor/globo.py b/yt_dlp/extractor/globo.py index d72296be6..f8308757a 100644 --- a/yt_dlp/extractor/globo.py +++ b/yt_dlp/extractor/globo.py @@ -87,7 +87,7 @@ class GloboIE(InfoExtractor): video = self._download_json( f'http://api.globovideos.com/videos/{video_id}/playlist', video_id)['videos'][0] - if not self.get_param('allow_unplayable_formats') and video.get('encrypted') is True: + if video.get('encrypted') is True: self.report_drm(video_id) title = video['title'] diff --git a/yt_dlp/extractor/hotstar.py b/yt_dlp/extractor/hotstar.py index e97740c90..57831aad7 100644 --- a/yt_dlp/extractor/hotstar.py +++ b/yt_dlp/extractor/hotstar.py @@ -236,7 +236,7 @@ class HotStarIE(HotStarBaseIE): self._call_api_v1( f'{video_type}/detail', video_id, fatal=False, query={'tas': 10000, 'contentId': video_id}), ('body', 'results', 'item', {dict})) or {} - if not self.get_param('allow_unplayable_formats') and video_data.get('drmProtected'): + if video_data.get('drmProtected'): self.report_drm(video_id) # See https://github.com/yt-dlp/yt-dlp/issues/396 diff --git a/yt_dlp/extractor/ivi.py b/yt_dlp/extractor/ivi.py index 57c276a67..171b1f796 100644 --- a/yt_dlp/extractor/ivi.py +++ b/yt_dlp/extractor/ivi.py @@ -140,13 +140,14 @@ class IviIE(InfoExtractor): quality = qualities(self._KNOWN_FORMATS) formats = [] + has_drm = False for f in result.get('files', []): f_url = f.get('url') content_format = f.get('content_format') if not f_url: continue - if (not self.get_param('allow_unplayable_formats') - and ('-MDRM-' in content_format or '-FPS-' in content_format)): + if '-MDRM-' in content_format or '-FPS-' in content_format: + has_drm = True continue formats.append({ 'url': f_url, @@ -154,6 +155,8 @@ class IviIE(InfoExtractor): 'quality': quality(content_format), 'filesize': int_or_none(f.get('size_in_bytes')), }) + if not formats and has_drm: + self.report_drm(video_id) compilation = result.get('compilation') episode = title if compilation else None diff --git a/yt_dlp/extractor/kaltura.py b/yt_dlp/extractor/kaltura.py index 6d51e32f6..cd2832466 100644 --- a/yt_dlp/extractor/kaltura.py +++ b/yt_dlp/extractor/kaltura.py @@ -464,6 +464,7 @@ class KalturaIE(InfoExtractor): formats = [] subtitles = {} + has_drm = False for f in flavor_assets: # Continue if asset is not ready if f.get('status') != 2: @@ -473,7 +474,8 @@ class KalturaIE(InfoExtractor): if f.get('fileExt') == 'chun': continue # DRM-protected video, cannot be decrypted - if not self.get_param('allow_unplayable_formats') and f.get('fileExt') == 'wvm': + if f.get('fileExt') == 'wvm': + has_drm = True continue if not f.get('fileExt'): # QT indicates QuickTime; some videos have broken fileExt @@ -513,6 +515,9 @@ class KalturaIE(InfoExtractor): formats.extend(fmts) self._merge_subtitles(subs, target=subtitles) + if not formats and has_drm: + self.report_drm(entry_id) + if captions: for caption in captions.get('objects', []): # Continue if caption is not ready diff --git a/yt_dlp/extractor/limelight.py b/yt_dlp/extractor/limelight.py index 763a01448..522e0409f 100644 --- a/yt_dlp/extractor/limelight.py +++ b/yt_dlp/extractor/limelight.py @@ -91,11 +91,13 @@ class LimelightBaseIE(InfoExtractor): formats = [] urls = [] + has_drm = False for stream in pc_item.get('streams', []): stream_url = stream.get('url') if not stream_url or stream_url in urls: continue - if not self.get_param('allow_unplayable_formats') and stream.get('drmProtected'): + if stream.get('drmProtected'): + has_drm = True continue urls.append(stream_url) ext = determine_ext(stream_url) @@ -159,8 +161,8 @@ class LimelightBaseIE(InfoExtractor): format_id = mobile_url.get('targetMediaPlatform') if not media_url or media_url in urls: continue - if (format_id in ('Widevine', 'SmoothStreaming') - and not self.get_param('allow_unplayable_formats', False)): + if format_id in ('Widevine', 'SmoothStreaming'): + has_drm = True continue urls.append(media_url) ext = determine_ext(media_url) @@ -179,6 +181,9 @@ class LimelightBaseIE(InfoExtractor): 'ext': ext, }) + if not formats and has_drm: + self.report_drm(video_id) + subtitles = {} for flag in mobile_item.get('flags'): if flag == 'ClosedCaptions': diff --git a/yt_dlp/extractor/ninecninemedia.py b/yt_dlp/extractor/ninecninemedia.py index 93e28624b..cc2da0875 100644 --- a/yt_dlp/extractor/ninecninemedia.py +++ b/yt_dlp/extractor/ninecninemedia.py @@ -29,8 +29,7 @@ class NineCNineMediaIE(InfoExtractor): '$include': '[HasClosedCaptions]', }) - if (not self.get_param('allow_unplayable_formats') - and try_get(content_package, lambda x: x['Constraints']['Security']['Type'])): + if try_get(content_package, lambda x: x['Constraints']['Security']['Type']): self.report_drm(content_id) manifest_base_url = content_package_url + 'manifest.' diff --git a/yt_dlp/extractor/ninenow.py b/yt_dlp/extractor/ninenow.py index f17531e62..77e8e4d71 100644 --- a/yt_dlp/extractor/ninenow.py +++ b/yt_dlp/extractor/ninenow.py @@ -85,7 +85,7 @@ class NineNowIE(InfoExtractor): else: raise ExtractorError('Unable to find video data') - if not self.get_param('allow_unplayable_formats') and try_get(common_data, lambda x: x['episode']['video']['drm'], bool): + if try_get(common_data, lambda x: x['episode']['video']['drm'], bool): self.report_drm(display_id) brightcove_id = try_get( common_data, lambda x: x['episode']['video']['brightcoveId'], str) or 'ref:{}'.format(common_data['episode']['video']['referenceId']) diff --git a/yt_dlp/extractor/nova.py b/yt_dlp/extractor/nova.py index e7b69e370..544609ec3 100644 --- a/yt_dlp/extractor/nova.py +++ b/yt_dlp/extractor/nova.py @@ -65,8 +65,7 @@ class NovaEmbedIE(InfoExtractor): for format_dict in format_list: if not isinstance(format_dict, dict): continue - if (not self.get_param('allow_unplayable_formats') - and traverse_obj(format_dict, ('drm', 'keySystem'))): + if traverse_obj(format_dict, ('drm', 'keySystem')): has_drm = True continue format_url = url_or_none(format_dict.get('src')) diff --git a/yt_dlp/extractor/npo.py b/yt_dlp/extractor/npo.py index 178fd98bf..765256bd1 100644 --- a/yt_dlp/extractor/npo.py +++ b/yt_dlp/extractor/npo.py @@ -275,9 +275,8 @@ class NPOIE(InfoExtractor): 'url': stream_url, }) - if not formats: - if not self.get_param('allow_unplayable_formats') and drm: - self.report_drm(video_id) + if not formats and drm: + self.report_drm(video_id) info = { 'id': video_id, diff --git a/yt_dlp/extractor/prosiebensat1.py b/yt_dlp/extractor/prosiebensat1.py index e8a471205..a651a3892 100644 --- a/yt_dlp/extractor/prosiebensat1.py +++ b/yt_dlp/extractor/prosiebensat1.py @@ -31,7 +31,7 @@ class ProSiebenSat1BaseIE(InfoExtractor): 'ids': clip_id, })[0] - if not self.get_param('allow_unplayable_formats') and video.get('is_protected') is True: + if video.get('is_protected') is True: self.report_drm(clip_id) formats = [] diff --git a/yt_dlp/extractor/rai.py b/yt_dlp/extractor/rai.py index efb47affc..926a09706 100644 --- a/yt_dlp/extractor/rai.py +++ b/yt_dlp/extractor/rai.py @@ -340,9 +340,8 @@ class RaiPlayIE(RaiBaseIE): media = self._download_json( f'{base}.json', video_id, 'Downloading video JSON') - if not self.get_param('allow_unplayable_formats'): - if traverse_obj(media, (('program_info', None), 'rights_management', 'rights', 'drm')): - self.report_drm(video_id) + if traverse_obj(media, (('program_info', None), 'rights_management', 'rights', 'drm')): + self.report_drm(video_id) video = media['video'] relinker_info = self._extract_relinker_info(video['content_url'], video_id) diff --git a/yt_dlp/extractor/redbee.py b/yt_dlp/extractor/redbee.py index d43bb0bab..dbc6f1e45 100644 --- a/yt_dlp/extractor/redbee.py +++ b/yt_dlp/extractor/redbee.py @@ -337,12 +337,16 @@ class RTBFIE(RedBeeBaseIE): 'height': height, }) + has_drm = False mpd_url = None if data.get('isLive') else data.get('urlDash') - if mpd_url and (self.get_param('allow_unplayable_formats') or not data.get('drm')): - fmts, subs = self._extract_mpd_formats_and_subtitles( - mpd_url, media_id, mpd_id='dash', fatal=False) - formats.extend(fmts) - self._merge_subtitles(subs, target=subtitles) + if mpd_url: + if data.get('drm'): + has_drm = True + else: + fmts, subs = self._extract_mpd_formats_and_subtitles( + mpd_url, media_id, mpd_id='dash', fatal=False) + formats.extend(fmts) + self._merge_subtitles(subs, target=subtitles) audio_url = data.get('urlAudio') if audio_url: @@ -365,6 +369,9 @@ class RTBFIE(RedBeeBaseIE): formats.extend(fmts) self._merge_subtitles(subs, target=subtitles) + if not formats and has_drm: + self.report_drm(media_id) + return { 'id': media_id, 'formats': formats, diff --git a/yt_dlp/extractor/ruutu.py b/yt_dlp/extractor/ruutu.py index 2dddb39f9..b35c46a28 100644 --- a/yt_dlp/extractor/ruutu.py +++ b/yt_dlp/extractor/ruutu.py @@ -237,8 +237,7 @@ class RuutuIE(InfoExtractor): return value or None if not formats: - if (not self.get_param('allow_unplayable_formats') - and xpath_text(video_xml, './Clip/DRM', default=None)): + if xpath_text(video_xml, './Clip/DRM', default=None): self.report_drm(video_id) ns_st_cds = pv('ns_st_cds') if ns_st_cds != 'free': diff --git a/yt_dlp/extractor/shahid.py b/yt_dlp/extractor/shahid.py index f0a3b6b7d..cc3afec9f 100644 --- a/yt_dlp/extractor/shahid.py +++ b/yt_dlp/extractor/shahid.py @@ -111,7 +111,7 @@ class ShahidIE(ShahidBaseIE): playout = self._call_api( 'playout/new/url/' + video_id, video_id)['playout'] - if not self.get_param('allow_unplayable_formats') and playout.get('drm'): + if playout.get('drm'): self.report_drm(video_id) formats = self._extract_m3u8_formats(re.sub( diff --git a/yt_dlp/extractor/sonyliv.py b/yt_dlp/extractor/sonyliv.py index 0cd914cbb..e5fe920b6 100644 --- a/yt_dlp/extractor/sonyliv.py +++ b/yt_dlp/extractor/sonyliv.py @@ -142,7 +142,7 @@ class SonyLIVIE(InfoExtractor): video_id = self._match_id(url) content = self._call_api( '1.5', 'IN/CONTENT/VIDEOURL/VOD/' + video_id, video_id) - if not self.get_param('allow_unplayable_formats') and content.get('isEncrypted'): + if content.get('isEncrypted'): self.report_drm(video_id) dash_url = content['videoURL'] headers = { diff --git a/yt_dlp/extractor/toggle.py b/yt_dlp/extractor/toggle.py index fbef7cc0f..793cfd138 100644 --- a/yt_dlp/extractor/toggle.py +++ b/yt_dlp/extractor/toggle.py @@ -126,8 +126,7 @@ class ToggleIE(InfoExtractor): }) if not formats: for meta in (info.get('Metas') or []): - if (not self.get_param('allow_unplayable_formats') - and meta.get('Key') == 'Encryption' and meta.get('Value') == '1'): + if meta.get('Key') == 'Encryption' and meta.get('Value') == '1': self.report_drm(video_id) # Most likely because geo-blocked if no formats and no DRM diff --git a/yt_dlp/extractor/toutv.py b/yt_dlp/extractor/toutv.py index cbd2c9c26..6350a363f 100644 --- a/yt_dlp/extractor/toutv.py +++ b/yt_dlp/extractor/toutv.py @@ -68,7 +68,7 @@ class TouTvIE(RadioCanadaIE): # XXX: Do not subclass from concrete IE }) # IsDrm does not necessarily mean the video is DRM protected (see # https://github.com/ytdl-org/youtube-dl/issues/13994). - if not self.get_param('allow_unplayable_formats') and metadata.get('IsDrm'): + if metadata.get('IsDrm'): self.report_warning('This video is probably DRM protected.', path) video_id = metadata['IdMedia'] details = metadata['Details'] diff --git a/yt_dlp/extractor/vidio.py b/yt_dlp/extractor/vidio.py index 955a11647..8ad1b7da1 100644 --- a/yt_dlp/extractor/vidio.py +++ b/yt_dlp/extractor/vidio.py @@ -261,8 +261,7 @@ class VidioLiveIE(VidioBaseIE): formats = [] if stream_meta.get('is_drm'): - if not self.get_param('allow_unplayable_formats'): - self.report_drm(video_id) + self.report_drm(video_id) if stream_meta.get('is_premium'): sources = self._download_json( f'https://www.vidio.com/interactions_stream.json?video_id={video_id}&type=livestreamings', diff --git a/yt_dlp/extractor/youtube.py b/yt_dlp/extractor/youtube.py index 0d3963116..bbd18fad9 100644 --- a/yt_dlp/extractor/youtube.py +++ b/yt_dlp/extractor/youtube.py @@ -4511,7 +4511,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor): self.write_debug(f'{video_id}: Video is in Post-Live Manifestless mode') if not formats: - if not self.get_param('allow_unplayable_formats') and traverse_obj(streaming_data, (..., 'licenseInfos')): + if traverse_obj(streaming_data, (..., 'licenseInfos')): self.report_drm(video_id) pemr = get_first( playability_statuses,