[extractor/mediaset] Fix embed extraction

Closes #4804
This commit is contained in:
pukkandan 2022-08-31 22:24:31 +05:30
parent f8c7ba9984
commit b86ca447ce
No known key found for this signature in database
GPG key ID: 7EEE9E1E817D0A39

View file

@ -172,31 +172,27 @@ class MediasetIE(ThePlatformBaseIE):
}] }]
def _extract_from_webpage(self, url, webpage): def _extract_from_webpage(self, url, webpage):
def _qs(url):
return parse_qs(url)
def _program_guid(qs): def _program_guid(qs):
return qs.get('programGuid', [None])[0] return qs.get('programGuid', [None])[0]
entries = []
for mobj in re.finditer( for mobj in re.finditer(
r'<iframe\b[^>]+\bsrc=(["\'])(?P<url>(?:https?:)?//(?:www\.)?video\.mediaset\.it/player/playerIFrame(?:Twitter)?\.shtml.*?)\1', r'<iframe\b[^>]+\bsrc=(["\'])(?P<url>(?:https?:)?//(?:www\.)?video\.mediaset\.it/player/playerIFrame(?:Twitter)?\.shtml.*?)\1',
webpage): webpage):
embed_url = mobj.group('url') embed_url = mobj.group('url')
embed_qs = _qs(embed_url) embed_qs = parse_qs(embed_url)
program_guid = _program_guid(embed_qs) program_guid = _program_guid(embed_qs)
if program_guid: if program_guid:
entries.append(embed_url) yield self.url_result(embed_url)
continue continue
video_id = embed_qs.get('id', [None])[0] video_id = embed_qs.get('id', [None])[0]
if not video_id: if not video_id:
continue continue
urlh = self._request_webpage(embed_url, video_id, note='Following embed URL redirect') urlh = self._request_webpage(embed_url, video_id, note='Following embed URL redirect')
embed_url = urlh.geturl() embed_url = urlh.geturl()
program_guid = _program_guid(_qs(embed_url)) program_guid = _program_guid(parse_qs(embed_url))
if program_guid: if program_guid:
entries.append(embed_url) yield self.url_result(embed_url)
return entries
def _parse_smil_formats(self, smil, smil_url, video_id, namespace=None, f4m_params=None, transform_rtmp_url=None): def _parse_smil_formats(self, smil, smil_url, video_id, namespace=None, f4m_params=None, transform_rtmp_url=None):
for video in smil.findall(self._xpath_ns('.//video', namespace)): for video in smil.findall(self._xpath_ns('.//video', namespace)):