]> gitweb @ CieloNegro.org - youtube-dl.git/commitdiff
[extractor/generic] Add support for mediaset embeds
authorSergey M․ <dstftw@gmail.com>
Sat, 13 May 2017 23:29:16 +0000 (06:29 +0700)
committerSergey M․ <dstftw@gmail.com>
Sat, 13 May 2017 23:29:16 +0000 (06:29 +0700)
youtube_dl/extractor/generic.py
youtube_dl/extractor/mediaset.py

index dde65fa96c8fb1c5204e3209d431c5e8ff493347..32f38c401f87413491576b341017c5ec0d874c5c 100644 (file)
@@ -89,6 +89,7 @@ from .limelight import LimelightBaseIE
 from .anvato import AnvatoIE
 from .washingtonpost import WashingtonPostIE
 from .wistia import WistiaIE
+from .mediaset import MediasetIE
 
 
 class GenericIE(InfoExtractor):
@@ -2648,6 +2649,12 @@ class GenericIE(InfoExtractor):
             return self.playlist_from_matches(
                 wapo_urls, video_id, video_title, ie=WashingtonPostIE.ie_key())
 
+        # Look for Mediaset embeds
+        mediaset_urls = MediasetIE._extract_urls(webpage)
+        if mediaset_urls:
+            return self.playlist_from_matches(
+                mediaset_urls, video_id, video_title, ie=MediasetIE.ie_key())
+
         # Looking for http://schema.org/VideoObject
         json_ld = self._search_json_ld(
             webpage, video_id, default={}, expected_type='VideoObject')
index 3ebc7f2e11d153a440359bbbd35a8c3665902e20..9a0e41663d378cebfbd1722eae88442bbe40aa6b 100644 (file)
@@ -59,6 +59,14 @@ class MediasetIE(InfoExtractor):
         'only_matching': True,
     }]
 
+    @staticmethod
+    def _extract_urls(webpage):
+        return [
+            mobj.group('url')
+            for mobj in re.finditer(
+                r'<iframe\b[^>]+\bsrc=(["\'])(?P<url>https?://(?:www\.)?video\.mediaset\.it/player/playerIFrame(?:Twitter)?\.shtml\?.*?\bid=\d+.*?)\1',
+                webpage)]
+
     def _real_extract(self, url):
         video_id = self._match_id(url)