]> git.bitcoin.ninja Git - youtube-dl/blob - youtube_dl/extractor/byutv.py
[README.md] Make download URLs consistent
[youtube-dl] / 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         'md5': '05850eb8c749e2ee05ad5a1c34668493',
15         'info_dict': {
16             'id': 'studio-c-season-5-episode-5',
17             'ext': 'mp4',
18             'description': 'md5:e07269172baff037f8e8bf9956bc9747',
19             'title': 'Season 5 Episode 5',
20             'thumbnail': 're:^https?://.*\.jpg$',
21             'duration': 1486.486,
22         },
23         'params': {
24             'skip_download': True,
25         },
26         'add_ie': ['Ooyala'],
27     }
28
29     def _real_extract(self, url):
30         mobj = re.match(self._VALID_URL, url)
31         video_id = mobj.group('video_id')
32
33         webpage = self._download_webpage(url, video_id)
34         episode_code = self._search_regex(
35             r'(?s)episode:(.*?\}),\s*\n', webpage, 'episode information')
36         episode_json = re.sub(
37             r'(\n\s+)([a-zA-Z]+):\s+\'(.*?)\'', r'\1"\2": "\3"', episode_code)
38         ep = json.loads(episode_json)
39
40         if ep['providerType'] == 'Ooyala':
41             return {
42                 '_type': 'url_transparent',
43                 'ie_key': 'Ooyala',
44                 'url': 'ooyala:%s' % ep['providerId'],
45                 'id': video_id,
46                 'title': ep['title'],
47                 'description': ep.get('description'),
48                 'thumbnail': ep.get('imageThumbnail'),
49             }
50         else:
51             raise ExtractorError('Unsupported provider %s' % ep['provider'])