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.

112 lines
3.8 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. int_or_none,
  7. parse_iso8601,
  8. )
  9. class ABCOTVSIE(InfoExtractor):
  10. IE_NAME = 'abcotvs'
  11. IE_DESC = 'ABC Owned Television Stations'
  12. _VALID_URL = r'https?://(?:abc(?:7(?:news|ny|chicago)?|11|13|30)|6abc)\.com(?:/[^/]+/(?P<display_id>[^/]+))?/(?P<id>\d+)'
  13. _TESTS = [
  14. {
  15. 'url': 'http://abc7news.com/entertainment/east-bay-museum-celebrates-vintage-synthesizers/472581/',
  16. 'info_dict': {
  17. 'id': '472581',
  18. 'display_id': 'east-bay-museum-celebrates-vintage-synthesizers',
  19. 'ext': 'mp4',
  20. 'title': 'East Bay museum celebrates vintage synthesizers',
  21. 'description': 'md5:a4f10fb2f2a02565c1749d4adbab4b10',
  22. 'thumbnail': r're:^https?://.*\.jpg$',
  23. 'timestamp': 1421123075,
  24. 'upload_date': '20150113',
  25. 'uploader': 'Jonathan Bloom',
  26. },
  27. 'params': {
  28. # m3u8 download
  29. 'skip_download': True,
  30. },
  31. },
  32. {
  33. 'url': 'http://abc7news.com/472581',
  34. 'only_matching': True,
  35. },
  36. ]
  37. def _real_extract(self, url):
  38. mobj = re.match(self._VALID_URL, url)
  39. video_id = mobj.group('id')
  40. display_id = mobj.group('display_id') or video_id
  41. webpage = self._download_webpage(url, display_id)
  42. m3u8 = self._html_search_meta(
  43. 'contentURL', webpage, 'm3u8 url', fatal=True).split('?')[0]
  44. formats = self._extract_m3u8_formats(m3u8, display_id, 'mp4')
  45. self._sort_formats(formats)
  46. title = self._og_search_title(webpage).strip()
  47. description = self._og_search_description(webpage).strip()
  48. thumbnail = self._og_search_thumbnail(webpage)
  49. timestamp = parse_iso8601(self._search_regex(
  50. r'<div class="meta">\s*<time class="timeago" datetime="([^"]+)">',
  51. webpage, 'upload date', fatal=False))
  52. uploader = self._search_regex(
  53. r'rel="author">([^<]+)</a>',
  54. webpage, 'uploader', default=None)
  55. return {
  56. 'id': video_id,
  57. 'display_id': display_id,
  58. 'title': title,
  59. 'description': description,
  60. 'thumbnail': thumbnail,
  61. 'timestamp': timestamp,
  62. 'uploader': uploader,
  63. 'formats': formats,
  64. }
  65. class ABCOTVSClipsIE(InfoExtractor):
  66. IE_NAME = 'abcotvs:clips'
  67. _VALID_URL = r'https?://clips\.abcotvs\.com/(?:[^/]+/)*video/(?P<id>\d+)'
  68. _TEST = {
  69. 'url': 'https://clips.abcotvs.com/kabc/video/214814',
  70. 'info_dict': {
  71. 'id': '214814',
  72. 'ext': 'mp4',
  73. 'title': 'SpaceX launch pad explosion destroys rocket, satellite',
  74. 'description': 'md5:9f186e5ad8f490f65409965ee9c7be1b',
  75. 'upload_date': '20160901',
  76. 'timestamp': 1472756695,
  77. },
  78. 'params': {
  79. # m3u8 download
  80. 'skip_download': True,
  81. },
  82. }
  83. def _real_extract(self, url):
  84. video_id = self._match_id(url)
  85. video_data = self._download_json('https://clips.abcotvs.com/vogo/video/getByIds?ids=' + video_id, video_id)['results'][0]
  86. title = video_data['title']
  87. formats = self._extract_m3u8_formats(
  88. video_data['videoURL'].split('?')[0], video_id, 'mp4')
  89. self._sort_formats(formats)
  90. return {
  91. 'id': video_id,
  92. 'title': title,
  93. 'description': video_data.get('description'),
  94. 'thumbnail': video_data.get('thumbnailURL'),
  95. 'duration': int_or_none(video_data.get('duration')),
  96. 'timestamp': int_or_none(video_data.get('pubDate')),
  97. 'formats': formats,
  98. }