2018-10-26 19:15:44 -07:00
|
|
|
# coding: utf-8
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2019-03-11 16:26:30 -07:00
|
|
|
<<<<<<< HEAD
|
2018-11-21 06:04:34 +07:00
|
|
|
import itertools
|
|
|
|
|
2018-10-26 19:15:44 -07:00
|
|
|
from .common import InfoExtractor
|
|
|
|
from ..compat import (
|
2018-11-21 05:25:43 +07:00
|
|
|
compat_parse_qs,
|
2018-10-26 19:15:44 -07:00
|
|
|
compat_urllib_parse_urlparse,
|
|
|
|
)
|
|
|
|
from ..utils import (
|
|
|
|
clean_html,
|
2018-11-21 05:25:43 +07:00
|
|
|
float_or_none,
|
2019-03-11 16:26:30 -07:00
|
|
|
=======
|
2018-10-27 07:57:12 -07:00
|
|
|
import re
|
|
|
|
from .common import InfoExtractor
|
2018-11-02 12:27:22 -07:00
|
|
|
from ..compat import (
|
|
|
|
compat_urllib_parse_urlparse,
|
|
|
|
compat_parse_qs
|
|
|
|
)
|
2018-10-29 16:22:03 -07:00
|
|
|
from ..utils import (
|
2018-11-02 12:27:22 -07:00
|
|
|
clean_html,
|
2019-03-11 16:26:30 -07:00
|
|
|
>>>>>>> 2f72407593d15549a1ec6830a3cb5d7b4ad0b22b
|
2018-10-26 19:15:44 -07:00
|
|
|
int_or_none,
|
|
|
|
try_get,
|
|
|
|
urlencode_postdata,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2019-03-11 16:26:30 -07:00
|
|
|
<<<<<<< HEAD
|
2018-11-21 05:25:43 +07:00
|
|
|
class CiscoLiveBaseIE(InfoExtractor):
|
2018-10-26 19:15:44 -07:00
|
|
|
# These appear to be constant across all Cisco Live presentations
|
|
|
|
# and are not tied to any user session or event
|
|
|
|
RAINFOCUS_API_URL = 'https://events.rainfocus.com/api/%s'
|
2018-11-21 05:25:43 +07:00
|
|
|
RAINFOCUS_API_PROFILE_ID = 'Na3vqYdAlJFSxhYTYQGuMbpafMqftalz'
|
|
|
|
RAINFOCUS_WIDGET_ID = 'n6l4Lo05R8fiy3RpUBm447dZN8uNWoye'
|
2018-10-26 19:15:44 -07:00
|
|
|
BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/5647924234001/SyK2FdqjM_default/index.html?videoId=%s'
|
|
|
|
|
2018-11-21 05:25:43 +07:00
|
|
|
HEADERS = {
|
|
|
|
'Origin': 'https://ciscolive.cisco.com',
|
|
|
|
'rfApiProfileId': RAINFOCUS_API_PROFILE_ID,
|
|
|
|
'rfWidgetId': RAINFOCUS_WIDGET_ID,
|
|
|
|
}
|
|
|
|
|
2018-11-21 06:04:34 +07:00
|
|
|
def _call_api(self, ep, rf_id, query, referrer, note=None):
|
2018-11-21 05:25:43 +07:00
|
|
|
headers = self.HEADERS.copy()
|
|
|
|
headers['Referer'] = referrer
|
|
|
|
return self._download_json(
|
2018-11-21 06:04:34 +07:00
|
|
|
self.RAINFOCUS_API_URL % ep, rf_id, note=note,
|
|
|
|
data=urlencode_postdata(query), headers=headers)
|
2018-11-21 05:25:43 +07:00
|
|
|
|
2018-10-26 19:15:44 -07:00
|
|
|
def _parse_rf_item(self, rf_item):
|
2019-03-11 16:26:30 -07:00
|
|
|
=======
|
2018-10-27 07:57:12 -07:00
|
|
|
class CiscoLiveIE(InfoExtractor):
|
2018-10-29 14:03:17 -07:00
|
|
|
IE_NAME = 'ciscolive'
|
2018-10-29 21:17:54 -07:00
|
|
|
_VALID_URL = r'(?:https?://)?ciscolive\.cisco\.com/on-demand-library/\??(?P<query>[^#]+)#/(?:session/(?P<id>.+))?$'
|
2018-10-29 10:06:20 -07:00
|
|
|
_TESTS = [
|
|
|
|
{
|
2018-10-29 14:03:17 -07:00
|
|
|
'url': 'https://ciscolive.cisco.com/on-demand-library/?#/session/1423353499155001FoSs',
|
|
|
|
'md5': 'c98acf395ed9c9f766941c70f5352e22',
|
|
|
|
'info_dict': {
|
|
|
|
'id': '5803694304001',
|
|
|
|
'ext': 'mp4',
|
2018-11-19 09:35:20 -08:00
|
|
|
'title': '13 Smart Automations to Monitor Your Cisco IOS Network',
|
|
|
|
'description': 'md5:ec4a436019e09a918dec17714803f7cc',
|
2018-10-29 14:03:17 -07:00
|
|
|
'timestamp': 1530305395,
|
|
|
|
'uploader_id': '5647924234001',
|
|
|
|
'upload_date': '20180629',
|
|
|
|
'location': '16B Mezz.',
|
2018-10-29 10:06:20 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2018-10-29 14:03:17 -07:00
|
|
|
'url': 'https://ciscolive.cisco.com/on-demand-library/?search.event=ciscoliveus2018&search.technicallevel=scpsSkillLevel_aintroductory&search.focus=scpsSessionFocus_designAndDeployment#/',
|
|
|
|
'md5': '993d4cf051f6174059328b1dce8e94bd',
|
|
|
|
'info_dict': {
|
|
|
|
'upload_date': '20180629',
|
2018-11-19 09:35:20 -08:00
|
|
|
'title': 'DevNet Panel-Applying Design Thinking to Building Products in Cisco',
|
2018-10-29 14:03:17 -07:00
|
|
|
'timestamp': 1530316421,
|
|
|
|
'uploader_id': '5647924234001',
|
|
|
|
'id': '5803751616001',
|
2018-11-19 09:35:20 -08:00
|
|
|
'description': 'md5:5f144575cd6848117fe2f756855b038b',
|
2018-10-29 14:03:17 -07:00
|
|
|
'location': 'WoS, DevNet Theater',
|
|
|
|
'ext': 'mp4',
|
2018-10-29 10:06:20 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2018-10-29 14:03:17 -07:00
|
|
|
'url': 'https://ciscolive.cisco.com/on-demand-library/?search.technology=scpsTechnology_applicationDevelopment&search.technology=scpsTechnology_ipv6&search.focus=scpsSessionFocus_troubleshootingTroubleshooting#/',
|
|
|
|
'md5': '80e0c3b87e373fe3a3316b934b8915bf',
|
|
|
|
'info_dict': {
|
|
|
|
'upload_date': '20180629',
|
2018-11-19 09:35:20 -08:00
|
|
|
'title': 'Beating the CCIE Routing & Switching',
|
2018-10-29 14:03:17 -07:00
|
|
|
'timestamp': 1530311842,
|
|
|
|
'uploader_id': '5647924234001',
|
|
|
|
'id': '5803735679001',
|
2018-11-19 09:35:20 -08:00
|
|
|
'description': 'md5:e71970799e92d7f5ff57ae23f64b0929',
|
2018-10-29 14:03:17 -07:00
|
|
|
'location': 'Tulúm 02',
|
|
|
|
'ext': 'mp4',
|
2018-10-29 10:06:20 -07:00
|
|
|
},
|
2018-10-29 14:03:17 -07:00
|
|
|
}
|
2018-10-29 10:06:20 -07:00
|
|
|
]
|
2018-10-27 07:57:12 -07:00
|
|
|
|
|
|
|
# These appear to be constant across all Cisco Live presentations
|
|
|
|
# and are not tied to any user session or event
|
2018-10-29 14:03:17 -07:00
|
|
|
RAINFOCUS_API_URL = 'https://events.rainfocus.com/api/%s'
|
|
|
|
RAINFOCUS_APIPROFILEID = 'Na3vqYdAlJFSxhYTYQGuMbpafMqftalz'
|
|
|
|
RAINFOCUS_WIDGETID = 'n6l4Lo05R8fiy3RpUBm447dZN8uNWoye'
|
|
|
|
BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/5647924234001/SyK2FdqjM_default/index.html?videoId=%s'
|
2018-10-27 07:57:12 -07:00
|
|
|
|
2018-10-28 10:16:03 -07:00
|
|
|
def _parse_rf_item(self, rf_item):
|
2018-11-19 09:35:20 -08:00
|
|
|
''' Parses metadata and passes to Brightcove extractor '''
|
2019-03-11 16:26:30 -07:00
|
|
|
>>>>>>> 2f72407593d15549a1ec6830a3cb5d7b4ad0b22b
|
2018-10-26 19:15:44 -07:00
|
|
|
event_name = rf_item.get('eventName')
|
|
|
|
title = rf_item['title']
|
|
|
|
description = clean_html(rf_item.get('abstract'))
|
|
|
|
presenter_name = try_get(rf_item, lambda x: x['participants'][0]['fullName'])
|
|
|
|
bc_id = rf_item['videos'][0]['url']
|
|
|
|
bc_url = self.BRIGHTCOVE_URL_TEMPLATE % bc_id
|
2019-03-11 16:26:30 -07:00
|
|
|
<<<<<<< HEAD
|
2018-11-21 05:25:43 +07:00
|
|
|
duration = float_or_none(try_get(rf_item, lambda x: x['times'][0]['length']))
|
2019-03-11 16:26:30 -07:00
|
|
|
=======
|
2018-11-02 12:27:22 -07:00
|
|
|
duration = int_or_none(try_get(rf_item, lambda x: x['times'][0]['length']))
|
2019-03-11 16:26:30 -07:00
|
|
|
>>>>>>> 2f72407593d15549a1ec6830a3cb5d7b4ad0b22b
|
2018-10-26 19:15:44 -07:00
|
|
|
location = try_get(rf_item, lambda x: x['times'][0]['room'])
|
|
|
|
|
|
|
|
if duration:
|
|
|
|
duration = duration * 60
|
|
|
|
|
|
|
|
return {
|
|
|
|
'_type': 'url_transparent',
|
2019-03-11 16:26:30 -07:00
|
|
|
<<<<<<< HEAD
|
2018-11-21 05:25:43 +07:00
|
|
|
'url': bc_url,
|
|
|
|
'ie_key': 'BrightcoveNew',
|
|
|
|
'title': title,
|
2018-10-26 19:15:44 -07:00
|
|
|
'description': description,
|
|
|
|
'duration': duration,
|
2018-11-21 05:25:43 +07:00
|
|
|
'creator': presenter_name,
|
2018-10-26 19:15:44 -07:00
|
|
|
'location': location,
|
|
|
|
'series': event_name,
|
|
|
|
}
|
|
|
|
|
2018-11-21 05:25:43 +07:00
|
|
|
|
|
|
|
class CiscoLiveSessionIE(CiscoLiveBaseIE):
|
2019-03-11 16:23:20 -07:00
|
|
|
_VALID_URL = r'https?://(?:www\.)?ciscolive(?:\.cisco)?\.com/[^#]*#/session/(?P<id>[^/?&]+)'
|
|
|
|
_TESTS = [{
|
|
|
|
'url': 'https://ciscolive.cisco.com/global/on-demand-library/?#/session/1423353499155001FoSs',
|
2018-11-21 05:25:43 +07:00
|
|
|
'md5': 'c98acf395ed9c9f766941c70f5352e22',
|
|
|
|
'info_dict': {
|
|
|
|
'id': '5803694304001',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'title': '13 Smart Automations to Monitor Your Cisco IOS Network',
|
|
|
|
'description': 'md5:ec4a436019e09a918dec17714803f7cc',
|
|
|
|
'timestamp': 1530305395,
|
|
|
|
'upload_date': '20180629',
|
|
|
|
'uploader_id': '5647924234001',
|
|
|
|
'location': '16B Mezz.',
|
|
|
|
},
|
2019-03-11 16:23:20 -07:00
|
|
|
}, {
|
|
|
|
'url': 'https://www.ciscolive.com/global/on-demand-library.html?#/session/14479207924060017vKJ',
|
|
|
|
'only_matching': True,
|
|
|
|
}]
|
2018-10-26 19:15:44 -07:00
|
|
|
|
|
|
|
def _real_extract(self, url):
|
2018-11-21 05:25:43 +07:00
|
|
|
rf_id = self._match_id(url)
|
|
|
|
rf_result = self._call_api('session', rf_id, {'id': rf_id}, url)
|
|
|
|
return self._parse_rf_item(rf_result['items'][0])
|
|
|
|
|
|
|
|
|
|
|
|
class CiscoLiveSearchIE(CiscoLiveBaseIE):
|
2019-03-11 16:23:20 -07:00
|
|
|
_VALID_URL = r'https?://(?:www\.)?ciscolive(?:\.cisco)?\.com/[^?]*\?search'
|
2018-11-21 05:25:43 +07:00
|
|
|
_TESTS = [{
|
|
|
|
'url': 'https://ciscolive.cisco.com/on-demand-library/?search.event=ciscoliveus2018&search.technicallevel=scpsSkillLevel_aintroductory&search.focus=scpsSessionFocus_designAndDeployment#/',
|
|
|
|
'info_dict': {
|
2018-11-21 06:04:34 +07:00
|
|
|
'title': 'Search query',
|
2018-11-21 05:25:43 +07:00
|
|
|
},
|
|
|
|
'playlist_count': 5,
|
|
|
|
}, {
|
|
|
|
'url': 'https://ciscolive.cisco.com/on-demand-library/?search.technology=scpsTechnology_applicationDevelopment&search.technology=scpsTechnology_ipv6&search.focus=scpsSessionFocus_troubleshootingTroubleshooting#/',
|
|
|
|
'only_matching': True,
|
2019-03-11 16:23:20 -07:00
|
|
|
}, {
|
|
|
|
'url': 'https://www.ciscolive.com/global/on-demand-library.html?search.event=ciscoliveemea2019#/',
|
|
|
|
'only_matching': True,
|
2018-11-21 05:25:43 +07:00
|
|
|
}]
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def suitable(cls, url):
|
|
|
|
return False if CiscoLiveSessionIE.suitable(url) else super(CiscoLiveSearchIE, cls).suitable(url)
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def _check_bc_id_exists(rf_item):
|
|
|
|
return int_or_none(try_get(rf_item, lambda x: x['videos'][0]['url'])) is not None
|
|
|
|
|
2018-11-21 06:04:34 +07:00
|
|
|
def _entries(self, query, url):
|
|
|
|
query['size'] = 50
|
|
|
|
query['from'] = 0
|
|
|
|
for page_num in itertools.count(1):
|
|
|
|
results = self._call_api(
|
|
|
|
'search', None, query, url,
|
|
|
|
'Downloading search JSON page %d' % page_num)
|
|
|
|
sl = try_get(results, lambda x: x['sectionList'][0], dict)
|
|
|
|
if sl:
|
|
|
|
results = sl
|
|
|
|
items = results.get('items')
|
|
|
|
if not items or not isinstance(items, list):
|
|
|
|
break
|
|
|
|
for item in items:
|
|
|
|
if not isinstance(item, dict):
|
|
|
|
continue
|
|
|
|
if not self._check_bc_id_exists(item):
|
|
|
|
continue
|
|
|
|
yield self._parse_rf_item(item)
|
|
|
|
size = int_or_none(results.get('size'))
|
|
|
|
if size is not None:
|
|
|
|
query['size'] = size
|
|
|
|
total = int_or_none(results.get('total'))
|
|
|
|
if total is not None and query['from'] + query['size'] > total:
|
|
|
|
break
|
|
|
|
query['from'] += query['size']
|
|
|
|
|
2018-11-21 05:25:43 +07:00
|
|
|
def _real_extract(self, url):
|
2018-11-21 06:04:34 +07:00
|
|
|
query = compat_parse_qs(compat_urllib_parse_urlparse(url).query)
|
|
|
|
query['type'] = 'session'
|
|
|
|
return self.playlist_result(
|
|
|
|
self._entries(query, url), playlist_title='Search query')
|
2019-03-11 16:26:30 -07:00
|
|
|
=======
|
2018-11-19 09:35:20 -08:00
|
|
|
'creator': presenter_name,
|
|
|
|
'description': description,
|
2018-10-29 14:03:17 -07:00
|
|
|
'duration': duration,
|
|
|
|
'ie_key': 'BrightcoveNew',
|
2018-11-19 09:35:20 -08:00
|
|
|
'location': location,
|
|
|
|
'series': event_name,
|
|
|
|
'title': title,
|
|
|
|
'url': bc_url,
|
2018-10-28 10:16:03 -07:00
|
|
|
}
|
2018-10-28 14:03:36 -07:00
|
|
|
|
2018-10-29 16:22:03 -07:00
|
|
|
def _check_bc_id_exists(self, rf_item):
|
2018-11-19 09:35:20 -08:00
|
|
|
''' Checks for the existence of a Brightcove URL in an API result '''
|
2018-10-29 16:22:03 -07:00
|
|
|
bc_id = try_get(rf_item, lambda x: x['videos'][0]['url'])
|
2018-11-05 16:21:10 -08:00
|
|
|
if bc_id:
|
2018-11-19 09:35:20 -08:00
|
|
|
if bc_id.strip().isdigit():
|
2018-11-05 16:21:10 -08:00
|
|
|
return rf_item
|
2018-10-27 07:57:12 -07:00
|
|
|
|
|
|
|
def _real_extract(self, url):
|
2018-10-28 10:16:03 -07:00
|
|
|
mobj = re.match(self._VALID_URL, url)
|
2018-11-19 09:35:20 -08:00
|
|
|
HEADERS = {
|
2018-10-29 14:03:17 -07:00
|
|
|
'Origin': 'https://ciscolive.cisco.com',
|
|
|
|
'rfApiProfileId': self.RAINFOCUS_APIPROFILEID,
|
|
|
|
'rfWidgetId': self.RAINFOCUS_WIDGETID,
|
|
|
|
'Referer': url,
|
2018-10-27 07:57:12 -07:00
|
|
|
}
|
|
|
|
# Single session URL (single video)
|
2018-10-29 14:03:17 -07:00
|
|
|
if mobj.group('id'):
|
|
|
|
rf_id = mobj.group('id')
|
|
|
|
request = self.RAINFOCUS_API_URL % 'session'
|
2018-11-02 12:27:22 -07:00
|
|
|
data = urlencode_postdata({'id': rf_id})
|
2018-11-19 09:35:20 -08:00
|
|
|
rf_result = self._download_json(request, rf_id, data=data, headers=HEADERS)
|
2018-11-02 13:53:07 -07:00
|
|
|
rf_item = self._check_bc_id_exists(rf_result['items'][0])
|
2018-10-28 10:16:03 -07:00
|
|
|
return self._parse_rf_item(rf_item)
|
2018-10-27 07:57:12 -07:00
|
|
|
else:
|
|
|
|
# Filter query URL (multiple videos)
|
2018-11-02 12:27:22 -07:00
|
|
|
rf_query = compat_parse_qs((compat_urllib_parse_urlparse(url).query))
|
|
|
|
rf_query['type'] = 'session'
|
|
|
|
rf_query['size'] = 1000
|
|
|
|
data = urlencode_postdata(rf_query)
|
2018-10-29 14:03:17 -07:00
|
|
|
request = self.RAINFOCUS_API_URL % 'search'
|
2018-11-19 09:35:20 -08:00
|
|
|
rf_results = self._download_json(request, 'Filter query', data=data, headers=HEADERS)
|
|
|
|
entries = [
|
|
|
|
self._parse_rf_item(rf_item)
|
|
|
|
for rf_item
|
|
|
|
in rf_results['sectionList'][0]['items']
|
2018-10-29 16:22:03 -07:00
|
|
|
if self._check_bc_id_exists(rf_item)
|
2018-10-29 14:03:17 -07:00
|
|
|
]
|
2018-10-29 14:11:04 -07:00
|
|
|
return self.playlist_result(entries, 'Filter query')
|
2019-03-11 16:26:30 -07:00
|
|
|
>>>>>>> 2f72407593d15549a1ec6830a3cb5d7b4ad0b22b
|