]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/mediasite.py
2 from __future__
import unicode_literals
7 from . common
import InfoExtractor
23 class MediasiteIE ( InfoExtractor
):
24 _VALID_URL
= r
'(?xi)https?://[^/]+/Mediasite/(?:Play|Showcase/(?:default|livebroadcast)/Presentation)/(?P<id>[0-9a-f]{32,34})(?P<query>\?[^#]+|)'
27 'url' : 'https://hitsmediaweb.h-its.org/mediasite/Play/2db6c271681e4f199af3c60d1f82869b1d' ,
29 'id' : '2db6c271681e4f199af3c60d1f82869b1d' ,
31 'title' : 'Lecture: Tuesday, September 20, 2016 - Sir Andrew Wiles' ,
32 'description' : 'Sir Andrew Wiles: “Equations in arithmetic” \\ n \\ nI will describe some of the interactions between modern number theory and the problem of solving equations in rational numbers or integers \\ u0027.' ,
33 'timestamp' : 1474268400.0 ,
34 'upload_date' : '20160919' ,
38 'url' : 'http://mediasite.uib.no/Mediasite/Play/90bb363295d945d6b548c867d01181361d?catalog=a452b7df-9ae1-46b7-a3ba-aceeb285f3eb' ,
40 'id' : '90bb363295d945d6b548c867d01181361d' ,
42 'upload_date' : '20150429' ,
43 'title' : '5) IT-forum 2015-Dag 1 - Dungbeetle - How and why Rain created a tiny bug tracker for Unity' ,
44 'timestamp' : 1430311380.0 ,
48 'url' : 'https://collegerama.tudelft.nl/Mediasite/Play/585a43626e544bdd97aeb71a0ec907a01d' ,
49 'md5' : '481fda1c11f67588c0d9d8fbdced4e39' ,
51 'id' : '585a43626e544bdd97aeb71a0ec907a01d' ,
53 'title' : 'Een nieuwe wereld: waarden, bewustzijn en techniek van de mensheid 2.0.' ,
55 'thumbnail' : r
're:^https?://.*\.jpg(?:\?.*)?$' ,
57 'timestamp' : 1413309600 ,
58 'upload_date' : '20141014' ,
62 'url' : 'https://collegerama.tudelft.nl/Mediasite/Play/86a9ea9f53e149079fbdb4202b521ed21d?catalog=fd32fd35-6c99-466c-89d4-cd3c431bc8a4' ,
63 'md5' : 'ef1fdded95bdf19b12c5999949419c92' ,
65 'id' : '86a9ea9f53e149079fbdb4202b521ed21d' ,
67 'title' : '64ste Vakantiecursus: Afvalwater' ,
68 'description' : 'md5:7fd774865cc69d972f542b157c328305' ,
69 'thumbnail' : r
're:^https?://.*\.jpg(?:\?.*?)?$' ,
71 'timestamp' : 1326446400 ,
72 'upload_date' : '20120113' ,
76 'url' : 'http://digitalops.sandia.gov/Mediasite/Play/24aace4429fc450fb5b38cdbf424a66e1d' ,
77 'md5' : '9422edc9b9a60151727e4b6d8bef393d' ,
79 'id' : '24aace4429fc450fb5b38cdbf424a66e1d' ,
81 'title' : 'Xyce Software Training - Section 1' ,
82 'description' : r
're:(?s)SAND Number: SAND 2013-7800.{200,}' ,
83 'upload_date' : '20120409' ,
84 'timestamp' : 1333983600 ,
89 'url' : 'https://collegerama.tudelft.nl/Mediasite/Showcase/livebroadcast/Presentation/ada7020854f743c49fbb45c9ec7dbb351d' ,
90 'only_matching' : True ,
93 'url' : 'https://mediasite.ntnu.no/Mediasite/Showcase/default/Presentation/7d8b913259334b688986e970fae6fcb31d' ,
94 'only_matching' : True ,
98 # look in Mediasite.Core.js (Mediasite.ContentStreamType[*])
100 0 : 'video1' , # the main video
103 4 : 'video2' , # screencast?
108 def _extract_urls ( webpage
):
110 unescapeHTML ( mobj
. group ( 'url' ))
111 for mobj
in re
. finditer (
112 r
'(?xi)<iframe\b[^>]+\bsrc=(["\' ])( ?P
< url
>( ?
:( ?
: https?
:) ?
//[ ^
/]+) ?
/ Mediasite
/ Play
/[ 0 - 9 a
- f
]{ 32 , 34 }( ?
: \? .* ?
) ?
) \
1 ',
115 def _real_extract(self, url):
116 url, data = unsmuggle_url(url, {})
117 mobj = re.match(self._VALID_URL, url)
118 resource_id = mobj.group(' id ')
119 query = mobj.group(' query
')
121 webpage, urlh = self._download_webpage_handle(url, resource_id) # XXX: add UrlReferrer?
122 redirect_url = compat_str(urlh.geturl())
124 # XXX: might have also extracted UrlReferrer and QueryString from the html
125 service_path = compat_urlparse.urljoin(redirect_url, self._html_search_regex(
126 r' < div
[ ^
>]+ \b id
=[ " \' ]ServicePath[^>]+>(.+?)</div>', webpage, resource_id,
127 default='/Mediasite/PlayerService/PlayerService.svc/json'))
129 player_options = self._download_json(
130 ' %s /GetPlayerOptions' % service_path, resource_id,
132 'Content-type': 'application/json; charset=utf-8',
133 'X-Requested-With': 'XMLHttpRequest',
136 'getPlayerOptionsRequest': {
137 'ResourceId': resource_id,
138 'QueryString': query,
139 'UrlReferrer': data.get('UrlReferrer', ''),
140 'UseScreenReader': False,
142 }).encode('utf-8'))['d']
144 presentation = player_options['Presentation']
145 title = presentation['Title']
147 if presentation is None:
148 raise ExtractorError(
149 'Mediasite says: %s ' % player_options['PlayerPresentationStatusMessage'],
154 for snum, Stream in enumerate(presentation['Streams']):
155 stream_type = Stream.get('StreamType')
156 if stream_type is None:
159 video_urls = Stream.get('VideoUrls')
160 if not isinstance(video_urls, list):
163 stream_id = self._STREAM_TYPES.get(
164 stream_type, 'type %u ' % stream_type)
167 for unum, VideoUrl in enumerate(video_urls):
168 video_url = url_or_none(VideoUrl.get('Location'))
171 # XXX: if Stream.get('CanChangeScheme', False), switch scheme to HTTP/HTTPS
173 media_type = VideoUrl.get('MediaType')
174 if media_type == 'SS':
175 stream_formats.extend(self._extract_ism_formats(
176 video_url, resource_id,
177 ism_id=' %s-%u . %u ' % (stream_id, snum, unum),
179 elif media_type == 'Dash':
180 stream_formats.extend(self._extract_mpd_formats(
181 video_url, resource_id,
182 mpd_id=' %s-%u . %u ' % (stream_id, snum, unum),
185 stream_formats.append({
186 'format_id': ' %s-%u . %u ' % (stream_id, snum, unum),
188 'ext': mimetype2ext(VideoUrl.get('MimeType')),
191 # TODO: if Stream['HasSlideContent']:
192 # synthesise an MJPEG video stream ' %s-%u .slides' % (stream_type, snum)
193 # from Stream['Slides']
194 # this will require writing a custom downloader...
196 # disprefer 'secondary' streams
198 for fmt in stream_formats:
199 fmt['preference'] = -1
201 thumbnail_url = Stream.get('ThumbnailUrl')
204 'id': ' %s-%u ' % (stream_id, snum),
205 'url': urljoin(redirect_url, thumbnail_url),
206 'preference': -1 if stream_type != 0 else 0,
208 formats.extend(stream_formats)
210 self._sort_formats(formats)
212 # XXX: Presentation['Presenters']
213 # XXX: Presentation['Transcript']
218 'description': presentation.get('Description'),
219 'duration': float_or_none(presentation.get('Duration'), 1000),
220 'timestamp': float_or_none(presentation.get('UnixTime'), 1000),
222 'thumbnails': thumbnails,