]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/byutv.py
debian/{compat,control}: Relutanctly update compat to 11.
[youtubedl] / youtube_dl / extractor / byutv.py
1 from __future__ import unicode_literals
2
3 import re
4
5 from .common import InfoExtractor
6
7
8 class BYUtvIE(InfoExtractor):
9 _VALID_URL = r'https?://(?:www\.)?byutv\.org/(?:watch|player)/(?!event/)(?P<id>[0-9a-f-]+)(?:/(?P<display_id>[^/?#&]+))?'
10 _TESTS = [{
11 'url': 'http://www.byutv.org/watch/6587b9a3-89d2-42a6-a7f7-fd2f81840a7d/studio-c-season-5-episode-5',
12 'info_dict': {
13 'id': 'ZvanRocTpW-G5_yZFeltTAMv6jxOU9KH',
14 'display_id': 'studio-c-season-5-episode-5',
15 'ext': 'mp4',
16 'title': 'Season 5 Episode 5',
17 'description': 'md5:1d31dc18ef4f075b28f6a65937d22c65',
18 'thumbnail': r're:^https?://.*',
19 'duration': 1486.486,
20 },
21 'params': {
22 'skip_download': True,
23 },
24 'add_ie': ['Ooyala'],
25 }, {
26 'url': 'http://www.byutv.org/watch/6587b9a3-89d2-42a6-a7f7-fd2f81840a7d',
27 'only_matching': True,
28 }, {
29 'url': 'https://www.byutv.org/player/27741493-dc83-40b0-8420-e7ae38a2ae98/byu-football-toledo-vs-byu-93016?listid=4fe0fee5-0d3c-4a29-b725-e4948627f472&listindex=0&q=toledo',
30 'only_matching': True,
31 }]
32
33 def _real_extract(self, url):
34 mobj = re.match(self._VALID_URL, url)
35 video_id = mobj.group('id')
36 display_id = mobj.group('display_id') or video_id
37
38 ep = self._download_json(
39 'https://api.byutv.org/api3/catalog/getvideosforcontent', video_id,
40 query={
41 'contentid': video_id,
42 'channel': 'byutv',
43 'x-byutv-context': 'web$US',
44 }, headers={
45 'x-byutv-context': 'web$US',
46 'x-byutv-platformkey': 'xsaaw9c7y5',
47 })['ooyalaVOD']
48
49 return {
50 '_type': 'url_transparent',
51 'ie_key': 'Ooyala',
52 'url': 'ooyala:%s' % ep['providerId'],
53 'id': video_id,
54 'display_id': display_id,
55 'title': ep.get('title'),
56 'description': ep.get('description'),
57 'thumbnail': ep.get('imageThumbnail'),
58 }