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.

68 lines
2.3 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import parse_iso8601
  5. class Abc7NewsIE(InfoExtractor):
  6. _VALID_URL = r'https?://abc7news\.com(?:/[^/]+/(?P<display_id>[^/]+))?/(?P<id>\d+)'
  7. _TESTS = [
  8. {
  9. 'url': 'http://abc7news.com/entertainment/east-bay-museum-celebrates-vintage-synthesizers/472581/',
  10. 'info_dict': {
  11. 'id': '472581',
  12. 'display_id': 'east-bay-museum-celebrates-vintage-synthesizers',
  13. 'ext': 'mp4',
  14. 'title': 'East Bay museum celebrates history of synthesized music',
  15. 'description': 'md5:a4f10fb2f2a02565c1749d4adbab4b10',
  16. 'thumbnail': 're:^https?://.*\.jpg$',
  17. 'timestamp': 1421123075,
  18. 'upload_date': '20150113',
  19. 'uploader': 'Jonathan Bloom',
  20. },
  21. 'params': {
  22. # m3u8 download
  23. 'skip_download': True,
  24. },
  25. },
  26. {
  27. 'url': 'http://abc7news.com/472581',
  28. 'only_matching': True,
  29. },
  30. ]
  31. def _real_extract(self, url):
  32. mobj = re.match(self._VALID_URL, url)
  33. video_id = mobj.group('id')
  34. display_id = mobj.group('display_id') or video_id
  35. webpage = self._download_webpage(url, display_id)
  36. m3u8 = self._html_search_meta(
  37. 'contentURL', webpage, 'm3u8 url', fatal=True)
  38. formats = self._extract_m3u8_formats(m3u8, display_id, 'mp4')
  39. self._sort_formats(formats)
  40. title = self._og_search_title(webpage).strip()
  41. description = self._og_search_description(webpage).strip()
  42. thumbnail = self._og_search_thumbnail(webpage)
  43. timestamp = parse_iso8601(self._search_regex(
  44. r'<div class="meta">\s*<time class="timeago" datetime="([^"]+)">',
  45. webpage, 'upload date', fatal=False))
  46. uploader = self._search_regex(
  47. r'rel="author">([^<]+)</a>',
  48. webpage, 'uploader', default=None)
  49. return {
  50. 'id': video_id,
  51. 'display_id': display_id,
  52. 'title': title,
  53. 'description': description,
  54. 'thumbnail': thumbnail,
  55. 'timestamp': timestamp,
  56. 'uploader': uploader,
  57. 'formats': formats,
  58. }