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.

92 lines
3.3 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import parse_duration
  5. class BYUtvIE(InfoExtractor):
  6. _VALID_URL = r'https?://(?:www\.)?byutv\.org/(?:watch|player)/(?!event/)(?P<id>[0-9a-f-]+)(?:/(?P<display_id>[^/?#&]+))?'
  7. _TESTS = [{
  8. # ooyalaVOD
  9. 'url': 'http://www.byutv.org/watch/6587b9a3-89d2-42a6-a7f7-fd2f81840a7d/studio-c-season-5-episode-5',
  10. 'info_dict': {
  11. 'id': 'ZvanRocTpW-G5_yZFeltTAMv6jxOU9KH',
  12. 'display_id': 'studio-c-season-5-episode-5',
  13. 'ext': 'mp4',
  14. 'title': 'Season 5 Episode 5',
  15. 'description': 'md5:1d31dc18ef4f075b28f6a65937d22c65',
  16. 'thumbnail': r're:^https?://.*',
  17. 'duration': 1486.486,
  18. },
  19. 'params': {
  20. 'skip_download': True,
  21. },
  22. 'add_ie': ['Ooyala'],
  23. }, {
  24. # dvr
  25. 'url': 'https://www.byutv.org/player/8f1dab9b-b243-47c8-b525-3e2d021a3451/byu-softball-pacific-vs-byu-41219---game-2',
  26. 'info_dict': {
  27. 'id': '8f1dab9b-b243-47c8-b525-3e2d021a3451',
  28. 'display_id': 'byu-softball-pacific-vs-byu-41219---game-2',
  29. 'ext': 'mp4',
  30. 'title': 'Pacific vs. BYU (4/12/19)',
  31. 'description': 'md5:1ac7b57cb9a78015910a4834790ce1f3',
  32. 'duration': 11645,
  33. },
  34. 'params': {
  35. 'skip_download': True
  36. },
  37. }, {
  38. 'url': 'http://www.byutv.org/watch/6587b9a3-89d2-42a6-a7f7-fd2f81840a7d',
  39. 'only_matching': True,
  40. }, {
  41. 'url': 'https://www.byutv.org/player/27741493-dc83-40b0-8420-e7ae38a2ae98/byu-football-toledo-vs-byu-93016?listid=4fe0fee5-0d3c-4a29-b725-e4948627f472&listindex=0&q=toledo',
  42. 'only_matching': True,
  43. }]
  44. def _real_extract(self, url):
  45. mobj = re.match(self._VALID_URL, url)
  46. video_id = mobj.group('id')
  47. display_id = mobj.group('display_id') or video_id
  48. info = self._download_json(
  49. 'https://api.byutv.org/api3/catalog/getvideosforcontent',
  50. display_id, query={
  51. 'contentid': video_id,
  52. 'channel': 'byutv',
  53. 'x-byutv-context': 'web$US',
  54. }, headers={
  55. 'x-byutv-context': 'web$US',
  56. 'x-byutv-platformkey': 'xsaaw9c7y5',
  57. })
  58. ep = info.get('ooyalaVOD')
  59. if ep:
  60. return {
  61. '_type': 'url_transparent',
  62. 'ie_key': 'Ooyala',
  63. 'url': 'ooyala:%s' % ep['providerId'],
  64. 'id': video_id,
  65. 'display_id': display_id,
  66. 'title': ep.get('title'),
  67. 'description': ep.get('description'),
  68. 'thumbnail': ep.get('imageThumbnail'),
  69. }
  70. ep = info['dvr']
  71. title = ep['title']
  72. formats = self._extract_m3u8_formats(
  73. ep['videoUrl'], video_id, 'mp4', entry_protocol='m3u8_native',
  74. m3u8_id='hls')
  75. self._sort_formats(formats)
  76. return {
  77. 'id': video_id,
  78. 'display_id': display_id,
  79. 'title': title,
  80. 'description': ep.get('description'),
  81. 'thumbnail': ep.get('imageThumbnail'),
  82. 'duration': parse_duration(ep.get('length')),
  83. 'formats': formats,
  84. }