]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/byutv.py
[byutv] Add support (Fixes #2612)
[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
7from ..utils import (
8 ExtractorError,
9)
10
11
12class BYUtvIE(InfoExtractor):
13 _VALID_URL = r'^https?://(?:www\.)?byutv.org/watch/[0-9a-f-]+/(?P<video_id>[^/?#]+)'
14 _TEST = {
15 'url': 'http://www.byutv.org/watch/44e80f7b-e3ba-43ba-8c51-b1fd96c94a79/granite-flats-talking',
16 'info_dict': {
17 'id': 'granite-flats-talking',
18 'ext': 'mp4',
19 'description': 'md5:1a7ae3e153359b7cc355ef3963441e5f',
20 'title': 'Talking',
21 'thumbnail': 're:^https?://.*promo.*'
22 },
23 'params': {
24 'skip_download': True,
25 }
26 }
27
28 def _real_extract(self, url):
29 mobj = re.match(self._VALID_URL, url)
30 video_id = mobj.group('video_id')
31
32 webpage = self._download_webpage(url, video_id)
33 episode_code = self._search_regex(
34 r'(?s)episode:(.*?\}),\s*\n', webpage, 'episode information')
35 episode_json = re.sub(
36 r'(\n\s+)([a-zA-Z]+):\s+\'(.*?)\'', r'\1"\2": "\3"', episode_code)
37 ep = json.loads(episode_json)
38
39 if ep['providerType'] == 'Ooyala':
40 return {
41 '_type': 'url_transparent',
42 'ie_key': 'Ooyala',
43 'url': 'ooyala:%s' % ep['providerId'],
44 'id': video_id,
45 'title': ep['title'],
46 'description': ep.get('description'),
47 'thumbnail': ep.get('imageThumbnail'),
48 }
49 else:
50 raise ExtractorError('Unsupported provider %s' % ep['provider'])