]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/cbsnews.py
2 from __future__
import unicode_literals
7 from .common
import InfoExtractor
10 class CBSNewsIE(InfoExtractor
):
12 _VALID_URL
= r
'http://(?:www\.)?cbsnews\.com/(?:[^/]+/)+(?P<id>[\da-z_-]+)'
16 'url': 'http://www.cbsnews.com/news/tesla-and-spacex-elon-musks-industrial-empire/',
18 'id': 'tesla-and-spacex-elon-musks-industrial-empire',
20 'title': 'Tesla and SpaceX: Elon Musk\'s industrial empire',
21 'thumbnail': 'http://beta.img.cbsnews.com/i/2014/03/30/60147937-2f53-4565-ad64-1bdd6eb64679/60-0330-pelley-640x360.jpg',
26 'skip_download': True,
30 'url': 'http://www.cbsnews.com/videos/fort-hood-shooting-army-downplays-mental-illness-as-cause-of-attack/',
32 'id': 'fort-hood-shooting-army-downplays-mental-illness-as-cause-of-attack',
34 'title': 'Fort Hood shooting: Army downplays mental illness as cause of attack',
35 'thumbnail': 're:^https?://.*\.jpg$',
40 'skip_download': True,
45 def _real_extract(self
, url
):
46 mobj
= re
.match(self
._VALID
_URL
, url
)
47 video_id
= mobj
.group('id')
49 webpage
= self
._download
_webpage
(url
, video_id
)
51 video_info
= json
.loads(self
._html
_search
_regex
(
52 r
'(?:<ul class="media-list items" id="media-related-items"><li data-video-info|<div id="cbsNewsVideoPlayer" data-video-player-options)=\'({.+?
})\'',
53 webpage, 'video JSON info
'))
55 item = video_info['item
'] if 'item
' in video_info else video_info
56 title = item.get('articleTitle
') or item.get('hed
')
57 duration = item.get('duration
')
58 thumbnail = item.get('mediaImage
') or item.get('thumbnail
')
61 for format_id in ['RtmpMobileLow
', 'RtmpMobileHigh
', 'Hls
', 'RtmpDesktop
']:
62 uri = item.get('media
' + format_id + 'URI
')
67 'format_id
': format_id,
69 if uri.startswith('rtmp
'):
71 'app
': 'ondemand?auth
=cbs
',
72 'play_path
': 'mp4
:' + uri.split('<break>')[-1],
73 'player_url
': 'http
://www
.cbsnews
.com
/[[IMPORT
]]/vidtech
.cbsinteractive
.com
/player
/3_3_0/CBSI_PLAYER_HD
.swf
',
74 'page_url
': 'http
://www
.cbsnews
.com
',
77 elif uri.endswith('.m3u8
'):
84 'thumbnail
': thumbnail,