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