performgroup.py 3.2 KB

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