logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

cbslocal.py (4117B)


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