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.

51 lines
1.7 KiB

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/6587b9a3-89d2-42a6-a7f7-fd2f81840a7d/studio-c-season-5-episode-5',
  10. 'md5': '05850eb8c749e2ee05ad5a1c34668493',
  11. 'info_dict': {
  12. 'id': 'studio-c-season-5-episode-5',
  13. 'ext': 'mp4',
  14. 'description': 'md5:e07269172baff037f8e8bf9956bc9747',
  15. 'title': 'Season 5 Episode 5',
  16. 'thumbnail': 're:^https?://.*\.jpg$',
  17. 'duration': 1486.486,
  18. },
  19. 'params': {
  20. 'skip_download': True,
  21. },
  22. 'add_ie': ['Ooyala'],
  23. }
  24. def _real_extract(self, url):
  25. mobj = re.match(self._VALID_URL, url)
  26. video_id = mobj.group('video_id')
  27. webpage = self._download_webpage(url, video_id)
  28. episode_code = self._search_regex(
  29. r'(?s)episode:(.*?\}),\s*\n', webpage, 'episode information')
  30. episode_json = re.sub(
  31. r'(\n\s+)([a-zA-Z]+):\s+\'(.*?)\'', r'\1"\2": "\3"', episode_code)
  32. ep = json.loads(episode_json)
  33. if ep['providerType'] == 'Ooyala':
  34. return {
  35. '_type': 'url_transparent',
  36. 'ie_key': 'Ooyala',
  37. 'url': 'ooyala:%s' % ep['providerId'],
  38. 'id': video_id,
  39. 'title': ep['title'],
  40. 'description': ep.get('description'),
  41. 'thumbnail': ep.get('imageThumbnail'),
  42. }
  43. else:
  44. raise ExtractorError('Unsupported provider %s' % ep['provider'])