[ciscolive] Updated formatting with Black
This commit is contained in:
parent
28743f5a8b
commit
b02413655e
@ -8,60 +8,65 @@ from ..utils import smuggle_url
|
|||||||
|
|
||||||
|
|
||||||
class CiscoLiveIE(InfoExtractor):
|
class CiscoLiveIE(InfoExtractor):
|
||||||
IE_NAME = 'ciscolive'
|
IE_NAME = "ciscolive"
|
||||||
_VALID_URL = r'https://ciscolive.cisco.com/on-demand-library/\??(?P<query>[^#]+)#/(?:session/(?P<id>.+))?$'
|
_VALID_URL = r"https://ciscolive.cisco.com/on-demand-library/\??(?P<query>[^#]+)#/(?:session/(?P<id>.+))?$"
|
||||||
_TESTS = [{
|
_TESTS = [
|
||||||
'url': 'https://ciscolive.cisco.com/on-demand-library/?#/session/1423353499155001FoSs',
|
{
|
||||||
'md5': 'c98acf395ed9c9f766941c70f5352e22',
|
"url": "https://ciscolive.cisco.com/on-demand-library/?#/session/1423353499155001FoSs",
|
||||||
'info_dict': {
|
"md5": "c98acf395ed9c9f766941c70f5352e22",
|
||||||
'id': '5803694304001',
|
"info_dict": {
|
||||||
'ext': 'mp4',
|
"id": "5803694304001",
|
||||||
'title': '13 Smart Automations to Monitor Your Cisco IOS Network',
|
"ext": "mp4",
|
||||||
'timestamp': 1530305395,
|
"title": "13 Smart Automations to Monitor Your Cisco IOS Network",
|
||||||
'uploader_id': '5647924234001',
|
"timestamp": 1530305395,
|
||||||
'upload_date': '20180629'
|
"uploader_id": "5647924234001",
|
||||||
}
|
"upload_date": "20180629",
|
||||||
}, {
|
},
|
||||||
'url': 'https://ciscolive.cisco.com/on-demand-library/?search.event=ciscoliveus2018&search.technicallevel=scpsSkillLevel_aintroductory&search.focus=scpsSessionFocus_designAndDeployment#/',
|
},
|
||||||
'md5': '993d4cf051f6174059328b1dce8e94bd',
|
{
|
||||||
'info_dict': {
|
"url": "https://ciscolive.cisco.com/on-demand-library/?search.event=ciscoliveus2018&search.technicallevel=scpsSkillLevel_aintroductory&search.focus=scpsSessionFocus_designAndDeployment#/",
|
||||||
'id': '5803751616001',
|
"md5": "993d4cf051f6174059328b1dce8e94bd",
|
||||||
'ext': 'mp4',
|
"info_dict": {
|
||||||
'timestamp': 1530316421,
|
"id": "5803751616001",
|
||||||
'title': 'DevNet Panel-Applying Design Thinking to Building Products in Cisco',
|
"ext": "mp4",
|
||||||
'uploader_id': '5647924234001',
|
"timestamp": 1530316421,
|
||||||
'upload_date': '20180629',
|
"title": "DevNet Panel-Applying Design Thinking to Building Products in Cisco",
|
||||||
}
|
"uploader_id": "5647924234001",
|
||||||
}, {
|
"upload_date": "20180629",
|
||||||
'url': 'https://ciscolive.cisco.com/on-demand-library/?search.technology=scpsTechnology_applicationDevelopment&search.technology=scpsTechnology_ipv6&search.focus=scpsSessionFocus_troubleshootingTroubleshooting#/',
|
},
|
||||||
'md5': '80e0c3b87e373fe3a3316b934b8915bf',
|
},
|
||||||
'info_dict': {
|
{
|
||||||
'id': '5803735679001',
|
"url": "https://ciscolive.cisco.com/on-demand-library/?search.technology=scpsTechnology_applicationDevelopment&search.technology=scpsTechnology_ipv6&search.focus=scpsSessionFocus_troubleshootingTroubleshooting#/",
|
||||||
'ext': 'mp4',
|
"md5": "80e0c3b87e373fe3a3316b934b8915bf",
|
||||||
'timestamp': 1530311842,
|
"info_dict": {
|
||||||
'title': 'Beating the CCIE Routing & Switching',
|
"id": "5803735679001",
|
||||||
'uploader_id': '5647924234001',
|
"ext": "mp4",
|
||||||
'upload_date': '20180629',
|
"timestamp": 1530311842,
|
||||||
}
|
"title": "Beating the CCIE Routing & Switching",
|
||||||
}, {
|
"uploader_id": "5647924234001",
|
||||||
'url': 'https://ciscolive.cisco.com/on-demand-library/?search.solutions=scpsSolutions_cleanair#/',
|
"upload_date": "20180629",
|
||||||
'md5': '80e0c3b87e373fe3a3316b934b8915bf',
|
},
|
||||||
'info_dict': {
|
},
|
||||||
'id': '5803735679001',
|
{
|
||||||
'ext': 'mp4',
|
"url": "https://ciscolive.cisco.com/on-demand-library/?search.solutions=scpsSolutions_cleanair#/",
|
||||||
'timestamp': 1530311842,
|
"md5": "80e0c3b87e373fe3a3316b934b8915bf",
|
||||||
'title': 'Beating the CCIE Routing & Switching',
|
"info_dict": {
|
||||||
'uploader_id': '5647924234001',
|
"id": "5803735679001",
|
||||||
'upload_date': '20180629',
|
"ext": "mp4",
|
||||||
}
|
"timestamp": 1530311842,
|
||||||
}]
|
"title": "Beating the CCIE Routing & Switching",
|
||||||
|
"uploader_id": "5647924234001",
|
||||||
|
"upload_date": "20180629",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
# These appear to be constant across all Cisco Live presentations
|
# These appear to be constant across all Cisco Live presentations
|
||||||
# and are not tied to any user session or event
|
# and are not tied to any user session or event
|
||||||
RAINFOCUS_API_URL = 'https://events.rainfocus.com/api/%s'
|
RAINFOCUS_API_URL = "https://events.rainfocus.com/api/%s"
|
||||||
RAINFOCUS_APIPROFILEID = 'Na3vqYdAlJFSxhYTYQGuMbpafMqftalz'
|
RAINFOCUS_APIPROFILEID = "Na3vqYdAlJFSxhYTYQGuMbpafMqftalz"
|
||||||
RAINFOCUS_WIDGETID = 'n6l4Lo05R8fiy3RpUBm447dZN8uNWoye'
|
RAINFOCUS_WIDGETID = "n6l4Lo05R8fiy3RpUBm447dZN8uNWoye"
|
||||||
BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/5647924234001/SyK2FdqjM_default/index.html?videoId=%s'
|
BRIGHTCOVE_URL_TEMPLATE = "http://players.brightcove.net/5647924234001/SyK2FdqjM_default/index.html?videoId=%s"
|
||||||
|
|
||||||
def _parse_rf_item(self, rf_item):
|
def _parse_rf_item(self, rf_item):
|
||||||
""" Parses metadata and passes to Brightcove extractor
|
""" Parses metadata and passes to Brightcove extractor
|
||||||
@ -71,59 +76,65 @@ class CiscoLiveIE(InfoExtractor):
|
|||||||
# Not all of which is appropriate to pass to Brightcove extractor
|
# Not all of which is appropriate to pass to Brightcove extractor
|
||||||
# but might be nice to print to output
|
# but might be nice to print to output
|
||||||
|
|
||||||
event_name = rf_item.get('eventName')
|
event_name = rf_item.get("eventName")
|
||||||
# Full event name [Cisco Live EMEA 2016]
|
# Full event name [Cisco Live EMEA 2016]
|
||||||
# rf_id = rf_item.get('eventId')
|
# rf_id = rf_item.get('eventId')
|
||||||
# Rainfocus ID [14382715417240cleu16]
|
# Rainfocus ID [14382715417240cleu16]
|
||||||
cl_id = rf_item.get('abbreviation')
|
cl_id = rf_item.get("abbreviation")
|
||||||
# Cisco Live ID - Shorthand session ID [BRKCRS-2501]
|
# Cisco Live ID - Shorthand session ID [BRKCRS-2501]
|
||||||
title = rf_item.get('title')
|
title = rf_item.get("title")
|
||||||
# Full session title [Campus QoS Design-Simplified]
|
# Full session title [Campus QoS Design-Simplified]
|
||||||
description = rf_item.get('abstract')
|
description = rf_item.get("abstract")
|
||||||
# Description [This session will apply Cisco's QoS strategy for rich media...]
|
# Description [This session will apply Cisco's QoS strategy for rich media...]
|
||||||
presenter_name = rf_item['participants'][0]['fullName'] # TODO: Needs safe get() method
|
# TODO: Needs safe get() method
|
||||||
|
presenter_name = rf_item["participants"][0]["fullName"]
|
||||||
# Presenter's full name [Tim Szigeti]
|
# Presenter's full name [Tim Szigeti]
|
||||||
presenter_title = rf_item['participants'][0]['jobTitle']
|
presenter_title = rf_item["participants"][0]["jobTitle"]
|
||||||
# Presenter's job title [Principal Engineer - Technical Marketing]
|
# Presenter's job title [Principal Engineer - Technical Marketing]
|
||||||
pdf_url = rf_item['files'][0]['url']
|
pdf_url = rf_item["files"][0]["url"]
|
||||||
# Presentation PDF URL [https://clnv.s3.amazonaws.com/2016/eur/pdf/BRKCRS-2501.pdf]
|
# Presentation PDF URL [https://clnv.s3.amazonaws.com/2016/eur/pdf/BRKCRS-2501.pdf]
|
||||||
bc_id = rf_item['videos'][0]['url']
|
bc_id = rf_item["videos"][0]["url"]
|
||||||
# Brightcove video ID [5803710412001]
|
# Brightcove video ID [5803710412001]
|
||||||
bc_url = self.BRIGHTCOVE_URL_TEMPLATE % bc_id
|
bc_url = self.BRIGHTCOVE_URL_TEMPLATE % bc_id
|
||||||
# Brightcove video URL [http://players.brightcove.net/5647924234001/SyK2FdqjM_default/index.html?videoId=5803710412001]
|
# Brightcove video URL [http://players.brightcove.net/5647924234001/SyK2FdqjM_default/index.html?videoId=5803710412001]
|
||||||
duration = rf_item['times'][0]['length'] * 60
|
duration = rf_item["times"][0]["length"] * 60
|
||||||
# Duration. Provided in minutes * 60 = seconds [7200]
|
# Duration. Provided in minutes * 60 = seconds [7200]
|
||||||
location = rf_item['times'][0]['room']
|
location = rf_item["times"][0]["room"]
|
||||||
# Location [Hall 7.3 Breakout Room 732]
|
# Location [Hall 7.3 Breakout Room 732]
|
||||||
|
|
||||||
# Metadata passed to final Brightcove extractor
|
# Metadata passed to final Brightcove extractor
|
||||||
# TODO: Only title is passed--need to work on how to best merge smuggled metadata
|
# TODO: Only title is passed--need to work on how to best merge smuggled metadata
|
||||||
metadata = {
|
metadata = {
|
||||||
'id': cl_id,
|
"id": cl_id,
|
||||||
'title': title,
|
"title": title,
|
||||||
'creator': presenter_name,
|
"creator": presenter_name,
|
||||||
'description': description,
|
"description": description,
|
||||||
'series': event_name,
|
"series": event_name,
|
||||||
'duration': duration,
|
"duration": duration,
|
||||||
'location': location,
|
"location": location,
|
||||||
}
|
}
|
||||||
self.to_screen('Event Name: %s' % event_name)
|
self.to_screen("Event Name: %s" % event_name)
|
||||||
self.to_screen('Session ID: %s' % cl_id)
|
self.to_screen("Session ID: %s" % cl_id)
|
||||||
self.to_screen('Session Title: %s' % title)
|
self.to_screen("Session Title: %s" % title)
|
||||||
self.to_screen('Presenter: %s, %s' % (presenter_name, presenter_title))
|
self.to_screen("Presenter: %s, %s" % (presenter_name, presenter_title))
|
||||||
self.to_screen('Slide Deck URL: %s' % pdf_url)
|
self.to_screen("Slide Deck URL: %s" % pdf_url)
|
||||||
self.to_screen('Video URL: %s' % bc_url)
|
self.to_screen("Video URL: %s" % bc_url)
|
||||||
return self.url_result(smuggle_url(bc_url, metadata), 'BrightcoveNew', bc_id, title)
|
return self.url_result(
|
||||||
|
smuggle_url(bc_url, metadata), "BrightcoveNew", bc_id, title
|
||||||
|
)
|
||||||
|
|
||||||
def _check_bc_url_exists(self, rf_item):
|
def _check_bc_url_exists(self, rf_item):
|
||||||
""" Checks for the existence of a Brightcove URL in a
|
""" Checks for the existence of a Brightcove URL in a
|
||||||
RainFocus result item
|
RainFocus result item
|
||||||
|
|
||||||
"""
|
"""
|
||||||
msg = "Skipping session that does not include a valid video URL: %s" % rf_item.get("title", "Unknown title")
|
msg = (
|
||||||
|
"Skipping session that does not include a valid video URL: %s"
|
||||||
|
% rf_item.get("title", "Unknown title")
|
||||||
|
)
|
||||||
try:
|
try:
|
||||||
bc_id = rf_item["videos"][0]["url"]
|
bc_id = rf_item["videos"][0]["url"]
|
||||||
mobj = re.match(r'\d+', bc_id)
|
mobj = re.match(r"\d+", bc_id)
|
||||||
if mobj:
|
if mobj:
|
||||||
return rf_item
|
return rf_item
|
||||||
else:
|
else:
|
||||||
@ -134,38 +145,38 @@ class CiscoLiveIE(InfoExtractor):
|
|||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
mobj = re.match(self._VALID_URL, url)
|
mobj = re.match(self._VALID_URL, url)
|
||||||
rf_headers = {
|
rf_headers = {
|
||||||
'Origin': 'https://ciscolive.cisco.com',
|
"Origin": "https://ciscolive.cisco.com",
|
||||||
'rfApiProfileId': self.RAINFOCUS_APIPROFILEID,
|
"rfApiProfileId": self.RAINFOCUS_APIPROFILEID,
|
||||||
'rfWidgetId': self.RAINFOCUS_WIDGETID,
|
"rfWidgetId": self.RAINFOCUS_WIDGETID,
|
||||||
'Referer': url
|
"Referer": url,
|
||||||
}
|
|
||||||
rf_args = {
|
|
||||||
'video_id': None,
|
|
||||||
'headers': rf_headers
|
|
||||||
}
|
}
|
||||||
|
rf_args = {"video_id": None, "headers": rf_headers}
|
||||||
|
|
||||||
# Single session URL (single video)
|
# Single session URL (single video)
|
||||||
if mobj.group('id'):
|
if mobj.group("id"):
|
||||||
rf_id = mobj.group('id')
|
rf_id = mobj.group("id")
|
||||||
rf_args['url_or_request'] = self.RAINFOCUS_API_URL % 'session'
|
rf_args["url_or_request"] = self.RAINFOCUS_API_URL % "session"
|
||||||
rf_args['video_id'] = rf_id
|
rf_args["video_id"] = rf_id
|
||||||
rf_args['data'] = compat_urllib_parse_urlencode({'id': rf_id})
|
rf_args["data"] = compat_urllib_parse_urlencode({"id": rf_id})
|
||||||
rf_result = self._download_json(**rf_args)
|
rf_result = self._download_json(**rf_args)
|
||||||
rf_item = self._check_bc_url_exists(rf_result['items'][0])
|
rf_item = self._check_bc_url_exists(rf_result["items"][0])
|
||||||
return self._parse_rf_item(rf_item)
|
return self._parse_rf_item(rf_item)
|
||||||
else:
|
else:
|
||||||
# Filter query URL (multiple videos)
|
# Filter query URL (multiple videos)
|
||||||
if mobj.group('query'):
|
if mobj.group("query"):
|
||||||
rf_query = mobj.group('query')
|
rf_query = mobj.group("query")
|
||||||
rf_query = str(rf_query + '&type=session&size=1000')
|
rf_query = str(rf_query + "&type=session&size=1000")
|
||||||
rf_args['url_or_request'] = self.RAINFOCUS_API_URL % 'search'
|
rf_args["url_or_request"] = self.RAINFOCUS_API_URL % "search"
|
||||||
rf_args['data'] = rf_query
|
rf_args["data"] = rf_query
|
||||||
# Query JSON results offer no obvious way to ID the search
|
# Query JSON results offer no obvious way to ID the search
|
||||||
rf_args['video_id'] = 'Filter query'
|
rf_args["video_id"] = "Filter query"
|
||||||
self.to_screen('Video collection for filter query "%s"' % rf_query)
|
self.to_screen('Video collection for filter query "%s"' % rf_query)
|
||||||
rf_results = self._download_json(**rf_args)
|
rf_results = self._download_json(**rf_args)
|
||||||
# Not all sessions have videos; filter them out before moving on
|
# Not all sessions have videos; filter them out before moving on
|
||||||
rf_video_results = [rf_item for rf_item in rf_results["sectionList"][0]["items"]
|
rf_video_results = [
|
||||||
if self._check_bc_url_exists(rf_item)]
|
rf_item
|
||||||
|
for rf_item in rf_results["sectionList"][0]["items"]
|
||||||
|
if self._check_bc_url_exists(rf_item)
|
||||||
|
]
|
||||||
entries = [self._parse_rf_item(rf_item) for rf_item in rf_video_results]
|
entries = [self._parse_rf_item(rf_item) for rf_item in rf_video_results]
|
||||||
return self.playlist_result(entries)
|
return self.playlist_result(entries)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user