]>
jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/vice.py
1 from __future__
import unicode_literals
5 from .common
import InfoExtractor
6 from ..utils
import ExtractorError
9 class ViceIE(InfoExtractor
):
10 _VALID_URL
= r
'https?://(?:.+?\.)?vice\.com/(?:[^/]+/)?videos?/(?P<id>[^/?#&]+)'
13 'url': 'http://www.vice.com/video/cowboy-capitalists-part-1',
15 'id': '43cW1mYzpia9IlestBjVpd23Yu3afAfp',
17 'title': 'VICE_COWBOYCAPITALISTS_PART01_v1_VICE_WM_1080p.mov',
21 'url': 'http://www.vice.com/video/how-to-hack-a-car',
22 'md5': '6fb2989a3fed069fb8eab3401fc2d3c9',
26 'title': 'How to Hack a Car: Phreaked Out (Episode 2)',
27 'description': 'md5:ee95453f7ff495db8efe14ae8bf56f30',
28 'uploader_id': 'MotherboardTV',
29 'uploader': 'Motherboard',
30 'upload_date': '20140529',
33 'url': 'https://news.vice.com/video/experimenting-on-animals-inside-the-monkey-lab',
34 'only_matching': True,
36 'url': 'http://www.vice.com/ru/video/big-night-out-ibiza-clive-martin-229',
37 'only_matching': True,
39 'url': 'https://munchies.vice.com/en/videos/watch-the-trailer-for-our-new-series-the-pizza-show',
40 'only_matching': True,
43 def _real_extract(self
, url
):
44 video_id
= self
._match
_id
(url
)
45 webpage
= self
._download
_webpage
(url
, video_id
)
47 embed_code
= self
._search
_regex
(
48 r
'embedCode=([^&\'"]+)', webpage,
49 'ooyala embed code', default=None)
51 return self.url_result('ooyala:%s' % embed_code, 'Ooyala')
52 youtube_id = self._search_regex(
53 r'data-youtube-id="([^
"]+)"', webpage, 'youtube
id')
54 return self.url_result(youtube_id, 'Youtube
')
55 except ExtractorError:
56 raise ExtractorError('The page doesn
\'t contain a video
', expected=True)
59 class ViceShowIE(InfoExtractor):
60 _VALID_URL = r'https?
://(?
:.+?\
.)?vice\
.com
/(?
:[^
/]+/)?show
/(?P
<id>[^
/?
#&]+)'
63 'url': 'https://munchies.vice.com/en/show/fuck-thats-delicious-2',
65 'id': 'fuck-thats-delicious-2',
66 'title': "Fuck, That's Delicious",
67 'description': 'Follow the culinary adventures of rapper Action Bronson during his ongoing world tour.',
72 def _real_extract(self
, url
):
73 show_id
= self
._match
_id
(url
)
74 webpage
= self
._download
_webpage
(url
, show_id
)
77 self
.url_result(video_url
, ViceIE
.ie_key())
78 for video_url
, _
in re
.findall(
79 r
'<h2[^>]+class="article-title"[^>]+data-id="\d+"[^>]*>\s*<a[^>]+href="(%s.*?)"'
80 % ViceIE
._VALID
_URL
, webpage
)]
82 title
= self
._search
_regex
(
83 r
'<title>(.+?)</title>', webpage
, 'title', default
=None)
85 title
= re
.sub(r
'(.+)\s*\|\s*.+$', r
'\1', title
).strip()
86 description
= self
._html
_search
_meta
('description', webpage
, 'description')
88 return self
.playlist_result(entries
, show_id
, title
, description
)