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.

73 lines
2.3 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. determine_ext,
  6. int_or_none,
  7. unescapeHTML,
  8. )
  9. class ATVAtIE(InfoExtractor):
  10. _VALID_URL = r'https?://(?:www\.)?atv\.at/(?:[^/]+/){2}(?P<id>[dv]\d+)'
  11. _TESTS = [{
  12. 'url': 'http://atv.at/aktuell/di-210317-2005-uhr/v1698449/',
  13. 'md5': 'c3b6b975fb3150fc628572939df205f2',
  14. 'info_dict': {
  15. 'id': '1698447',
  16. 'ext': 'mp4',
  17. 'title': 'DI, 21.03.17 | 20:05 Uhr 1/1',
  18. }
  19. }, {
  20. 'url': 'http://atv.at/aktuell/meinrad-knapp/d8416/',
  21. 'only_matching': True,
  22. }]
  23. def _real_extract(self, url):
  24. display_id = self._match_id(url)
  25. webpage = self._download_webpage(url, display_id)
  26. video_data = self._parse_json(unescapeHTML(self._search_regex(
  27. r'class="[^"]*jsb_video/FlashPlayer[^"]*"[^>]+data-jsb="([^"]+)"',
  28. webpage, 'player data')), display_id)['config']['initial_video']
  29. video_id = video_data['id']
  30. video_title = video_data['title']
  31. parts = []
  32. for part in video_data.get('parts', []):
  33. part_id = part['id']
  34. part_title = part['title']
  35. formats = []
  36. for source in part.get('sources', []):
  37. source_url = source.get('src')
  38. if not source_url:
  39. continue
  40. ext = determine_ext(source_url)
  41. if ext == 'm3u8':
  42. formats.extend(self._extract_m3u8_formats(
  43. source_url, part_id, 'mp4', 'm3u8_native',
  44. m3u8_id='hls', fatal=False))
  45. else:
  46. formats.append({
  47. 'format_id': source.get('delivery'),
  48. 'url': source_url,
  49. })
  50. self._sort_formats(formats)
  51. parts.append({
  52. 'id': part_id,
  53. 'title': part_title,
  54. 'thumbnail': part.get('preview_image_url'),
  55. 'duration': int_or_none(part.get('duration')),
  56. 'is_live': part.get('is_livestream'),
  57. 'formats': formats,
  58. })
  59. return {
  60. '_type': 'multi_video',
  61. 'id': video_id,
  62. 'title': video_title,
  63. 'entries': parts,
  64. }