]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/byutv.py
[ooyala] use api v2 to reduce requests for format extraction
[yt-dlp.git] / youtube_dl / extractor / byutv.py
CommitLineData
6949d810
PH
1from __future__ import unicode_literals
2
3import json
4import re
5
6from .common import InfoExtractor
5c802bac 7from ..utils import ExtractorError
6949d810
PH
8
9
10class BYUtvIE(InfoExtractor):
11 _VALID_URL = r'^https?://(?:www\.)?byutv.org/watch/[0-9a-f-]+/(?P<video_id>[^/?#]+)'
12 _TEST = {
7009a904 13 'url': 'http://www.byutv.org/watch/6587b9a3-89d2-42a6-a7f7-fd2f81840a7d/studio-c-season-5-episode-5',
6949d810 14 'info_dict': {
7009a904 15 'id': 'studio-c-season-5-episode-5',
6949d810 16 'ext': 'mp4',
cce9d15d 17 'description': 'md5:e07269172baff037f8e8bf9956bc9747',
7009a904 18 'title': 'Season 5 Episode 5',
cce9d15d 19 'thumbnail': 're:^https?://.*\.jpg$',
53e06b25 20 'duration': 1486.486,
6949d810
PH
21 },
22 'params': {
23 'skip_download': True,
24 }
25 }
26
27 def _real_extract(self, url):
28 mobj = re.match(self._VALID_URL, url)
29 video_id = mobj.group('video_id')
30
31 webpage = self._download_webpage(url, video_id)
32 episode_code = self._search_regex(
33 r'(?s)episode:(.*?\}),\s*\n', webpage, 'episode information')
34 episode_json = re.sub(
35 r'(\n\s+)([a-zA-Z]+):\s+\'(.*?)\'', r'\1"\2": "\3"', episode_code)
36 ep = json.loads(episode_json)
37
38 if ep['providerType'] == 'Ooyala':
39 return {
40 '_type': 'url_transparent',
41 'ie_key': 'Ooyala',
42 'url': 'ooyala:%s' % ep['providerId'],
43 'id': video_id,
44 'title': ep['title'],
45 'description': ep.get('description'),
46 'thumbnail': ep.get('imageThumbnail'),
47 }
48 else:
49 raise ExtractorError('Unsupported provider %s' % ep['provider'])