You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
2.8 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .anvato import AnvatoIE
  4. from .sendtonews import SendtoNewsIE
  5. from ..compat import compat_urlparse
  6. from ..utils import unified_timestamp
  7. class CBSLocalIE(AnvatoIE):
  8. _VALID_URL = r'https?://[a-z]+\.cbslocal\.com/\d+/\d+/\d+/(?P<id>[0-9a-z-]+)'
  9. _TESTS = [{
  10. # Anvato backend
  11. 'url': 'http://losangeles.cbslocal.com/2016/05/16/safety-advocates-say-fatal-car-seat-failures-are-public-health-crisis',
  12. 'md5': 'f0ee3081e3843f575fccef901199b212',
  13. 'info_dict': {
  14. 'id': '3401037',
  15. 'ext': 'mp4',
  16. 'title': 'Safety Advocates Say Fatal Car Seat Failures Are \'Public Health Crisis\'',
  17. '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.',
  18. 'thumbnail': 're:^https?://.*',
  19. 'timestamp': 1463440500,
  20. 'upload_date': '20160516',
  21. 'subtitles': {
  22. 'en': 'mincount:5',
  23. },
  24. 'categories': [
  25. 'Stations\\Spoken Word\\KCBSTV',
  26. 'Syndication\\MSN',
  27. 'Syndication\\NDN',
  28. 'Syndication\\AOL',
  29. 'Syndication\\Yahoo',
  30. 'Syndication\\Tribune',
  31. 'Syndication\\Curb.tv',
  32. 'Content\\News'
  33. ],
  34. },
  35. }, {
  36. # SendtoNews embed
  37. 'url': 'http://cleveland.cbslocal.com/2016/05/16/indians-score-season-high-15-runs-in-blowout-win-over-reds-rapid-reaction/',
  38. 'info_dict': {
  39. 'id': 'GxfCe0Zo7D-175909-5588',
  40. 'ext': 'mp4',
  41. 'title': 'Recap: CLE 15, CIN 6',
  42. 'description': '5/16/16: Indians\' bats explode for 15 runs in a win',
  43. 'upload_date': '20160516',
  44. 'timestamp': 1463433840,
  45. 'duration': 49,
  46. },
  47. 'params': {
  48. # m3u8 download
  49. 'skip_download': True,
  50. },
  51. }]
  52. def _real_extract(self, url):
  53. display_id = self._match_id(url)
  54. webpage = self._download_webpage(url, display_id)
  55. sendtonews_url = SendtoNewsIE._extract_url(webpage)
  56. if sendtonews_url:
  57. info_dict = {
  58. '_type': 'url_transparent',
  59. 'url': compat_urlparse.urljoin(url, sendtonews_url),
  60. }
  61. else:
  62. info_dict = self._extract_anvato_videos(webpage, display_id)
  63. time_str = self._html_search_regex(
  64. r'class="entry-date">([^<]+)<', webpage, 'released date', fatal=False)
  65. timestamp = unified_timestamp(time_str)
  66. info_dict.update({
  67. 'display_id': display_id,
  68. 'timestamp': timestamp,
  69. })
  70. return info_dict