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.

50 lines
1.6 KiB

  1. from __future__ import unicode_literals
  2. import json
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. ExtractorError,
  7. )
  8. class BYUtvIE(InfoExtractor):
  9. _VALID_URL = r'^https?://(?:www\.)?byutv.org/watch/[0-9a-f-]+/(?P<video_id>[^/?#]+)'
  10. _TEST = {
  11. 'url': 'http://www.byutv.org/watch/44e80f7b-e3ba-43ba-8c51-b1fd96c94a79/granite-flats-talking',
  12. 'info_dict': {
  13. 'id': 'granite-flats-talking',
  14. 'ext': 'mp4',
  15. 'description': 'md5:1a7ae3e153359b7cc355ef3963441e5f',
  16. 'title': 'Talking',
  17. 'thumbnail': 're:^https?://.*promo.*'
  18. },
  19. 'params': {
  20. 'skip_download': True,
  21. }
  22. }
  23. def _real_extract(self, url):
  24. mobj = re.match(self._VALID_URL, url)
  25. video_id = mobj.group('video_id')
  26. webpage = self._download_webpage(url, video_id)
  27. episode_code = self._search_regex(
  28. r'(?s)episode:(.*?\}),\s*\n', webpage, 'episode information')
  29. episode_json = re.sub(
  30. r'(\n\s+)([a-zA-Z]+):\s+\'(.*?)\'', r'\1"\2": "\3"', episode_code)
  31. ep = json.loads(episode_json)
  32. if ep['providerType'] == 'Ooyala':
  33. return {
  34. '_type': 'url_transparent',
  35. 'ie_key': 'Ooyala',
  36. 'url': 'ooyala:%s' % ep['providerId'],
  37. 'id': video_id,
  38. 'title': ep['title'],
  39. 'description': ep.get('description'),
  40. 'thumbnail': ep.get('imageThumbnail'),
  41. }
  42. else:
  43. raise ExtractorError('Unsupported provider %s' % ep['provider'])