]>
Commit | Line | Data |
---|---|---|
6949d810 PH |
1 | from __future__ import unicode_literals |
2 | ||
6949d810 PH |
3 | |
4 | from .common import InfoExtractor | |
df63cafe S |
5 | from ..utils import ( |
6 | determine_ext, | |
7 | merge_dicts, | |
8 | parse_duration, | |
9 | url_or_none, | |
10 | ) | |
6949d810 PH |
11 | |
12 | ||
13 | class BYUtvIE(InfoExtractor): | |
c8be7d5f | 14 | _VALID_URL = r'https?://(?:www\.)?byutv\.org/(?:watch|player)/(?!event/)(?P<id>[0-9a-f-]+)(?:/(?P<display_id>[^/?#&]+))?' |
6d2549fb | 15 | _TESTS = [{ |
0db2b275 | 16 | # ooyalaVOD |
7009a904 | 17 | 'url': 'http://www.byutv.org/watch/6587b9a3-89d2-42a6-a7f7-fd2f81840a7d/studio-c-season-5-episode-5', |
6949d810 | 18 | 'info_dict': { |
c8be7d5f | 19 | 'id': 'ZvanRocTpW-G5_yZFeltTAMv6jxOU9KH', |
6d2549fb | 20 | 'display_id': 'studio-c-season-5-episode-5', |
6949d810 | 21 | 'ext': 'mp4', |
7009a904 | 22 | 'title': 'Season 5 Episode 5', |
c8be7d5f S |
23 | 'description': 'md5:1d31dc18ef4f075b28f6a65937d22c65', |
24 | 'thumbnail': r're:^https?://.*', | |
53e06b25 | 25 | 'duration': 1486.486, |
6949d810 | 26 | }, |
688c634b | 27 | 'params': { |
28 | 'skip_download': True, | |
29 | }, | |
277c7465 | 30 | 'add_ie': ['Ooyala'], |
ab116745 | 31 | }, { |
0db2b275 S |
32 | # dvr |
33 | 'url': 'https://www.byutv.org/player/8f1dab9b-b243-47c8-b525-3e2d021a3451/byu-softball-pacific-vs-byu-41219---game-2', | |
ab116745 | 34 | 'info_dict': { |
0db2b275 S |
35 | 'id': '8f1dab9b-b243-47c8-b525-3e2d021a3451', |
36 | 'display_id': 'byu-softball-pacific-vs-byu-41219---game-2', | |
ab116745 | 37 | 'ext': 'mp4', |
0db2b275 S |
38 | 'title': 'Pacific vs. BYU (4/12/19)', |
39 | 'description': 'md5:1ac7b57cb9a78015910a4834790ce1f3', | |
40 | 'duration': 11645, | |
ab116745 MT |
41 | }, |
42 | 'params': { | |
43 | 'skip_download': True | |
44 | }, | |
6d2549fb S |
45 | }, { |
46 | 'url': 'http://www.byutv.org/watch/6587b9a3-89d2-42a6-a7f7-fd2f81840a7d', | |
47 | 'only_matching': True, | |
c8be7d5f S |
48 | }, { |
49 | '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', | |
50 | 'only_matching': True, | |
6d2549fb | 51 | }] |
6949d810 PH |
52 | |
53 | def _real_extract(self, url): | |
5ad28e7f | 54 | mobj = self._match_valid_url(url) |
6d2549fb | 55 | video_id = mobj.group('id') |
0db2b275 | 56 | display_id = mobj.group('display_id') or video_id |
6949d810 | 57 | |
df63cafe | 58 | video = self._download_json( |
0db2b275 S |
59 | 'https://api.byutv.org/api3/catalog/getvideosforcontent', |
60 | display_id, query={ | |
c8be7d5f | 61 | 'contentid': video_id, |
6bf9c28b RA |
62 | 'channel': 'byutv', |
63 | 'x-byutv-context': 'web$US', | |
c8be7d5f | 64 | }, headers={ |
6bf9c28b | 65 | 'x-byutv-context': 'web$US', |
c8be7d5f | 66 | 'x-byutv-platformkey': 'xsaaw9c7y5', |
ab116745 | 67 | }) |
6d2549fb | 68 | |
df63cafe | 69 | ep = video.get('ooyalaVOD') |
ab116745 MT |
70 | if ep: |
71 | return { | |
72 | '_type': 'url_transparent', | |
73 | 'ie_key': 'Ooyala', | |
74 | 'url': 'ooyala:%s' % ep['providerId'], | |
75 | 'id': video_id, | |
0db2b275 | 76 | 'display_id': display_id, |
ab116745 MT |
77 | 'title': ep.get('title'), |
78 | 'description': ep.get('description'), | |
79 | 'thumbnail': ep.get('imageThumbnail'), | |
80 | } | |
0db2b275 | 81 | |
df63cafe S |
82 | info = {} |
83 | formats = [] | |
64a5cf79 | 84 | subtitles = {} |
df63cafe S |
85 | for format_id, ep in video.items(): |
86 | if not isinstance(ep, dict): | |
87 | continue | |
88 | video_url = url_or_none(ep.get('videoUrl')) | |
89 | if not video_url: | |
90 | continue | |
91 | ext = determine_ext(video_url) | |
92 | if ext == 'm3u8': | |
64a5cf79 | 93 | m3u8_fmts, m3u8_subs = self._extract_m3u8_formats_and_subtitles( |
df63cafe | 94 | video_url, video_id, 'mp4', entry_protocol='m3u8_native', |
64a5cf79 F |
95 | m3u8_id='hls', fatal=False) |
96 | formats.extend(m3u8_fmts) | |
97 | subtitles = self._merge_subtitles(subtitles, m3u8_subs) | |
df63cafe | 98 | elif ext == 'mpd': |
64a5cf79 F |
99 | mpd_fmts, mpd_subs = self._extract_mpd_formats_and_subtitles( |
100 | video_url, video_id, mpd_id='dash', fatal=False) | |
101 | formats.extend(mpd_fmts) | |
102 | subtitles = self._merge_subtitles(subtitles, mpd_subs) | |
df63cafe S |
103 | else: |
104 | formats.append({ | |
105 | 'url': video_url, | |
106 | 'format_id': format_id, | |
107 | }) | |
108 | merge_dicts(info, { | |
109 | 'title': ep.get('title'), | |
110 | 'description': ep.get('description'), | |
111 | 'thumbnail': ep.get('imageThumbnail'), | |
112 | 'duration': parse_duration(ep.get('length')), | |
113 | }) | |
0db2b275 | 114 | self._sort_formats(formats) |
df63cafe S |
115 | |
116 | return merge_dicts(info, { | |
0db2b275 S |
117 | 'id': video_id, |
118 | 'display_id': display_id, | |
df63cafe | 119 | 'title': display_id, |
0db2b275 | 120 | 'formats': formats, |
64a5cf79 | 121 | 'subtitles': subtitles, |
df63cafe | 122 | }) |