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.

106 lines
3.6 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 (
  7. parse_iso8601,
  8. unified_timestamp,
  9. )
  10. class CBSLocalIE(AnvatoIE):
  11. _VALID_URL = r'https?://[a-z]+\.cbslocal\.com/(?:\d+/\d+/\d+|video)/(?P<id>[0-9a-z-]+)'
  12. _TESTS = [{
  13. # Anvato backend
  14. 'url': 'http://losangeles.cbslocal.com/2016/05/16/safety-advocates-say-fatal-car-seat-failures-are-public-health-crisis',
  15. 'md5': 'f0ee3081e3843f575fccef901199b212',
  16. 'info_dict': {
  17. 'id': '3401037',
  18. 'ext': 'mp4',
  19. 'title': 'Safety Advocates Say Fatal Car Seat Failures Are \'Public Health Crisis\'',
  20. '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.',
  21. 'thumbnail': 're:^https?://.*',
  22. 'timestamp': 1463440500,
  23. 'upload_date': '20160516',
  24. 'uploader': 'CBS',
  25. 'subtitles': {
  26. 'en': 'mincount:5',
  27. },
  28. 'categories': [
  29. 'Stations\\Spoken Word\\KCBSTV',
  30. 'Syndication\\MSN',
  31. 'Syndication\\NDN',
  32. 'Syndication\\AOL',
  33. 'Syndication\\Yahoo',
  34. 'Syndication\\Tribune',
  35. 'Syndication\\Curb.tv',
  36. 'Content\\News'
  37. ],
  38. 'tags': ['CBS 2 News Evening'],
  39. },
  40. }, {
  41. # SendtoNews embed
  42. 'url': 'http://cleveland.cbslocal.com/2016/05/16/indians-score-season-high-15-runs-in-blowout-win-over-reds-rapid-reaction/',
  43. 'info_dict': {
  44. 'id': 'GxfCe0Zo7D-175909-5588',
  45. },
  46. 'playlist_count': 9,
  47. 'params': {
  48. # m3u8 download
  49. 'skip_download': True,
  50. },
  51. }, {
  52. 'url': 'http://newyork.cbslocal.com/video/3580809-a-very-blue-anniversary/',
  53. 'info_dict': {
  54. 'id': '3580809',
  55. 'ext': 'mp4',
  56. 'title': 'A Very Blue Anniversary',
  57. 'description': 'CBS2’s Cindy Hsu has more.',
  58. 'thumbnail': 're:^https?://.*',
  59. 'timestamp': 1479962220,
  60. 'upload_date': '20161124',
  61. 'uploader': 'CBS',
  62. 'subtitles': {
  63. 'en': 'mincount:5',
  64. },
  65. 'categories': [
  66. 'Stations\\Spoken Word\\WCBSTV',
  67. 'Syndication\\AOL',
  68. 'Syndication\\MSN',
  69. 'Syndication\\NDN',
  70. 'Syndication\\Yahoo',
  71. 'Content\\News',
  72. 'Content\\News\\Local News',
  73. ],
  74. 'tags': ['CBS 2 News Weekends', 'Cindy Hsu', 'Blue Man Group'],
  75. },
  76. }]
  77. def _real_extract(self, url):
  78. display_id = self._match_id(url)
  79. webpage = self._download_webpage(url, display_id)
  80. sendtonews_url = SendtoNewsIE._extract_url(webpage)
  81. if sendtonews_url:
  82. return self.url_result(
  83. compat_urlparse.urljoin(url, sendtonews_url),
  84. ie=SendtoNewsIE.ie_key())
  85. info_dict = self._extract_anvato_videos(webpage, display_id)
  86. time_str = self._html_search_regex(
  87. r'class="entry-date">([^<]+)<', webpage, 'released date', default=None)
  88. if time_str:
  89. timestamp = unified_timestamp(time_str)
  90. else:
  91. timestamp = parse_iso8601(self._html_search_meta('uploadDate', webpage))
  92. info_dict.update({
  93. 'display_id': display_id,
  94. 'timestamp': timestamp,
  95. })
  96. return info_dict