cbslocal.py 4.0 KB

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