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.

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