]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/cbs.py
376db726326302972c7c7ab33b7d362fa1360e67
1 from __future__
import unicode_literals
3 from . theplatform
import ThePlatformFeedIE
14 class CBSBaseIE ( ThePlatformFeedIE
):
15 def _parse_smil_subtitles ( self
, smil
, namespace
= None , subtitles_lang
= 'en' ):
17 for k
, ext
in [( 'sMPTE-TTCCURL' , 'tt' ), ( 'ClosedCaptionURL' , 'ttml' ), ( 'webVTTCaptionURL' , 'vtt' )]:
18 cc_e
= find_xpath_attr ( smil
, self
._ xpath
_ ns
( './/param' , namespace
), 'name' , k
)
20 cc_url
= cc_e
. get ( 'value' )
22 subtitles
. setdefault ( subtitles_lang
, []). append ({
29 class CBSIE ( CBSBaseIE
):
30 _VALID_URL
= r
'(?:cbs:|https?://(?:www\.)?(?:cbs\.com/shows/[^/]+/video|colbertlateshow\.com/(?:video|podcasts))/)(?P<id>[\w-]+)'
33 'url' : 'http://www.cbs.com/shows/garth-brooks/video/_u7W953k6la293J7EPTd9oHkSPs6Xn6_/connect-chat-feat-garth-brooks/' ,
35 'id' : '_u7W953k6la293J7EPTd9oHkSPs6Xn6_' ,
37 'title' : 'Connect Chat feat. Garth Brooks' ,
38 '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!' ,
40 'timestamp' : 1385585425 ,
41 'upload_date' : '20131127' ,
42 'uploader' : 'CBSI-NEW' ,
46 'skip_download' : True ,
48 '_skip' : 'Blocked outside the US' ,
50 'url' : 'http://colbertlateshow.com/video/8GmB0oY0McANFvp2aEffk9jZZZ2YyXxy/the-colbeard/' ,
51 'only_matching' : True ,
53 'url' : 'http://www.colbertlateshow.com/podcasts/dYSwjqPs_X1tvbV_P2FcPWRa_qT6akTC/in-the-bad-room-with-stephen/' ,
54 'only_matching' : True ,
57 def _extract_video_info ( self
, content_id
, site
= 'cbs' , mpx_acc
= 2198311517 ):
58 items_data
= self
._ download
_ xml
(
59 'http://can.cbs.com/thunder/player/videoPlayerService.php' ,
60 content_id
, query
={ 'partner' : site
, 'contentId' : content_id
})
61 video_data
= xpath_element ( items_data
, './/item' )
62 title
= xpath_text ( video_data
, 'videoTitle' , 'title' , True )
63 tp_path
= 'dJ5BDC/media/guid/ %d / %s ' % ( mpx_acc
, content_id
)
64 tp_release_url
= 'http://link.theplatform.com/s/' + tp_path
70 for item
in items_data
. findall ( './/item' ):
71 asset_type
= xpath_text ( item
, 'assetType' )
72 if not asset_type
or asset_type
in asset_types
or asset_type
in ( 'HLS_FPS' , 'DASH_CENC' ):
74 asset_types
. append ( asset_type
)
77 'assetTypes' : asset_type
,
79 if asset_type
. startswith ( 'HLS' ) or asset_type
in ( 'OnceURL' , 'StreamPack' ):
80 query
[ 'formats' ] = 'MPEG4,M3U'
81 elif asset_type
in ( 'RTMP' , 'WIFI' , '3G' ):
82 query
[ 'formats' ] = 'MPEG4,FLV'
84 tp_formats
, tp_subtitles
= self
._ extract
_ theplatform
_ smil
(
85 update_url_query ( tp_release_url
, query
), content_id
,
86 'Downloading %s SMIL data' % asset_type
)
87 except ExtractorError
as e
:
90 formats
. extend ( tp_formats
)
91 subtitles
= self
._ merge
_ subtitles
( subtitles
, tp_subtitles
)
92 if last_e
and not formats
:
94 self
._ sort
_ formats
( formats
)
96 info
= self
._ extract
_ theplatform
_ metadata
( tp_path
, content_id
)
100 'series' : xpath_text ( video_data
, 'seriesTitle' ),
101 'season_number' : int_or_none ( xpath_text ( video_data
, 'seasonNumber' )),
102 'episode_number' : int_or_none ( xpath_text ( video_data
, 'episodeNumber' )),
103 'duration' : int_or_none ( xpath_text ( video_data
, 'videoLength' ), 1000 ),
104 'thumbnail' : xpath_text ( video_data
, 'previewImageURL' ),
106 'subtitles' : subtitles
,
110 def _real_extract ( self
, url
):
111 content_id
= self
._ match
_ id
( url
)
112 return self
._ extract
_ video
_ info
( content_id
)