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.

58 lines
2.1 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. class BYUtvIE(InfoExtractor):
  5. _VALID_URL = r'https?://(?:www\.)?byutv\.org/(?:watch|player)/(?!event/)(?P<id>[0-9a-f-]+)(?:/(?P<display_id>[^/?#&]+))?'
  6. _TESTS = [{
  7. 'url': 'http://www.byutv.org/watch/6587b9a3-89d2-42a6-a7f7-fd2f81840a7d/studio-c-season-5-episode-5',
  8. 'info_dict': {
  9. 'id': 'ZvanRocTpW-G5_yZFeltTAMv6jxOU9KH',
  10. 'display_id': 'studio-c-season-5-episode-5',
  11. 'ext': 'mp4',
  12. 'title': 'Season 5 Episode 5',
  13. 'description': 'md5:1d31dc18ef4f075b28f6a65937d22c65',
  14. 'thumbnail': r're:^https?://.*',
  15. 'duration': 1486.486,
  16. },
  17. 'params': {
  18. 'skip_download': True,
  19. },
  20. 'add_ie': ['Ooyala'],
  21. }, {
  22. 'url': 'http://www.byutv.org/watch/6587b9a3-89d2-42a6-a7f7-fd2f81840a7d',
  23. 'only_matching': True,
  24. }, {
  25. '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',
  26. 'only_matching': True,
  27. }]
  28. def _real_extract(self, url):
  29. mobj = re.match(self._VALID_URL, url)
  30. video_id = mobj.group('id')
  31. display_id = mobj.group('display_id') or video_id
  32. ep = self._download_json(
  33. 'https://api.byutv.org/api3/catalog/getvideosforcontent', video_id,
  34. query={
  35. 'contentid': video_id,
  36. 'channel': 'byutv',
  37. 'x-byutv-context': 'web$US',
  38. }, headers={
  39. 'x-byutv-context': 'web$US',
  40. 'x-byutv-platformkey': 'xsaaw9c7y5',
  41. })['ooyalaVOD']
  42. return {
  43. '_type': 'url_transparent',
  44. 'ie_key': 'Ooyala',
  45. 'url': 'ooyala:%s' % ep['providerId'],
  46. 'id': video_id,
  47. 'display_id': display_id,
  48. 'title': ep.get('title'),
  49. 'description': ep.get('description'),
  50. 'thumbnail': ep.get('imageThumbnail'),
  51. }