]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/byutv.py
Tidy the changelog.
[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/6587b9a3-89d2-42a6-a7f7-fd2f81840a7d/studio-c-season-5-episode-5',
14 'info_dict': {
15 'id': 'studio-c-season-5-episode-5',
16 'ext': 'mp4',
17 'description': 'md5:5438d33774b6bdc662f9485a340401cc',
18 'title': 'Season 5 Episode 5',
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'])