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.

93 lines
3.0 KiB

11 years ago
  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import ExtractorError
  5. class BYUtvIE(InfoExtractor):
  6. _VALID_URL = r'https?://(?:www\.)?byutv\.org/watch/(?!event/)(?P<id>[0-9a-f-]+)(?:/(?P<display_id>[^/?#&]+))?'
  7. _TESTS = [{
  8. 'url': 'http://www.byutv.org/watch/6587b9a3-89d2-42a6-a7f7-fd2f81840a7d/studio-c-season-5-episode-5',
  9. 'info_dict': {
  10. 'id': '6587b9a3-89d2-42a6-a7f7-fd2f81840a7d',
  11. 'display_id': 'studio-c-season-5-episode-5',
  12. 'ext': 'mp4',
  13. 'title': 'Season 5 Episode 5',
  14. 'description': 'md5:e07269172baff037f8e8bf9956bc9747',
  15. 'thumbnail': r're:^https?://.*\.jpg$',
  16. 'duration': 1486.486,
  17. },
  18. 'params': {
  19. 'skip_download': True,
  20. },
  21. 'add_ie': ['Ooyala'],
  22. }, {
  23. 'url': 'http://www.byutv.org/watch/6587b9a3-89d2-42a6-a7f7-fd2f81840a7d',
  24. 'only_matching': True,
  25. }]
  26. def _real_extract(self, url):
  27. mobj = re.match(self._VALID_URL, url)
  28. video_id = mobj.group('id')
  29. display_id = mobj.group('display_id') or video_id
  30. webpage = self._download_webpage(url, display_id)
  31. episode_code = self._search_regex(
  32. r'(?s)episode:(.*?\}),\s*\n', webpage, 'episode information')
  33. ep = self._parse_json(
  34. episode_code, display_id, transform_source=lambda s:
  35. re.sub(r'(\n\s+)([a-zA-Z]+):\s+\'(.*?)\'', r'\1"\2": "\3"', s))
  36. if ep['providerType'] != 'Ooyala':
  37. raise ExtractorError('Unsupported provider %s' % ep['provider'])
  38. return {
  39. '_type': 'url_transparent',
  40. 'ie_key': 'Ooyala',
  41. 'url': 'ooyala:%s' % ep['providerId'],
  42. 'id': video_id,
  43. 'display_id': display_id,
  44. 'title': ep['title'],
  45. 'description': ep.get('description'),
  46. 'thumbnail': ep.get('imageThumbnail'),
  47. }
  48. class BYUtvEventIE(InfoExtractor):
  49. _VALID_URL = r'https?://(?:www\.)?byutv\.org/watch/event/(?P<id>[0-9a-f-]+)'
  50. _TEST = {
  51. 'url': 'http://www.byutv.org/watch/event/29941b9b-8bf6-48d2-aebf-7a87add9e34b',
  52. 'info_dict': {
  53. 'id': '29941b9b-8bf6-48d2-aebf-7a87add9e34b',
  54. 'ext': 'mp4',
  55. 'title': 'Toledo vs. BYU (9/30/16)',
  56. },
  57. 'params': {
  58. 'skip_download': True,
  59. },
  60. 'add_ie': ['Ooyala'],
  61. }
  62. def _real_extract(self, url):
  63. video_id = self._match_id(url)
  64. webpage = self._download_webpage(url, video_id)
  65. ooyala_id = self._search_regex(
  66. r'providerId\s*:\s*(["\'])(?P<id>(?:(?!\1).)+)\1',
  67. webpage, 'ooyala id', group='id')
  68. title = self._search_regex(
  69. r'class=["\']description["\'][^>]*>\s*<h1>([^<]+)</h1>', webpage,
  70. 'title').strip()
  71. return {
  72. '_type': 'url_transparent',
  73. 'ie_key': 'Ooyala',
  74. 'url': 'ooyala:%s' % ooyala_id,
  75. 'id': video_id,
  76. 'title': title,
  77. }