[downloader/http] Simplify
[youtube-dl] / youtube_dl / extractor / tvc.py
index 0055f9598ec12422da069b4c16036bad5c071ebe..3a4f393fcf6d79f3f42970db7aab853d5efedf84 100644 (file)
@@ -1,6 +1,8 @@
 # coding: utf-8
 from __future__ import unicode_literals
 
+import re
+
 from .common import InfoExtractor
 from ..utils import (
     clean_html,
@@ -8,7 +10,7 @@ from ..utils import (
 )
 
 
-class TVCEmbedIE(InfoExtractor):
+class TVCIE(InfoExtractor):
     _VALID_URL = r'http://(?:www\.)?tvc\.ru/video/iframe/id/(?P<id>\d+)'
     _TEST = {
         'url': 'http://www.tvc.ru/video/iframe/id/74622/isPlay/false/id_stat/channel/?acc_video_id=/channel/brand/id/17/show/episodes/episode_id/39702',
@@ -22,6 +24,13 @@ class TVCEmbedIE(InfoExtractor):
         },
     }
 
+    @classmethod
+    def _extract_url(cls, webpage):
+        mobj = re.search(
+            r'<iframe[^>]+?src=(["\'])(?P<url>(?:http:)?//(?:www\.)?tvc\.ru/video/iframe/id/[^"]+)\1', webpage)
+        if mobj:
+            return mobj.group('url')
+
     def _real_extract(self, url):
         video_id = self._match_id(url)
 
@@ -54,7 +63,7 @@ class TVCEmbedIE(InfoExtractor):
         }
 
 
-class TVCIE(InfoExtractor):
+class TVCArticleIE(InfoExtractor):
     _VALID_URL = r'http://(?:www\.)?tvc\.ru/(?!video/iframe/id/)(?P<id>[^?#]+)'
     _TESTS = [{
         'url': 'http://www.tvc.ru/channel/brand/id/29/show/episodes/episode_id/39702/',
@@ -92,7 +101,7 @@ class TVCIE(InfoExtractor):
         webpage = self._download_webpage(url, self._match_id(url))
         return {
             '_type': 'url_transparent',
-            'ie_key': 'TVCEmbed',
+            'ie_key': 'TVC',
             'url': self._og_search_video_url(webpage),
             'title': clean_html(self._og_search_title(webpage)),
             'description': clean_html(self._og_search_description(webpage)),