2014-07-23 01:34:34 +10:00
from __future__ import unicode_literals
2013-12-16 13:53:43 +11:00
from . common import InfoExtractor
2015-11-22 03:18:17 +11:00
from . . utils import (
sanitized_Request ,
smuggle_url ,
)
2013-12-16 13:53:43 +11:00
class CBSIE ( InfoExtractor ) :
2015-06-10 01:39:45 +10:00
_VALID_URL = r ' https?://(?:www \ .)?(?:cbs \ .com/shows/[^/]+/(?:video|artist)|colbertlateshow \ .com/(?:video|podcasts))/[^/]+/(?P<id>[^/]+) '
2013-12-16 13:53:43 +11:00
2014-07-23 00:56:42 +10:00
_TESTS = [ {
2014-07-23 01:34:34 +10:00
' url ' : ' http://www.cbs.com/shows/garth-brooks/video/_u7W953k6la293J7EPTd9oHkSPs6Xn6_/connect-chat-feat-garth-brooks/ ' ,
' info_dict ' : {
' id ' : ' 4JUVEwq3wUT7 ' ,
2015-06-10 01:39:45 +10:00
' display_id ' : ' connect-chat-feat-garth-brooks ' ,
2014-07-23 01:34:34 +10:00
' ext ' : ' flv ' ,
' title ' : ' Connect Chat feat. Garth Brooks ' ,
' 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! ' ,
' duration ' : 1495 ,
2013-12-16 13:53:43 +11:00
} ,
2014-07-23 01:34:34 +10:00
' params ' : {
2013-12-16 13:53:43 +11:00
# rtmp download
2014-07-23 01:34:34 +10:00
' skip_download ' : True ,
2013-12-16 13:53:43 +11:00
} ,
2014-07-23 01:34:34 +10:00
' _skip ' : ' Blocked outside the US ' ,
2014-07-23 00:56:42 +10:00
} , {
2014-07-23 01:34:34 +10:00
' url ' : ' http://www.cbs.com/shows/liveonletterman/artist/221752/st-vincent/ ' ,
' info_dict ' : {
2014-08-27 21:41:24 +10:00
' id ' : ' WWF_5KqY3PK1 ' ,
2015-06-10 01:39:45 +10:00
' display_id ' : ' st-vincent ' ,
2014-07-23 01:34:34 +10:00
' ext ' : ' flv ' ,
' title ' : ' Live on Letterman - St. Vincent ' ,
' description ' : ' Live On Letterman: St. Vincent in concert from New York \' s Ed Sullivan Theater on Tuesday, July 16, 2014. ' ,
' duration ' : 3221 ,
2014-07-23 00:56:42 +10:00
} ,
2014-07-23 01:34:34 +10:00
' params ' : {
2014-07-23 00:56:42 +10:00
# rtmp download
2014-07-23 01:34:34 +10:00
' skip_download ' : True ,
2014-07-23 00:56:42 +10:00
} ,
2014-07-23 01:34:34 +10:00
' _skip ' : ' Blocked outside the US ' ,
2015-06-10 01:23:53 +10:00
} , {
' url ' : ' http://colbertlateshow.com/video/8GmB0oY0McANFvp2aEffk9jZZZ2YyXxy/the-colbeard/ ' ,
' only_matching ' : True ,
} , {
2015-06-10 01:39:45 +10:00
' url ' : ' http://www.colbertlateshow.com/podcasts/dYSwjqPs_X1tvbV_P2FcPWRa_qT6akTC/in-the-bad-room-with-stephen/ ' ,
2015-06-10 01:23:53 +10:00
' only_matching ' : True ,
2014-07-23 00:56:42 +10:00
} ]
2013-12-16 13:53:43 +11:00
def _real_extract ( self , url ) :
2015-06-10 01:39:45 +10:00
display_id = self . _match_id ( url )
2015-11-22 03:18:17 +11:00
request = sanitized_Request ( url )
2015-11-14 05:22:32 +11:00
# Android UA is served with higher quality (720p) streams (see
# https://github.com/rg3/youtube-dl/issues/7490)
request . add_header ( ' User-Agent ' , ' Mozilla/5.0 (Linux; Android 4.4; Nexus 5) ' )
webpage = self . _download_webpage ( request , display_id )
2013-12-16 13:53:43 +11:00
real_id = self . _search_regex (
2015-06-10 01:23:53 +10:00
[ r " video \ .settings \ .pid \ s*= \ s* ' ([^ ' ]+) ' ; " , r " cbsplayer \ .pid \ s*= \ s* ' ([^ ' ]+) ' ; " ] ,
2014-07-23 01:34:34 +10:00
webpage , ' real video ID ' )
2015-06-10 01:39:45 +10:00
return {
' _type ' : ' url_transparent ' ,
' ie_key ' : ' ThePlatform ' ,
2015-11-14 05:22:32 +11:00
' url ' : smuggle_url (
' http://link.theplatform.com/s/dJ5BDC/ %s ?mbr=true&manifest=m3u ' % real_id ,
{ ' force_smil_url ' : True } ) ,
2015-06-10 01:39:45 +10:00
' display_id ' : display_id ,
}