1 from __future__ import unicode_literals
5 from .common import InfoExtractor
6 from .ooyala import OoyalaIE
7 from ..utils import ExtractorError
10 class ViceIE(InfoExtractor):
11 _VALID_URL = r'https?://(?:.+?\.)?vice\.com/(?:[^/]+/)?videos?/(?P<id>[^/?#&]+)'
14 'url': 'http://www.vice.com/video/cowboy-capitalists-part-1',
16 'id': '43cW1mYzpia9IlestBjVpd23Yu3afAfp',
18 'title': 'VICE_COWBOYCAPITALISTS_PART01_v1_VICE_WM_1080p.mov',
22 'url': 'http://www.vice.com/video/how-to-hack-a-car',
23 'md5': '6fb2989a3fed069fb8eab3401fc2d3c9',
27 'title': 'How to Hack a Car: Phreaked Out (Episode 2)',
28 'description': 'md5:ee95453f7ff495db8efe14ae8bf56f30',
29 'uploader_id': 'MotherboardTV',
30 'uploader': 'Motherboard',
31 'upload_date': '20140529',
34 'url': 'https://news.vice.com/video/experimenting-on-animals-inside-the-monkey-lab',
35 'only_matching': True,
37 'url': 'http://www.vice.com/ru/video/big-night-out-ibiza-clive-martin-229',
38 'only_matching': True,
40 'url': 'https://munchies.vice.com/en/videos/watch-the-trailer-for-our-new-series-the-pizza-show',
41 'only_matching': True,
44 def _real_extract(self, url):
45 video_id = self._match_id(url)
46 webpage = self._download_webpage(url, video_id)
48 embed_code = self._search_regex(
49 r'embedCode=([^&\'"]+)', webpage,
50 'ooyala embed code', default=None)
52 ooyala_url = OoyalaIE._url_for_embed_code(embed_code)
53 return self.url_result('ooyala:%s' % embed_code, 'Ooyala')
54 youtube_id = self._search_regex(
55 r'data-youtube-id="([^"]+)"', webpage, 'youtube id')
56 return self.url_result(youtube_id, 'Youtube')
57 except ExtractorError:
58 raise ExtractorError('The page doesn\'t contain a video', expected=True)
61 class ViceShowIE(InfoExtractor):
62 _VALID_URL = r'https?://(?:.+?\.)?vice\.com/(?:[^/]+/)?show/(?P<id>[^/?#&]+)'
65 'url': 'https://munchies.vice.com/en/show/fuck-thats-delicious-2',
67 'id': 'fuck-thats-delicious-2',
68 'title': "Fuck, That's Delicious",
69 'description': 'Follow the culinary adventures of rapper Action Bronson during his ongoing world tour.',
74 def _real_extract(self, url):
75 show_id = self._match_id(url)
76 webpage = self._download_webpage(url, show_id)
79 self.url_result(video_url, ViceIE.ie_key())
80 for video_url, _ in re.findall(
81 r'<h2[^>]+class="article-title"[^>]+data-id="\d+"[^>]*>\s*<a[^>]+href="(%s.*?)"'
82 % ViceIE._VALID_URL, webpage)]
84 title = self._search_regex(
85 r'<title>(.+?)</title>', webpage, 'title', default=None)
87 title = re.sub(r'(.+)\s*\|\s*.+$', r'\1', title).strip()
88 description = self._html_search_meta('description', webpage, 'description')
90 return self.playlist_result(entries, show_id, title, description)