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
  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:5438d33774b6bdc662f9485a340401cc',
  14. 'title': 'Season 5 Episode 5',
  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'])