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.

84 lines
2.9 KiB

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