]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/cbs.py
Rename compat_urllib_request_Request to sanitized_Request and move to utils
[yt-dlp.git] / youtube_dl / extractor / cbs.py
CommitLineData
e42a692f
PH
1from __future__ import unicode_literals
2
fa3ae234 3from .common import InfoExtractor
4e21b3a9
S
4from ..compat import compat_urllib_request
5from ..utils import smuggle_url
fa3ae234
PH
6
7
8class CBSIE(InfoExtractor):
9d581f3d 9 _VALID_URL = r'https?://(?:www\.)?(?:cbs\.com/shows/[^/]+/(?:video|artist)|colbertlateshow\.com/(?:video|podcasts))/[^/]+/(?P<id>[^/]+)'
fa3ae234 10
2871d489 11 _TESTS = [{
e42a692f
PH
12 'url': 'http://www.cbs.com/shows/garth-brooks/video/_u7W953k6la293J7EPTd9oHkSPs6Xn6_/connect-chat-feat-garth-brooks/',
13 'info_dict': {
14 'id': '4JUVEwq3wUT7',
9d581f3d 15 'display_id': 'connect-chat-feat-garth-brooks',
e42a692f
PH
16 'ext': 'flv',
17 'title': 'Connect Chat feat. Garth Brooks',
18 'description': 'Connect with country music singer Garth Brooks, as he chats with fans on Wednesday November 27, 2013. Be sure to tune in to Garth Brooks: Live from Las Vegas, Friday November 29, at 9/8c on CBS!',
19 'duration': 1495,
fa3ae234 20 },
e42a692f 21 'params': {
fa3ae234 22 # rtmp download
e42a692f 23 'skip_download': True,
fa3ae234 24 },
e42a692f 25 '_skip': 'Blocked outside the US',
2871d489 26 }, {
e42a692f
PH
27 'url': 'http://www.cbs.com/shows/liveonletterman/artist/221752/st-vincent/',
28 'info_dict': {
10437550 29 'id': 'WWF_5KqY3PK1',
9d581f3d 30 'display_id': 'st-vincent',
e42a692f
PH
31 'ext': 'flv',
32 'title': 'Live on Letterman - St. Vincent',
33 'description': 'Live On Letterman: St. Vincent in concert from New York\'s Ed Sullivan Theater on Tuesday, July 16, 2014.',
34 'duration': 3221,
2871d489 35 },
e42a692f 36 'params': {
2871d489 37 # rtmp download
e42a692f 38 'skip_download': True,
2871d489 39 },
e42a692f 40 '_skip': 'Blocked outside the US',
9bf99891
S
41 }, {
42 'url': 'http://colbertlateshow.com/video/8GmB0oY0McANFvp2aEffk9jZZZ2YyXxy/the-colbeard/',
43 'only_matching': True,
44 }, {
9d581f3d 45 'url': 'http://www.colbertlateshow.com/podcasts/dYSwjqPs_X1tvbV_P2FcPWRa_qT6akTC/in-the-bad-room-with-stephen/',
9bf99891 46 'only_matching': True,
2871d489 47 }]
fa3ae234
PH
48
49 def _real_extract(self, url):
9d581f3d 50 display_id = self._match_id(url)
4e21b3a9
S
51 request = compat_urllib_request.Request(url)
52 # Android UA is served with higher quality (720p) streams (see
53 # https://github.com/rg3/youtube-dl/issues/7490)
54 request.add_header('User-Agent', 'Mozilla/5.0 (Linux; Android 4.4; Nexus 5)')
55 webpage = self._download_webpage(request, display_id)
fa3ae234 56 real_id = self._search_regex(
9bf99891 57 [r"video\.settings\.pid\s*=\s*'([^']+)';", r"cbsplayer\.pid\s*=\s*'([^']+)';"],
e42a692f 58 webpage, 'real video ID')
9d581f3d
S
59 return {
60 '_type': 'url_transparent',
61 'ie_key': 'ThePlatform',
4e21b3a9
S
62 'url': smuggle_url(
63 'http://link.theplatform.com/s/dJ5BDC/%s?mbr=true&manifest=m3u' % real_id,
64 {'force_smil_url': True}),
9d581f3d
S
65 'display_id': display_id,
66 }