[generic] Add support for xhamster embeds
authorSergey M․ <dstftw@gmail.com>
Sun, 21 Jun 2015 17:11:25 +0000 (23:11 +0600)
committerSergey M․ <dstftw@gmail.com>
Sun, 21 Jun 2015 17:11:25 +0000 (23:11 +0600)
youtube_dl/extractor/generic.py
youtube_dl/extractor/xhamster.py

index 07939b196daa6ef51d3971bbc4d40ea87343c1ca..e108bde668200e631080e27d4838c60a1bf48dfc 100644 (file)
@@ -43,6 +43,7 @@ from .senateisvp import SenateISVPIE
 from .bliptv import BlipTVIE
 from .svt import SVTIE
 from .pornhub import PornHubIE
+from .xhamster import XHamsterEmbedIE
 from .vimeo import VimeoIE
 from .dailymotion import DailymotionCloudIE
 
@@ -1331,6 +1332,11 @@ class GenericIE(InfoExtractor):
         if pornhub_url:
             return self.url_result(pornhub_url, 'PornHub')
 
+        # Look for embedded XHamster player
+        xhamster_urls = XHamsterEmbedIE._extract_urls(webpage)
+        if xhamster_urls:
+            return _playlist_from_matches(xhamster_urls, ie='XHamsterEmbed')
+
         # Look for embedded Tvigle player
         mobj = re.search(
             r'<iframe[^>]+?src=(["\'])(?P<url>(?:https?:)?//cloud\.tvigle\.ru/video/.+?)\1', webpage)
index ae3c5962b8061c5d3e136e3ff5120eb0f3aace2f..725e01ac3ab6c158c7ad4ee9e5dcf413181322c6 100644 (file)
@@ -149,6 +149,12 @@ class XHamsterEmbedIE(InfoExtractor):
         }
     }
 
+    @staticmethod
+    def _extract_urls(webpage):
+        return [url for _, url in re.findall(
+            r'<iframe[^>]+?src=(["\'])(?P<url>(?:https?:)?//(?:www\.)?xhamster\.com/xembed\.php\?video=\d+)\1',
+            webpage)]
+
     def _real_extract(self, url):
         video_id = self._match_id(url)