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.

48 lines
1.6 KiB

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