]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/byutv.py
debian/patches: Remove patch cherry-picked from upstream.
[youtubedl] / youtube_dl / extractor / byutv.py
1 from __future__ import unicode_literals
2
3 import re
4
5 from .common import InfoExtractor
6 from ..utils import parse_duration
7
8
9 class BYUtvIE(InfoExtractor):
10 _VALID_URL = r'https?://(?:www\.)?byutv\.org/(?:watch|player)/(?!event/)(?P<id>[0-9a-f-]+)(?:/(?P<display_id>[^/?#&]+))?'
11 _TESTS = [{
12 # ooyalaVOD
13 'url': 'http://www.byutv.org/watch/6587b9a3-89d2-42a6-a7f7-fd2f81840a7d/studio-c-season-5-episode-5',
14 'info_dict': {
15 'id': 'ZvanRocTpW-G5_yZFeltTAMv6jxOU9KH',
16 'display_id': 'studio-c-season-5-episode-5',
17 'ext': 'mp4',
18 'title': 'Season 5 Episode 5',
19 'description': 'md5:1d31dc18ef4f075b28f6a65937d22c65',
20 'thumbnail': r're:^https?://.*',
21 'duration': 1486.486,
22 },
23 'params': {
24 'skip_download': True,
25 },
26 'add_ie': ['Ooyala'],
27 }, {
28 # dvr
29 'url': 'https://www.byutv.org/player/8f1dab9b-b243-47c8-b525-3e2d021a3451/byu-softball-pacific-vs-byu-41219---game-2',
30 'info_dict': {
31 'id': '8f1dab9b-b243-47c8-b525-3e2d021a3451',
32 'display_id': 'byu-softball-pacific-vs-byu-41219---game-2',
33 'ext': 'mp4',
34 'title': 'Pacific vs. BYU (4/12/19)',
35 'description': 'md5:1ac7b57cb9a78015910a4834790ce1f3',
36 'duration': 11645,
37 },
38 'params': {
39 'skip_download': True
40 },
41 }, {
42 'url': 'http://www.byutv.org/watch/6587b9a3-89d2-42a6-a7f7-fd2f81840a7d',
43 'only_matching': True,
44 }, {
45 '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',
46 'only_matching': True,
47 }]
48
49 def _real_extract(self, url):
50 mobj = re.match(self._VALID_URL, url)
51 video_id = mobj.group('id')
52 display_id = mobj.group('display_id') or video_id
53
54 info = self._download_json(
55 'https://api.byutv.org/api3/catalog/getvideosforcontent',
56 display_id, query={
57 'contentid': video_id,
58 'channel': 'byutv',
59 'x-byutv-context': 'web$US',
60 }, headers={
61 'x-byutv-context': 'web$US',
62 'x-byutv-platformkey': 'xsaaw9c7y5',
63 })
64
65 ep = info.get('ooyalaVOD')
66 if ep:
67 return {
68 '_type': 'url_transparent',
69 'ie_key': 'Ooyala',
70 'url': 'ooyala:%s' % ep['providerId'],
71 'id': video_id,
72 'display_id': display_id,
73 'title': ep.get('title'),
74 'description': ep.get('description'),
75 'thumbnail': ep.get('imageThumbnail'),
76 }
77
78 ep = info['dvr']
79 title = ep['title']
80 formats = self._extract_m3u8_formats(
81 ep['videoUrl'], video_id, 'mp4', entry_protocol='m3u8_native',
82 m3u8_id='hls')
83 self._sort_formats(formats)
84 return {
85 'id': video_id,
86 'display_id': display_id,
87 'title': title,
88 'description': ep.get('description'),
89 'thumbnail': ep.get('imageThumbnail'),
90 'duration': parse_duration(ep.get('length')),
91 'formats': formats,
92 }