1
0
Fork 0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-12-22 08:47:41 +00:00

[safari] extract free and preview videos(#7491)

This commit is contained in:
remitamine 2016-03-11 16:57:06 +01:00
parent fac7e79277
commit bcb668de18

View file

@ -12,6 +12,7 @@ from ..utils import (
smuggle_url, smuggle_url,
std_headers, std_headers,
urlencode_postdata, urlencode_postdata,
update_url_query,
) )
@ -26,6 +27,7 @@ class SafariBaseIE(InfoExtractor):
LOGGED_IN = False LOGGED_IN = False
def _real_initialize(self): def _real_initialize(self):
return
# We only need to log in once for courses or individual videos # We only need to log in once for courses or individual videos
if not self.LOGGED_IN: if not self.LOGGED_IN:
self._login() self._login()
@ -86,13 +88,15 @@ class SafariIE(SafariBaseIE):
_TESTS = [{ _TESTS = [{
'url': 'https://www.safaribooksonline.com/library/view/hadoop-fundamentals-livelessons/9780133392838/part00.html', 'url': 'https://www.safaribooksonline.com/library/view/hadoop-fundamentals-livelessons/9780133392838/part00.html',
'md5': '5b0c4cc1b3c1ba15dda7344085aa5592', 'md5': 'dcc5a425e79f2564148652616af1f2a3',
'info_dict': { 'info_dict': {
'id': '2842601850001', 'id': '0_qbqx90ic',
'ext': 'mp4', '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', 'url': 'https://www.safaribooksonline.com/api/v1/book/9780133392838/chapter/part00.html',
'only_matching': True, 'only_matching': True,
@ -107,15 +111,16 @@ class SafariIE(SafariBaseIE):
course_id = mobj.group('course_id') course_id = mobj.group('course_id')
part = mobj.group('part') part = mobj.group('part')
webpage = self._download_webpage( webpage = self._download_webpage(url, '%s/%s' % (course_id, part))
'%s/%s/chapter-content/%s.html' % (self._API_BASE, course_id, part), reference_id = self._search_regex(r'data-reference-id="([^"]+)"', webpage, 'kaltura reference id')
part) 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')
bc_url = BrightcoveLegacyIE._extract_brightcove_url(webpage) return self.url_result(update_url_query('https://cdnapisec.kaltura.com/html5/html5lib/v2.37.1/mwEmbedFrame.php', {
if not bc_url: 'wid': '_%s' % partner_id,
raise ExtractorError('Could not extract Brightcove URL from %s' % url, expected=True) 'uiconf_id': ui_id,
'flashvars[referenceId]': reference_id,
return self.url_result(smuggle_url(bc_url, {'Referer': url}), 'BrightcoveLegacy') }), 'Kaltura')
class SafariCourseIE(SafariBaseIE): class SafariCourseIE(SafariBaseIE):