]>
Commit | Line | Data |
---|---|---|
c460bdd5 PH |
1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
c460bdd5 | 4 | import json |
c460bdd5 PH |
5 | |
6 | from .common import InfoExtractor | |
c460bdd5 PH |
7 | from ..utils import ( |
8 | int_or_none, | |
c460bdd5 | 9 | mimetype2ext, |
c460bdd5 PH |
10 | ) |
11 | ||
12 | ||
13 | class SandiaIE(InfoExtractor): | |
14 | IE_DESC = 'Sandia National Laboratories' | |
15 | _VALID_URL = r'https?://digitalops\.sandia\.gov/Mediasite/Play/(?P<id>[0-9a-f]+)' | |
16 | _TEST = { | |
17 | 'url': 'http://digitalops.sandia.gov/Mediasite/Play/24aace4429fc450fb5b38cdbf424a66e1d', | |
18 | 'md5': '9422edc9b9a60151727e4b6d8bef393d', | |
19 | 'info_dict': { | |
20 | 'id': '24aace4429fc450fb5b38cdbf424a66e1d', | |
21 | 'ext': 'mp4', | |
22 | 'title': 'Xyce Software Training - Section 1', | |
23 | 'description': 're:(?s)SAND Number: SAND 2013-7800.{200,}', | |
94a5cff9 RA |
24 | 'upload_date': '20120409', |
25 | 'timestamp': 1333983600, | |
c460bdd5 PH |
26 | 'duration': 7794, |
27 | } | |
28 | } | |
29 | ||
30 | def _real_extract(self, url): | |
31 | video_id = self._match_id(url) | |
32 | ||
94a5cff9 RA |
33 | presentation_data = self._download_json( |
34 | 'http://digitalops.sandia.gov/Mediasite/PlayerService/PlayerService.svc/json/GetPlayerOptions', | |
35 | video_id, data=json.dumps({ | |
36 | 'getPlayerOptionsRequest': { | |
37 | 'ResourceId': video_id, | |
38 | 'QueryString': '', | |
39 | } | |
40 | }), headers={ | |
41 | 'Content-Type': 'application/json; charset=utf-8', | |
42 | })['d']['Presentation'] | |
c460bdd5 | 43 | |
94a5cff9 | 44 | title = presentation_data['Title'] |
c460bdd5 PH |
45 | |
46 | formats = [] | |
94a5cff9 RA |
47 | for stream in presentation_data.get('Streams', []): |
48 | for fd in stream.get('VideoUrls', []): | |
49 | formats.append({ | |
50 | 'format_id': fd['MediaType'], | |
51 | 'format_note': fd['MimeType'].partition('/')[2], | |
52 | 'ext': mimetype2ext(fd['MimeType']), | |
53 | 'url': fd['Location'], | |
54 | 'protocol': 'f4m' if fd['MimeType'] == 'video/x-mp4-fragmented' else None, | |
55 | }) | |
c460bdd5 PH |
56 | self._sort_formats(formats) |
57 | ||
c460bdd5 PH |
58 | return { |
59 | 'id': video_id, | |
60 | 'title': title, | |
94a5cff9 | 61 | 'description': presentation_data.get('Description'), |
c460bdd5 | 62 | 'formats': formats, |
94a5cff9 RA |
63 | 'timestamp': int_or_none(presentation_data.get('UnixTime'), 1000), |
64 | 'duration': int_or_none(presentation_data.get('Duration'), 1000), | |
c460bdd5 | 65 | } |