2016-05-21 14:40:45 +09: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 21:32:17 +09:00
|
|
|
|
from ..utils import (
|
2022-02-23 11:55:38 +09:00
|
|
|
|
merge_dicts,
|
2016-11-24 21:32:17 +09:00
|
|
|
|
parse_iso8601,
|
|
|
|
|
unified_timestamp,
|
|
|
|
|
)
|
2016-05-21 14:40:45 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CBSLocalIE(AnvatoIE):
|
2020-12-24 20:40:34 +09:00
|
|
|
|
_VALID_URL_BASE = r'https?://[a-z]+\.cbslocal\.com/'
|
|
|
|
|
_VALID_URL = _VALID_URL_BASE + r'video/(?P<id>\d+)'
|
|
|
|
|
|
2022-02-23 11:55:38 +09:00
|
|
|
|
_OLD_ANVATO_KEY = 'anvato_cbslocal_app_web_prod_547f3e49241ef0e5d30c79b2efbca5d92c698f67'
|
|
|
|
|
|
2020-12-24 20:40:34 +09:00
|
|
|
|
_TESTS = [{
|
|
|
|
|
'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?://.*',
|
|
|
|
|
'timestamp': int,
|
|
|
|
|
'upload_date': r're:^\d{8}$',
|
|
|
|
|
'uploader': 'CBS',
|
|
|
|
|
'subtitles': {
|
|
|
|
|
'en': 'mincount:5',
|
|
|
|
|
},
|
|
|
|
|
'categories': [
|
|
|
|
|
'Stations\\Spoken Word\\WCBSTV',
|
|
|
|
|
'Content\\News',
|
|
|
|
|
'Content\\News\\Local News',
|
|
|
|
|
],
|
|
|
|
|
'tags': ['CBS 2 News Weekends', 'Cindy Hsu', 'Blue Man Group'],
|
|
|
|
|
},
|
|
|
|
|
'params': {
|
|
|
|
|
'skip_download': True,
|
|
|
|
|
},
|
2022-02-23 11:55:38 +09:00
|
|
|
|
'expected_warnings': ('Failed to download m3u8 information', ),
|
2020-12-24 20:40:34 +09:00
|
|
|
|
}]
|
|
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
2022-02-23 11:55:38 +09:00
|
|
|
|
|
2020-12-24 20:40:34 +09:00
|
|
|
|
mcp_id = self._match_id(url)
|
2022-02-23 11:55:38 +09:00
|
|
|
|
webpage = self._download_webpage(url, mcp_id)
|
|
|
|
|
|
|
|
|
|
json_ld = self._search_json_ld(webpage, mcp_id, fatal=False) or {}
|
|
|
|
|
json_ld.pop('url', None)
|
|
|
|
|
|
|
|
|
|
return merge_dicts(
|
|
|
|
|
self._extract_anvato_videos(webpage, mcp_id)
|
|
|
|
|
or self.url_result(self._OLD_ANVATO_KEY + ':' + mcp_id, 'Anvato', mcp_id),
|
|
|
|
|
json_ld)
|
2020-12-24 20:40:34 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CBSLocalArticleIE(AnvatoIE):
|
|
|
|
|
_VALID_URL = CBSLocalIE._VALID_URL_BASE + r'\d+/\d+/\d+/(?P<id>[0-9a-z-]+)'
|
2016-05-21 14:40:45 +09:00
|
|
|
|
|
|
|
|
|
_TESTS = [{
|
|
|
|
|
# Anvato backend
|
|
|
|
|
'url': 'http://losangeles.cbslocal.com/2016/05/16/safety-advocates-say-fatal-car-seat-failures-are-public-health-crisis',
|
2022-02-23 11:55:38 +09:00
|
|
|
|
'only_matching': True
|
|
|
|
|
}, {
|
|
|
|
|
'url': 'https://losangeles.cbslocal.com/2022/02/16/rams-super-bowl-parade-to-take-place-wednesday/',
|
|
|
|
|
'md5': '36bdac3fb24ec8a6d7790218a0357b08',
|
2016-05-21 14:40:45 +09:00
|
|
|
|
'info_dict': {
|
2022-02-23 11:55:38 +09:00
|
|
|
|
'id': '6201053',
|
2016-05-21 14:40:45 +09:00
|
|
|
|
'ext': 'mp4',
|
2022-02-23 11:55:38 +09:00
|
|
|
|
'display_id': 'rams-super-bowl-parade-to-take-place-wednesday',
|
|
|
|
|
'upload_date': '20220216',
|
2016-11-04 23:33:08 +09:00
|
|
|
|
'uploader': 'CBS',
|
2022-02-23 11:55:38 +09:00
|
|
|
|
'description': 'Jeff Nguyen is live from outside the L.A. Memorial Coliseum where fans cheered on the Los Angeles Rams.',
|
|
|
|
|
'timestamp': 1645044990,
|
|
|
|
|
'title': 'Rams Fans Gather Outside The LA Memorial Coliseum',
|
2016-05-21 14:40:45 +09:00
|
|
|
|
'categories': [
|
2022-02-23 11:55:38 +09:00
|
|
|
|
'Stations\\Spoken Word\\KCALTV',
|
|
|
|
|
'Content\\News',
|
|
|
|
|
'Content\\Top Story',
|
2016-05-21 14:40:45 +09:00
|
|
|
|
],
|
2022-02-23 11:55:38 +09:00
|
|
|
|
'tags': ['KCAL 9 News Afternoon'],
|
2016-05-21 14:40:45 +09: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 14:37:37 +09:00
|
|
|
|
'playlist_count': 9,
|
2016-05-21 14:40:45 +09:00
|
|
|
|
'params': {
|
|
|
|
|
# m3u8 download
|
|
|
|
|
'skip_download': True,
|
|
|
|
|
},
|
2022-02-23 11:55:38 +09:00
|
|
|
|
'skip': 'Redirects to CBS News home page',
|
2016-05-21 14:40:45 +09:00
|
|
|
|
}]
|
|
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
|
display_id = self._match_id(url)
|
|
|
|
|
webpage = self._download_webpage(url, display_id)
|
|
|
|
|
|
2022-02-23 11:55:38 +09:00
|
|
|
|
json_ld = self._search_json_ld(webpage, display_id, fatal=False) or {}
|
|
|
|
|
json_ld.pop('url', None)
|
|
|
|
|
|
2016-05-21 14:40:45 +09:00
|
|
|
|
sendtonews_url = SendtoNewsIE._extract_url(webpage)
|
|
|
|
|
if sendtonews_url:
|
2022-02-23 11:55:38 +09:00
|
|
|
|
result = self.url_result(
|
2016-08-15 14:37:37 +09:00
|
|
|
|
compat_urlparse.urljoin(url, sendtonews_url),
|
|
|
|
|
ie=SendtoNewsIE.ie_key())
|
2022-02-23 11:55:38 +09:00
|
|
|
|
return merge_dicts(result, json_ld)
|
2016-08-15 14:37:37 +09:00
|
|
|
|
|
2022-02-23 11:55:38 +09:00
|
|
|
|
# returns a dict, or raises
|
2016-08-15 14:37:37 +09:00
|
|
|
|
info_dict = self._extract_anvato_videos(webpage, display_id)
|
2016-05-21 14:40:45 +09:00
|
|
|
|
|
2017-12-16 23:57:30 +09:00
|
|
|
|
timestamp = unified_timestamp(self._html_search_regex(
|
|
|
|
|
r'class="(?:entry|post)-date"[^>]*>([^<]+)', webpage,
|
|
|
|
|
'released date', default=None)) or parse_iso8601(
|
|
|
|
|
self._html_search_meta('uploadDate', webpage))
|
2016-05-21 14:40:45 +09:00
|
|
|
|
|
2022-02-23 11:55:38 +09:00
|
|
|
|
return merge_dicts(
|
|
|
|
|
info_dict,
|
|
|
|
|
json_ld,
|
|
|
|
|
{
|
|
|
|
|
'display_id': display_id,
|
|
|
|
|
'timestamp': timestamp,
|
|
|
|
|
})
|