Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rai] drm check and fix #27657

Closed
wants to merge 9 commits into from
34 changes: 34 additions & 0 deletions youtube_dl/extractor/rai.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,30 @@ 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 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
nixxo marked this conversation as resolved.
Show resolved Hide resolved

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']
Expand Down Expand Up @@ -326,6 +342,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',
Expand Down Expand Up @@ -410,6 +439,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<id>%s)\.html\?iframe' % self._UUID_RE,
webpage, 'content item id', default=None, group='id')

nixxo marked this conversation as resolved.
Show resolved Hide resolved
content_item_ids = set()
if content_item_id:
content_item_ids.add(content_item_id)
Expand Down