From 3635a2694b909a56b8376c8d468bfe1c606a6044 Mon Sep 17 00:00:00 2001 From: nixxo Date: Mon, 4 Jan 2021 15:10:13 +0100 Subject: [PATCH 1/7] [rai] extract ContentItem from iframes (fixes #12652) --- youtube_dl/extractor/rai.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/youtube_dl/extractor/rai.py b/youtube_dl/extractor/rai.py index ecb628f1494..e5c6b18e3d2 100644 --- a/youtube_dl/extractor/rai.py +++ b/youtube_dl/extractor/rai.py @@ -326,6 +326,19 @@ class RaiIE(RaiBaseIE): 'params': { 'skip_download': True, }, + }, { + # ContentItem in iframe - fixes #12652 + 'url': 'http://www.presadiretta.rai.it/dl/portali/site/puntata/ContentItem-3ed19d13-26c2-46ff-a551-b10828262f1b.html', + 'info_dict': { + 'id': '1ad6dc64-444a-42a4-9bea-e5419ad2f5fd', + 'ext': 'mp4', + 'title': 'Partiti acchiappavoti - Presa diretta del 13/09/2015', + 'description': 'md5:d291b03407ec505f95f27970c0b025f4', + 'upload_date': '20150913', + }, + 'params': { + 'skip_download': True, + }, }, { # Direct MMS URL 'url': 'http://www.rai.it/dl/RaiTV/programmi/media/ContentItem-b63a4089-ac28-48cf-bca5-9f5b5bc46df5.html', @@ -393,6 +406,7 @@ def _real_extract(self, url): content_item_url = self._html_search_meta( ('og:url', 'og:video', 'og:video:secure_url', 'twitter:url', 'twitter:player', 'jsonlink'), webpage, default=None) + if content_item_url: content_item_id = self._search_regex( r'ContentItem-(%s)' % self._UUID_RE, content_item_url, @@ -410,6 +424,11 @@ def _real_extract(self, url): ''' % self._UUID_RE, webpage, 'content item id', default=None, group='id') + if not content_item_id: + content_item_id = self._search_regex( + r'/ContentItem-(?P%s)\.html\?iframe' % self._UUID_RE, + webpage, 'content item id', default=None, group='id') + content_item_ids = set() if content_item_id: content_item_ids.add(content_item_id) From b2695b11d01fcdd1408bb7fc7f48a6d5b1edb513 Mon Sep 17 00:00:00 2001 From: nixxo Date: Mon, 4 Jan 2021 15:11:47 +0100 Subject: [PATCH 2/7] [rai] added checks for drm protected content --- youtube_dl/extractor/rai.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/youtube_dl/extractor/rai.py b/youtube_dl/extractor/rai.py index e5c6b18e3d2..07187714be0 100644 --- a/youtube_dl/extractor/rai.py +++ b/youtube_dl/extractor/rai.py @@ -145,14 +145,31 @@ class RaiPlayIE(RaiBaseIE): }, { 'url': 'http://www.raiplay.it/video/2016/11/gazebotraindesi-efebe701-969c-4593-92f3-285f0d1ce750.html?', 'only_matching': True, + }, { + # DRM protected + 'url': 'https://www.raiplay.it/video/2020/09/Lo-straordinario-mondo-di-Zoey-S1E1-Lo-straordinario-potere-di-Zoey-ed493918-1d32-44b7-8454-862e473d00ff.html', + 'only_matching': True, }] + def _check_drm(self, obj): + if (obj.get('rights_management') and ( + obj['rights_management']['rights'].get('drm'))): + return True + + if (obj.get('program_info')): + return self._check_drm(obj['program_info']) + + return False + def _real_extract(self, url): base, video_id = re.match(self._VALID_URL, url).groups() media = self._download_json( base + '.json', video_id, 'Downloading video JSON') + if self._check_drm(media): + raise ExtractorError('This video is DRM protected.', expected=True) + title = media['name'] video = media['video'] From 29a7b6c164b81c1ca5540664f60164cbd90492b4 Mon Sep 17 00:00:00 2001 From: nixxo Date: Mon, 4 Jan 2021 15:14:59 +0100 Subject: [PATCH 3/7] [rai] cosmetic --- youtube_dl/extractor/rai.py | 1 - 1 file changed, 1 deletion(-) diff --git a/youtube_dl/extractor/rai.py b/youtube_dl/extractor/rai.py index 07187714be0..26799655287 100644 --- a/youtube_dl/extractor/rai.py +++ b/youtube_dl/extractor/rai.py @@ -423,7 +423,6 @@ def _real_extract(self, url): content_item_url = self._html_search_meta( ('og:url', 'og:video', 'og:video:secure_url', 'twitter:url', 'twitter:player', 'jsonlink'), webpage, default=None) - if content_item_url: content_item_id = self._search_regex( r'ContentItem-(%s)' % self._UUID_RE, content_item_url, From 440dd607ac11e59e83680bcd60fd070b8c1a042a Mon Sep 17 00:00:00 2001 From: nixxo Date: Mon, 4 Jan 2021 16:50:29 +0100 Subject: [PATCH 4/7] [rai] fix coding conventions --- youtube_dl/extractor/rai.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/youtube_dl/extractor/rai.py b/youtube_dl/extractor/rai.py index 26799655287..1ca5395d762 100644 --- a/youtube_dl/extractor/rai.py +++ b/youtube_dl/extractor/rai.py @@ -152,11 +152,10 @@ class RaiPlayIE(RaiBaseIE): }] def _check_drm(self, obj): - if (obj.get('rights_management') and ( - obj['rights_management']['rights'].get('drm'))): + if try_get(obj, lambda x: x['rights_management']['rights']['drm'], dict): return True - if (obj.get('program_info')): + if obj.get('program_info'): return self._check_drm(obj['program_info']) return False From c63d35db93df90aac4b4df5f022062846fd4a544 Mon Sep 17 00:00:00 2001 From: nixxo Date: Tue, 5 Jan 2021 09:22:36 +0100 Subject: [PATCH 5/7] [rai] fix drm check --- youtube_dl/extractor/rai.py | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/youtube_dl/extractor/rai.py b/youtube_dl/extractor/rai.py index 1ca5395d762..caf04456fc4 100644 --- a/youtube_dl/extractor/rai.py +++ b/youtube_dl/extractor/rai.py @@ -151,22 +151,13 @@ class RaiPlayIE(RaiBaseIE): 'only_matching': True, }] - def _check_drm(self, obj): - if try_get(obj, lambda x: x['rights_management']['rights']['drm'], dict): - return True - - if obj.get('program_info'): - return self._check_drm(obj['program_info']) - - return False - def _real_extract(self, url): base, video_id = re.match(self._VALID_URL, url).groups() media = self._download_json( base + '.json', video_id, 'Downloading video JSON') - if self._check_drm(media): + if try_get(media, lambda x: x['rights_management']['rights']['drm'], dict) or try_get(media, lambda x: x['program_info']['rights_management']['rights']['drm'], dict): raise ExtractorError('This video is DRM protected.', expected=True) title = media['name'] @@ -342,19 +333,6 @@ class RaiIE(RaiBaseIE): 'params': { 'skip_download': True, }, - }, { - # ContentItem in iframe - fixes #12652 - 'url': 'http://www.presadiretta.rai.it/dl/portali/site/puntata/ContentItem-3ed19d13-26c2-46ff-a551-b10828262f1b.html', - 'info_dict': { - 'id': '1ad6dc64-444a-42a4-9bea-e5419ad2f5fd', - 'ext': 'mp4', - 'title': 'Partiti acchiappavoti - Presa diretta del 13/09/2015', - 'description': 'md5:d291b03407ec505f95f27970c0b025f4', - 'upload_date': '20150913', - }, - 'params': { - 'skip_download': True, - }, }, { # Direct MMS URL 'url': 'http://www.rai.it/dl/RaiTV/programmi/media/ContentItem-b63a4089-ac28-48cf-bca5-9f5b5bc46df5.html', @@ -439,11 +417,6 @@ def _real_extract(self, url): ''' % self._UUID_RE, webpage, 'content item id', default=None, group='id') - if not content_item_id: - content_item_id = self._search_regex( - r'/ContentItem-(?P%s)\.html\?iframe' % self._UUID_RE, - webpage, 'content item id', default=None, group='id') - content_item_ids = set() if content_item_id: content_item_ids.add(content_item_id) From dc1ca796738708f12acbf6304aaec43e4c3daa89 Mon Sep 17 00:00:00 2001 From: nixxo Date: Sun, 7 Mar 2021 08:31:59 +0100 Subject: [PATCH 6/7] [rai] Check for DRM improvements reviewed by @pukkandan (https://github.com/yt-dlp/yt-dlp/pull/150) Authored by: nixxo --- youtube_dl/extractor/rai.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/youtube_dl/extractor/rai.py b/youtube_dl/extractor/rai.py index 89bb5e33b0e..ecdbfea6a5d 100644 --- a/youtube_dl/extractor/rai.py +++ b/youtube_dl/extractor/rai.py @@ -170,11 +170,15 @@ def _real_extract(self, url): media = self._download_json( base + '.json', video_id, 'Downloading video JSON') - if try_get(media, lambda x: x['rights_management']['rights']['drm'], dict) or try_get(media, lambda x: x['program_info']['rights_management']['rights']['drm'], dict): - raise ExtractorError('This video is DRM protected.', expected=True) + if not self.params.get('allow_unplayable_formats'): + if try_get( + media, + (lambda x: x['rights_management']['rights']['drm'], + lambda x: x['program_info']['rights_management']['rights']['drm']), + dict): + raise ExtractorError('This video is DRM protected.', expected=True) title = media['name'] - video = media['video'] relinker_info = self._extract_relinker_info(video['content_url'], video_id) From 314b011391ccc043a311a51cd46af13cc4656568 Mon Sep 17 00:00:00 2001 From: nixxo Date: Sun, 7 Mar 2021 08:31:59 +0100 Subject: [PATCH 7/7] [rai] Check for DRM improvements reviewed by @pukkandan (https://github.com/yt-dlp/yt-dlp/pull/150) --- youtube_dl/extractor/rai.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/youtube_dl/extractor/rai.py b/youtube_dl/extractor/rai.py index 89bb5e33b0e..2c25b59bc9e 100644 --- a/youtube_dl/extractor/rai.py +++ b/youtube_dl/extractor/rai.py @@ -170,11 +170,14 @@ def _real_extract(self, url): media = self._download_json( base + '.json', video_id, 'Downloading video JSON') - if try_get(media, lambda x: x['rights_management']['rights']['drm'], dict) or try_get(media, lambda x: x['program_info']['rights_management']['rights']['drm'], dict): + if try_get( + media, + (lambda x: x['rights_management']['rights']['drm'], + lambda x: x['program_info']['rights_management']['rights']['drm']), + dict): raise ExtractorError('This video is DRM protected.', expected=True) title = media['name'] - video = media['video'] relinker_info = self._extract_relinker_info(video['content_url'], video_id)