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.

67 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. title = self._og_search_title(webpage).strip()
  40. description = self._og_search_description(webpage).strip()
  41. thumbnail = self._og_search_thumbnail(webpage)
  42. timestamp = parse_iso8601(self._search_regex(
  43. r'<div class="meta">\s*<time class="timeago" datetime="([^"]+)">',
  44. webpage, 'upload date', fatal=False))
  45. uploader = self._search_regex(
  46. r'rel="author">([^<]+)</a>',
  47. webpage, 'uploader', default=None)
  48. return {
  49. 'id': video_id,
  50. 'display_id': display_id,
  51. 'title': title,
  52. 'description': description,
  53. 'thumbnail': thumbnail,
  54. 'timestamp': timestamp,
  55. 'uploader': uploader,
  56. 'formats': formats,
  57. }