]>
Commit | Line | Data |
---|---|---|
6949d810 PH |
1 | from __future__ import unicode_literals |
2 | ||
6949d810 PH |
3 | import re |
4 | ||
5 | from .common import InfoExtractor | |
5c802bac | 6 | from ..utils import ExtractorError |
6949d810 PH |
7 | |
8 | ||
9 | class BYUtvIE(InfoExtractor): | |
f6ba581f | 10 | _VALID_URL = r'https?://(?:www\.)?byutv\.org/watch/(?!event/)(?P<id>[0-9a-f-]+)(?:/(?P<display_id>[^/?#&]+))?' |
6d2549fb | 11 | _TESTS = [{ |
7009a904 | 12 | 'url': 'http://www.byutv.org/watch/6587b9a3-89d2-42a6-a7f7-fd2f81840a7d/studio-c-season-5-episode-5', |
6949d810 | 13 | 'info_dict': { |
6d2549fb S |
14 | 'id': '6587b9a3-89d2-42a6-a7f7-fd2f81840a7d', |
15 | 'display_id': 'studio-c-season-5-episode-5', | |
6949d810 | 16 | 'ext': 'mp4', |
7009a904 | 17 | 'title': 'Season 5 Episode 5', |
6d2549fb | 18 | 'description': 'md5:e07269172baff037f8e8bf9956bc9747', |
cce9d15d | 19 | 'thumbnail': 're:^https?://.*\.jpg$', |
53e06b25 | 20 | 'duration': 1486.486, |
6949d810 | 21 | }, |
688c634b | 22 | 'params': { |
23 | 'skip_download': True, | |
24 | }, | |
277c7465 | 25 | 'add_ie': ['Ooyala'], |
6d2549fb S |
26 | }, { |
27 | 'url': 'http://www.byutv.org/watch/6587b9a3-89d2-42a6-a7f7-fd2f81840a7d', | |
28 | 'only_matching': True, | |
29 | }] | |
6949d810 PH |
30 | |
31 | def _real_extract(self, url): | |
6d2549fb S |
32 | mobj = re.match(self._VALID_URL, url) |
33 | video_id = mobj.group('id') | |
34 | display_id = mobj.group('display_id') or video_id | |
6949d810 | 35 | |
6d2549fb | 36 | webpage = self._download_webpage(url, display_id) |
6949d810 PH |
37 | episode_code = self._search_regex( |
38 | r'(?s)episode:(.*?\}),\s*\n', webpage, 'episode information') | |
4da45169 DR |
39 | |
40 | ep = self._parse_json( | |
6d2549fb | 41 | episode_code, display_id, transform_source=lambda s: |
4da45169 | 42 | re.sub(r'(\n\s+)([a-zA-Z]+):\s+\'(.*?)\'', r'\1"\2": "\3"', s)) |
6949d810 | 43 | |
6d2549fb | 44 | if ep['providerType'] != 'Ooyala': |
6949d810 | 45 | raise ExtractorError('Unsupported provider %s' % ep['provider']) |
6d2549fb S |
46 | |
47 | return { | |
48 | '_type': 'url_transparent', | |
49 | 'ie_key': 'Ooyala', | |
50 | 'url': 'ooyala:%s' % ep['providerId'], | |
51 | 'id': video_id, | |
52 | 'display_id': display_id, | |
53 | 'title': ep['title'], | |
54 | 'description': ep.get('description'), | |
55 | 'thumbnail': ep.get('imageThumbnail'), | |
56 | } | |
f6ba581f S |
57 | |
58 | ||
59 | class BYUtvEventIE(InfoExtractor): | |
60 | _VALID_URL = r'https?://(?:www\.)?byutv\.org/watch/event/(?P<id>[0-9a-f-]+)' | |
61 | _TEST = { | |
62 | 'url': 'http://www.byutv.org/watch/event/29941b9b-8bf6-48d2-aebf-7a87add9e34b', | |
63 | 'info_dict': { | |
64 | 'id': '29941b9b-8bf6-48d2-aebf-7a87add9e34b', | |
65 | 'ext': 'mp4', | |
66 | 'title': 'Toledo vs. BYU (9/30/16)', | |
67 | }, | |
68 | 'params': { | |
69 | 'skip_download': True, | |
70 | }, | |
71 | 'add_ie': ['Ooyala'], | |
72 | } | |
73 | ||
74 | def _real_extract(self, url): | |
75 | video_id = self._match_id(url) | |
76 | ||
77 | webpage = self._download_webpage(url, video_id) | |
78 | ||
79 | ooyala_id = self._search_regex( | |
80 | r'providerId\s*:\s*(["\'])(?P<id>(?:(?!\1).)+)\1', | |
81 | webpage, 'ooyala id', group='id') | |
82 | ||
83 | title = self._search_regex( | |
84 | r'class=["\']description["\'][^>]*>\s*<h1>([^<]+)</h1>', webpage, | |
85 | 'title').strip() | |
86 | ||
87 | return { | |
88 | '_type': 'url_transparent', | |
89 | 'ie_key': 'Ooyala', | |
90 | 'url': 'ooyala:%s' % ooyala_id, | |
91 | 'id': video_id, | |
92 | 'title': title, | |
93 | } |