From e6c2d9ad29bcc4eaa0eed03d3852588b6c7a10c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergey=20M=E2=80=A4?= Date: Fri, 10 Jul 2015 00:25:36 +0600 Subject: [PATCH] [extractor/generic:myvi] Add support for myvi embeds --- youtube_dl/extractor/generic.py | 6 ++++++ youtube_dl/extractor/myvi.py | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/youtube_dl/extractor/generic.py b/youtube_dl/extractor/generic.py index ea60d4a96..f8d6a8c76 100644 --- a/youtube_dl/extractor/generic.py +++ b/youtube_dl/extractor/generic.py @@ -37,6 +37,7 @@ from .tvc import TVCIE from .sportbox import SportBoxEmbedIE from .smotri import SmotriIE +from .myvi import MyviEmbedIE from .condenast import CondeNastIE from .udn import UDNEmbedIE from .senateisvp import SenateISVPIE @@ -1425,6 +1426,11 @@ def _playlist_from_matches(matches, getter=None, ie=None): if smotri_url: return self.url_result(smotri_url, 'Smotri') + # Look for embedded Myvi.ru player + myvi_url = MyviEmbedIE._extract_url(webpage) + if myvi_url: + return self.url_result(myvi_url) + # Look for embeded soundcloud player mobj = re.search( r'https?://(?:w\.)?soundcloud\.com/player[^"]+)"', diff --git a/youtube_dl/extractor/myvi.py b/youtube_dl/extractor/myvi.py index a14a5365b..896080c1e 100644 --- a/youtube_dl/extractor/myvi.py +++ b/youtube_dl/extractor/myvi.py @@ -1,6 +1,8 @@ # coding: utf-8 from __future__ import unicode_literals +import re + from .vimple import SprutoBaseIE @@ -38,6 +40,13 @@ class MyviEmbedIE(SprutoBaseIE): 'only_matching': True, }] + @classmethod + def _extract_url(cls, webpage): + mobj = re.search( + r']+?src=(["\'])(?P(?:https?:)?//myvi\.(?:ru/player|tv)/embed/html/[^"]+)\1', webpage) + if mobj: + return mobj.group('url') + def _real_extract(self, url): video_id = self._match_id(url)