[vice] Make test only matching
[youtube-dl] / youtube_dl / extractor / vice.py
1 from __future__ import unicode_literals
2 import re
3
4 from .common import InfoExtractor
5 from .ooyala import OoyalaIE
6 from ..utils import ExtractorError
7
8
9 class ViceIE(InfoExtractor):
10     _VALID_URL = r'https?://(?:.+?\.)?vice\.com/.*?/(?P<name>.+)'
11
12     _TESTS = [
13         {
14             'url': 'http://www.vice.com/Fringes/cowboy-capitalists-part-1',
15             'info_dict': {
16                 'id': '43cW1mYzpia9IlestBjVpd23Yu3afAfp',
17                 'ext': 'mp4',
18                 'title': 'VICE_COWBOYCAPITALISTS_PART01_v1_VICE_WM_1080p.mov',
19             },
20             'params': {
21                 # Requires ffmpeg (m3u8 manifest)
22                 'skip_download': True,
23             },
24         }, {
25             'url': 'https://news.vice.com/video/experimenting-on-animals-inside-the-monkey-lab',
26             'only_matching': True,
27         }
28     ]
29
30     def _real_extract(self, url):
31         mobj = re.match(self._VALID_URL, url)
32         name = mobj.group('name')
33         webpage = self._download_webpage(url, name)
34         try:
35             embed_code = self._search_regex(
36                 r'embedCode=([^&\'"]+)', webpage,
37                 'ooyala embed code')
38             ooyala_url = OoyalaIE._url_for_embed_code(embed_code)
39         except ExtractorError:
40             raise ExtractorError('The page doesn\'t contain a video', expected=True)
41         return self.url_result(ooyala_url, ie='Ooyala')