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.

83 lines
3.3 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import int_or_none
  6. class PerformGroupIE(InfoExtractor):
  7. _VALID_URL = r'https?://player\.performgroup\.com/eplayer(?:/eplayer\.html|\.js)#/?(?P<id>[0-9a-f]{26})\.(?P<auth_token>[0-9a-z]{26})'
  8. _TESTS = [{
  9. # http://www.faz.net/aktuell/sport/fussball/wm-2018-playoffs-schweiz-besiegt-nordirland-1-0-15286104.html
  10. 'url': 'http://player.performgroup.com/eplayer/eplayer.html#d478c41c5d192f56b9aa859de8.1w4crrej5w14e1ed4s1ce4ykab',
  11. 'md5': '259cb03d142e2e52471e8837ecacb29f',
  12. 'info_dict': {
  13. 'id': 'xgrwobuzumes1lwjxtcdpwgxd',
  14. 'ext': 'mp4',
  15. 'title': 'Liga MX: Keine Einsicht nach Horrorfoul',
  16. 'description': 'md5:7cd3b459c82725b021e046ab10bf1c5b',
  17. 'timestamp': 1511533477,
  18. 'upload_date': '20171124',
  19. }
  20. }]
  21. def _call_api(self, service, auth_token, content_id, referer_url):
  22. return self._download_json(
  23. 'http://ep3.performfeeds.com/ep%s/%s/%s/' % (service, auth_token, content_id),
  24. content_id, headers={
  25. 'Referer': referer_url,
  26. 'Origin': 'http://player.performgroup.com',
  27. }, query={
  28. '_fmt': 'json',
  29. })
  30. def _real_extract(self, url):
  31. player_id, auth_token = re.search(self._VALID_URL, url).groups()
  32. bootstrap = self._call_api('bootstrap', auth_token, player_id, url)
  33. video = bootstrap['config']['dataSource']['sourceItems'][0]['videos'][0]
  34. video_id = video['uuid']
  35. vod = self._call_api('vod', auth_token, video_id, url)
  36. media = vod['videos']['video'][0]['media']
  37. formats = []
  38. hls_url = media.get('hls', {}).get('url')
  39. if hls_url:
  40. formats.extend(self._extract_m3u8_formats(hls_url, video_id, 'mp4', 'm3u8_native', m3u8_id='hls', fatal=False))
  41. hds_url = media.get('hds', {}).get('url')
  42. if hds_url:
  43. formats.extend(self._extract_f4m_formats(hds_url + '?hdcore', video_id, f4m_id='hds', fatal=False))
  44. for c in media.get('content', []):
  45. c_url = c.get('url')
  46. if not c_url:
  47. continue
  48. tbr = int_or_none(c.get('bitrate'), 1000)
  49. format_id = 'http'
  50. if tbr:
  51. format_id += '-%d' % tbr
  52. formats.append({
  53. 'format_id': format_id,
  54. 'url': c_url,
  55. 'tbr': tbr,
  56. 'width': int_or_none(c.get('width')),
  57. 'height': int_or_none(c.get('height')),
  58. 'filesize': int_or_none(c.get('fileSize')),
  59. 'vcodec': c.get('type'),
  60. 'fps': int_or_none(c.get('videoFrameRate')),
  61. 'vbr': int_or_none(c.get('videoRate'), 1000),
  62. 'abr': int_or_none(c.get('audioRate'), 1000),
  63. })
  64. self._sort_formats(formats)
  65. return {
  66. 'id': video_id,
  67. 'title': video['title'],
  68. 'description': video.get('description'),
  69. 'thumbnail': video.get('poster'),
  70. 'duration': int_or_none(video.get('duration')),
  71. 'timestamp': int_or_none(video.get('publishedTime'), 1000),
  72. 'formats': formats,
  73. }