cbslocal.py 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. 'uploader': 'CBS',
  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. 'tags': ['CBS 2 News Evening'],
  36. },
  37. }, {
  38. # SendtoNews embed
  39. 'url': 'http://cleveland.cbslocal.com/2016/05/16/indians-score-season-high-15-runs-in-blowout-win-over-reds-rapid-reaction/',
  40. 'info_dict': {
  41. 'id': 'GxfCe0Zo7D-175909-5588',
  42. },
  43. 'playlist_count': 9,
  44. 'params': {
  45. # m3u8 download
  46. 'skip_download': True,
  47. },
  48. }]
  49. def _real_extract(self, url):
  50. display_id = self._match_id(url)
  51. webpage = self._download_webpage(url, display_id)
  52. sendtonews_url = SendtoNewsIE._extract_url(webpage)
  53. if sendtonews_url:
  54. return self.url_result(
  55. compat_urlparse.urljoin(url, sendtonews_url),
  56. ie=SendtoNewsIE.ie_key())
  57. info_dict = self._extract_anvato_videos(webpage, display_id)
  58. time_str = self._html_search_regex(
  59. r'class="entry-date">([^<]+)<', webpage, 'released date', fatal=False)
  60. timestamp = unified_timestamp(time_str)
  61. info_dict.update({
  62. 'display_id': display_id,
  63. 'timestamp': timestamp,
  64. })
  65. return info_dict