2016-05-21 00:40:45 -05:00
# coding: utf-8
from __future__ import unicode_literals
from . anvato import AnvatoIE
from . sendtonews import SendtoNewsIE
from . . compat import compat_urlparse
2016-11-24 06:32:17 -06:00
from . . utils import (
parse_iso8601 ,
unified_timestamp ,
)
2016-05-21 00:40:45 -05:00
class CBSLocalIE ( AnvatoIE ) :
2016-11-24 06:32:17 -06:00
_VALID_URL = r ' https?://[a-z]+ \ .cbslocal \ .com/(?: \ d+/ \ d+/ \ d+|video)/(?P<id>[0-9a-z-]+) '
2016-05-21 00:40:45 -05:00
_TESTS = [ {
# Anvato backend
' url ' : ' http://losangeles.cbslocal.com/2016/05/16/safety-advocates-say-fatal-car-seat-failures-are-public-health-crisis ' ,
' md5 ' : ' f0ee3081e3843f575fccef901199b212 ' ,
' info_dict ' : {
' id ' : ' 3401037 ' ,
' ext ' : ' mp4 ' ,
' title ' : ' Safety Advocates Say Fatal Car Seat Failures Are \' Public Health Crisis \' ' ,
' description ' : ' Collapsing seats have been the focus of scrutiny for decades, though experts say remarkably little has been done to address the issue. Randy Paige reports. ' ,
' thumbnail ' : ' re:^https?://.* ' ,
' timestamp ' : 1463440500 ,
' upload_date ' : ' 20160516 ' ,
2016-11-04 09:33:08 -05:00
' uploader ' : ' CBS ' ,
2016-05-21 00:40:45 -05:00
' subtitles ' : {
' en ' : ' mincount:5 ' ,
} ,
' categories ' : [
' Stations \\ Spoken Word \\ KCBSTV ' ,
' Syndication \\ MSN ' ,
' Syndication \\ NDN ' ,
' Syndication \\ AOL ' ,
' Syndication \\ Yahoo ' ,
' Syndication \\ Tribune ' ,
' Syndication \\ Curb.tv ' ,
' Content \\ News '
] ,
2016-11-04 09:33:08 -05:00
' tags ' : [ ' CBS 2 News Evening ' ] ,
2016-05-21 00:40:45 -05:00
} ,
} , {
# SendtoNews embed
' url ' : ' http://cleveland.cbslocal.com/2016/05/16/indians-score-season-high-15-runs-in-blowout-win-over-reds-rapid-reaction/ ' ,
' info_dict ' : {
' id ' : ' GxfCe0Zo7D-175909-5588 ' ,
} ,
2016-08-15 00:37:37 -05:00
' playlist_count ' : 9 ,
2016-05-21 00:40:45 -05:00
' params ' : {
# m3u8 download
' skip_download ' : True ,
} ,
2016-11-24 06:32:17 -06:00
} , {
' url ' : ' http://newyork.cbslocal.com/video/3580809-a-very-blue-anniversary/ ' ,
' info_dict ' : {
' id ' : ' 3580809 ' ,
' ext ' : ' mp4 ' ,
' title ' : ' A Very Blue Anniversary ' ,
' description ' : ' CBS2’ s Cindy Hsu has more. ' ,
' thumbnail ' : ' re:^https?://.* ' ,
2017-04-27 16:26:59 -05:00
' timestamp ' : int ,
' upload_date ' : r ' re:^ \ d {8} $ ' ,
2016-11-24 06:32:17 -06:00
' uploader ' : ' CBS ' ,
' subtitles ' : {
' en ' : ' mincount:5 ' ,
} ,
' categories ' : [
' Stations \\ Spoken Word \\ WCBSTV ' ,
' Syndication \\ AOL ' ,
' Syndication \\ MSN ' ,
' Syndication \\ NDN ' ,
' Syndication \\ Yahoo ' ,
' Content \\ News ' ,
' Content \\ News \\ Local News ' ,
] ,
' tags ' : [ ' CBS 2 News Weekends ' , ' Cindy Hsu ' , ' Blue Man Group ' ] ,
} ,
2016-05-21 00:40:45 -05:00
} ]
def _real_extract ( self , url ) :
display_id = self . _match_id ( url )
webpage = self . _download_webpage ( url , display_id )
sendtonews_url = SendtoNewsIE . _extract_url ( webpage )
if sendtonews_url :
2016-08-15 00:37:37 -05:00
return self . url_result (
compat_urlparse . urljoin ( url , sendtonews_url ) ,
ie = SendtoNewsIE . ie_key ( ) )
info_dict = self . _extract_anvato_videos ( webpage , display_id )
2016-05-21 00:40:45 -05:00
2017-12-16 08:57:30 -06:00
timestamp = unified_timestamp ( self . _html_search_regex (
r ' class= " (?:entry|post)-date " [^>]*>([^<]+) ' , webpage ,
' released date ' , d efault = None ) ) or parse_iso8601 (
self . _html_search_meta ( ' uploadDate ' , webpage ) )
2016-05-21 00:40:45 -05:00
info_dict . update ( {
' display_id ' : display_id ,
' timestamp ' : timestamp ,
} )
return info_dict