mirror of
https://github.com/l1ving/youtube-dl
synced 2025-03-10 17:17:15 +08:00
[ciscolive] Changes requested by maintainers
This commit is contained in:
parent
112db624e1
commit
2f72407593
0
youtube_dl/extractor/brightcove.py
Executable file → Normal file
0
youtube_dl/extractor/brightcove.py
Executable file → Normal file
62
youtube_dl/extractor/ciscolive.py
Executable file → Normal file
62
youtube_dl/extractor/ciscolive.py
Executable file → Normal file
@ -8,10 +8,10 @@ from ..compat import (
|
||||
compat_parse_qs
|
||||
)
|
||||
from ..utils import (
|
||||
try_get,
|
||||
clean_html,
|
||||
int_or_none,
|
||||
try_get,
|
||||
urlencode_postdata,
|
||||
int_or_none
|
||||
)
|
||||
|
||||
|
||||
@ -25,8 +25,8 @@ class CiscoLiveIE(InfoExtractor):
|
||||
'info_dict': {
|
||||
'id': '5803694304001',
|
||||
'ext': 'mp4',
|
||||
'title': '13 Smart Automations to Monitor Your Cisco IOS Network [BRKNMS-2465]',
|
||||
'description': 'md5:171c3a1c0469c126d01f083a83d6c60b',
|
||||
'title': '13 Smart Automations to Monitor Your Cisco IOS Network',
|
||||
'description': 'md5:ec4a436019e09a918dec17714803f7cc',
|
||||
'timestamp': 1530305395,
|
||||
'uploader_id': '5647924234001',
|
||||
'upload_date': '20180629',
|
||||
@ -38,11 +38,11 @@ class CiscoLiveIE(InfoExtractor):
|
||||
'md5': '993d4cf051f6174059328b1dce8e94bd',
|
||||
'info_dict': {
|
||||
'upload_date': '20180629',
|
||||
'title': 'DevNet Panel-Applying Design Thinking to Building Products in Cisco [DEVNET-1794]',
|
||||
'title': 'DevNet Panel-Applying Design Thinking to Building Products in Cisco',
|
||||
'timestamp': 1530316421,
|
||||
'uploader_id': '5647924234001',
|
||||
'id': '5803751616001',
|
||||
'description': 'md5:291dbd447bf745d1f61d944d9508538f',
|
||||
'description': 'md5:5f144575cd6848117fe2f756855b038b',
|
||||
'location': 'WoS, DevNet Theater',
|
||||
'ext': 'mp4',
|
||||
},
|
||||
@ -52,11 +52,11 @@ class CiscoLiveIE(InfoExtractor):
|
||||
'md5': '80e0c3b87e373fe3a3316b934b8915bf',
|
||||
'info_dict': {
|
||||
'upload_date': '20180629',
|
||||
'title': 'Beating the CCIE Routing & Switching [BRKCCIE-9162]',
|
||||
'title': 'Beating the CCIE Routing & Switching',
|
||||
'timestamp': 1530311842,
|
||||
'uploader_id': '5647924234001',
|
||||
'id': '5803735679001',
|
||||
'description': 'md5:18bf6e8a634df0a51290401f209089b0',
|
||||
'description': 'md5:e71970799e92d7f5ff57ae23f64b0929',
|
||||
'location': 'Tulúm 02',
|
||||
'ext': 'mp4',
|
||||
},
|
||||
@ -71,16 +71,11 @@ class CiscoLiveIE(InfoExtractor):
|
||||
BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/5647924234001/SyK2FdqjM_default/index.html?videoId=%s'
|
||||
|
||||
def _parse_rf_item(self, rf_item):
|
||||
''' Parses metadata and passes to Brightcove extractor
|
||||
|
||||
'''
|
||||
''' Parses metadata and passes to Brightcove extractor '''
|
||||
event_name = rf_item.get('eventName')
|
||||
cl_id = rf_item.get('abbreviation')
|
||||
title = rf_item.get('title')
|
||||
title = rf_item['title']
|
||||
description = clean_html(rf_item.get('abstract'))
|
||||
presenter_name = try_get(rf_item, lambda x: x['participants'][0]['fullName'])
|
||||
presenter_title = try_get(rf_item, lambda x: x['participants'][0]['jobTitle'])
|
||||
pdf_url = try_get(rf_item, lambda x: x['files'][0]['url'])
|
||||
bc_id = rf_item['videos'][0]['url']
|
||||
bc_url = self.BRIGHTCOVE_URL_TEMPLATE % bc_id
|
||||
duration = int_or_none(try_get(rf_item, lambda x: x['times'][0]['length']))
|
||||
@ -91,31 +86,26 @@ class CiscoLiveIE(InfoExtractor):
|
||||
|
||||
return {
|
||||
'_type': 'url_transparent',
|
||||
'url': bc_url,
|
||||
'id': cl_id,
|
||||
'title': '%s [%s]' % (title, cl_id),
|
||||
'creator': '%s, %s' % (presenter_name, presenter_title),
|
||||
'description': '%s\n\nVideo Player: %s\nSlide Deck: %s' % (description, bc_url, pdf_url),
|
||||
'series': event_name,
|
||||
'creator': presenter_name,
|
||||
'description': description,
|
||||
'duration': duration,
|
||||
'location': location,
|
||||
'ie_key': 'BrightcoveNew',
|
||||
'location': location,
|
||||
'series': event_name,
|
||||
'title': title,
|
||||
'url': bc_url,
|
||||
}
|
||||
|
||||
def _check_bc_id_exists(self, rf_item):
|
||||
''' Checks for the existence of a Brightcove URL in a
|
||||
RainFocus result item
|
||||
|
||||
'''
|
||||
''' Checks for the existence of a Brightcove URL in an API result '''
|
||||
bc_id = try_get(rf_item, lambda x: x['videos'][0]['url'])
|
||||
if bc_id:
|
||||
mobj = re.match(r'\d+', bc_id)
|
||||
if mobj:
|
||||
if bc_id.strip().isdigit():
|
||||
return rf_item
|
||||
|
||||
def _real_extract(self, url):
|
||||
mobj = re.match(self._VALID_URL, url)
|
||||
headers = {
|
||||
HEADERS = {
|
||||
'Origin': 'https://ciscolive.cisco.com',
|
||||
'rfApiProfileId': self.RAINFOCUS_APIPROFILEID,
|
||||
'rfWidgetId': self.RAINFOCUS_WIDGETID,
|
||||
@ -126,7 +116,7 @@ class CiscoLiveIE(InfoExtractor):
|
||||
rf_id = mobj.group('id')
|
||||
request = self.RAINFOCUS_API_URL % 'session'
|
||||
data = urlencode_postdata({'id': rf_id})
|
||||
rf_result = self._download_json(request, rf_id, data=data, headers=headers)
|
||||
rf_result = self._download_json(request, rf_id, data=data, headers=HEADERS)
|
||||
rf_item = self._check_bc_id_exists(rf_result['items'][0])
|
||||
return self._parse_rf_item(rf_item)
|
||||
else:
|
||||
@ -136,13 +126,11 @@ class CiscoLiveIE(InfoExtractor):
|
||||
rf_query['size'] = 1000
|
||||
data = urlencode_postdata(rf_query)
|
||||
request = self.RAINFOCUS_API_URL % 'search'
|
||||
# Query JSON results offer no obvious way to ID the search
|
||||
rf_results = self._download_json(request, 'Filter query', data=data, headers=headers)
|
||||
# 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_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']
|
||||
if self._check_bc_id_exists(rf_item)
|
||||
]
|
||||
entries = [self._parse_rf_item(rf_item) for rf_item in rf_video_results]
|
||||
return self.playlist_result(entries, 'Filter query')
|
||||
|
0
youtube_dl/extractor/extractors.py
Executable file → Normal file
0
youtube_dl/extractor/extractors.py
Executable file → Normal file
Loading…
x
Reference in New Issue
Block a user