]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/sandia.py
2 from __future__
import unicode_literals
8 from .common
import InfoExtractor
10 compat_urllib_request
,
21 class SandiaIE(InfoExtractor
):
22 IE_DESC
= 'Sandia National Laboratories'
23 _VALID_URL
= r
'https?://digitalops\.sandia\.gov/Mediasite/Play/(?P<id>[0-9a-f]+)'
25 'url': 'http://digitalops.sandia.gov/Mediasite/Play/24aace4429fc450fb5b38cdbf424a66e1d',
26 'md5': '9422edc9b9a60151727e4b6d8bef393d',
28 'id': '24aace4429fc450fb5b38cdbf424a66e1d',
30 'title': 'Xyce Software Training - Section 1',
31 'description': 're:(?s)SAND Number: SAND 2013-7800.{200,}',
32 'upload_date': '20120904',
37 def _real_extract(self
, url
):
38 video_id
= self
._match
_id
(url
)
40 req
= compat_urllib_request
.Request(url
)
41 req
.add_header('Cookie', 'MediasitePlayerCaps=ClientPlugins=4')
42 webpage
= self
._download
_webpage
(req
, video_id
)
44 js_path
= self
._search
_regex
(
45 r
'<script type="text/javascript" src="(/Mediasite/FileServer/Presentation/[^"]+)"',
46 webpage
, 'JS code URL')
47 js_url
= compat_urlparse
.urljoin(url
, js_path
)
49 js_code
= self
._download
_webpage
(
50 js_url
, video_id
, note
='Downloading player')
52 def extract_str(key
, **args
):
53 return self
._search
_regex
(
54 r
'Mediasite\.PlaybackManifest\.%s\s*=\s*(.+);\s*?\n' % re
.escape(key
),
57 def extract_data(key
, **args
):
58 data_json
= extract_str(key
, **args
)
61 return self
._parse
_json
(
62 data_json
, video_id
, transform_source
=js_to_json
)
65 for i
in itertools
.count():
66 fd
= extract_data('VideoUrls[%d]' % i
, default
=None)
70 'format_id': '%s' % i
,
71 'format_note': fd
['MimeType'].partition('/')[2],
72 'ext': mimetype2ext(fd
['MimeType']),
73 'url': fd
['Location'],
74 'protocol': 'f4m' if fd
['MimeType'] == 'video/x-mp4-fragmented' else None,
76 self
._sort
_formats
(formats
)
78 slide_baseurl
= compat_urlparse
.urljoin(
79 url
, extract_data('SlideBaseUrl'))
80 slide_template
= slide_baseurl
+ re
.sub(
81 r
'\{0:D?([0-9+])\}', r
'%0\1d', extract_data('SlideImageFileNameTemplate'))
84 for i
in itertools
.count(1):
85 sd
= extract_str('Slides[%d]' % i
, default
=None)
88 timestamp
= int_or_none(self
._search
_regex
(
89 r
'^Mediasite\.PlaybackManifest\.CreateSlide\("[^"]*"\s*,\s*([0-9]+),',
90 sd
, 'slide %s timestamp' % i
, fatal
=False))
92 'url': slide_template
% i
,
93 'duration': timestamp
- last_slide_time
,
95 last_slide_time
= timestamp
97 'format_id': 'slides',
98 'protocol': 'slideshow',
99 'url': json
.dumps(slides
),
100 'preference': -10000, # Downloader not yet written
102 self
._sort
_formats
(formats
)
104 title
= extract_data('Title')
105 description
= extract_data('Description', fatal
=False)
106 duration
= int_or_none(extract_data(
107 'Duration', fatal
=False), scale
=1000)
108 upload_date
= unified_strdate(extract_data('AirDate', fatal
=False))
113 'description': description
,
115 'upload_date': upload_date
,
116 'duration': duration
,