aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/extractor/safari.py
diff options
context:
space:
mode:
authorremitamine <remitamine@gmail.com>2016-03-11 16:57:06 +0100
committerremitamine <remitamine@gmail.com>2016-03-11 16:57:06 +0100
commitbcb668de189b92bd1dcad661d50ae981f25deca4 (patch)
tree2ca13c2ab2ad858dc0fbb68ae3adac584176841c /youtube_dl/extractor/safari.py
parentfac7e79277942a182ba68d1ba01b8b3f7a9935b3 (diff)
[safari] extract free and preview videos(#7491)
Diffstat (limited to 'youtube_dl/extractor/safari.py')
-rw-r--r--youtube_dl/extractor/safari.py29
1 files changed, 17 insertions, 12 deletions
diff --git a/youtube_dl/extractor/safari.py b/youtube_dl/extractor/safari.py
index a65fc8ed7..ae619636c 100644
--- a/youtube_dl/extractor/safari.py
+++ b/youtube_dl/extractor/safari.py
@@ -12,6 +12,7 @@ from ..utils import (
smuggle_url,
std_headers,
urlencode_postdata,
+ update_url_query,
)
@@ -26,6 +27,7 @@ class SafariBaseIE(InfoExtractor):
LOGGED_IN = False
def _real_initialize(self):
+ return
# We only need to log in once for courses or individual videos
if not self.LOGGED_IN:
self._login()
@@ -86,13 +88,15 @@ class SafariIE(SafariBaseIE):
_TESTS = [{
'url': 'https://www.safaribooksonline.com/library/view/hadoop-fundamentals-livelessons/9780133392838/part00.html',
- 'md5': '5b0c4cc1b3c1ba15dda7344085aa5592',
+ 'md5': 'dcc5a425e79f2564148652616af1f2a3',
'info_dict': {
- 'id': '2842601850001',
+ 'id': '0_qbqx90ic',
'ext': 'mp4',
- 'title': 'Introduction',
+ 'title': 'Introduction to Hadoop Fundamentals LiveLessons',
+ 'timestamp': 1437758058,
+ 'upload_date': '20150724',
+ 'uploader_id': 'stork',
},
- 'skip': 'Requires safaribooksonline account credentials',
}, {
'url': 'https://www.safaribooksonline.com/api/v1/book/9780133392838/chapter/part00.html',
'only_matching': True,
@@ -107,15 +111,16 @@ class SafariIE(SafariBaseIE):
course_id = mobj.group('course_id')
part = mobj.group('part')
- webpage = self._download_webpage(
- '%s/%s/chapter-content/%s.html' % (self._API_BASE, course_id, part),
- part)
-
- bc_url = BrightcoveLegacyIE._extract_brightcove_url(webpage)
- if not bc_url:
- raise ExtractorError('Could not extract Brightcove URL from %s' % url, expected=True)
+ webpage = self._download_webpage(url, '%s/%s' % (course_id, part))
+ reference_id = self._search_regex(r'data-reference-id="([^"]+)"', webpage, 'kaltura reference id')
+ partner_id = self._search_regex(r'data-partner-id="([^"]+)"', webpage, 'kaltura widget id')
+ ui_id = self._search_regex(r'data-ui-id="([^"]+)"', webpage, 'kaltura uiconf id')
- return self.url_result(smuggle_url(bc_url, {'Referer': url}), 'BrightcoveLegacy')
+ return self.url_result(update_url_query('https://cdnapisec.kaltura.com/html5/html5lib/v2.37.1/mwEmbedFrame.php', {
+ 'wid': '_%s' % partner_id,
+ 'uiconf_id': ui_id,
+ 'flashvars[referenceId]': reference_id,
+ }), 'Kaltura')
class SafariCourseIE(SafariBaseIE):