1
0
mirror of https://codeberg.org/polarisfm/youtube-dl synced 2024-11-26 02:14:32 +01:00

[Panopto] Bring the code in line with conventions

This commit is contained in:
Kevin Mark 2017-07-06 21:32:17 -04:00
parent a29e634cfe
commit fed0a6a939

View File

@ -39,7 +39,9 @@ class PanoptoIE(PanoptoBaseIE):
"""Returns a comma-delimited string of contributors.""" """Returns a comma-delimited string of contributors."""
s = '' s = ''
for c in contribs: for c in contribs:
s += '{}, ' .format(c['DisplayName']) display_name = c.get('DisplayName')
if display_name is not None:
s += '{}, '.format(display_name)
return s[:-2] if len(contribs) else '' return s[:-2] if len(contribs) else ''
def _real_extract(self, url): def _real_extract(self, url):
@ -69,8 +71,7 @@ class PanoptoIE(PanoptoBaseIE):
"with Panopto. If the error below is about unauthorized access, this is " "with Panopto. If the error below is about unauthorized access, this is "
"most likely the issue.") "most likely the issue.")
raise ExtractorError( raise ExtractorError(
'API error: ({}) {}'.format(delivery_info['ErrorCode'], 'API error: ({}) {}'.format(delivery_info.get('ErrorCode', '?'), delivery_info.get('ErrorMessage', '?'))
delivery_info['ErrorMessage'] if 'ErrorMessage' in delivery_info else '')
) )
streams = [] streams = []
@ -107,24 +108,39 @@ class PanoptoIE(PanoptoBaseIE):
result['_type'] = 'multi_video' result['_type'] = 'multi_video'
result['entries'] = streams result['entries'] = streams
if 'Contributors' in delivery_info['Delivery']: # We already know Delivery exists since we need it for stream extraction
result['uploader'] = self._get_contribs_str(delivery_info['Delivery']['Contributors']) contributors = delivery_info['Delivery'].get('Contributors')
if contributors is not None:
result['uploader'] = self._get_contribs_str(contributors)
if 'SessionStartTime' in delivery_info['Delivery']: session_start_time = delivery_info['Delivery'].get('SessionStartTime')
result['timestamp'] = delivery_info['Delivery']['SessionStartTime'] - 11640000000 if session_start_time is not None:
result['timestamp'] = session_start_time - 11640000000
if 'Duration' in delivery_info['Delivery']: duration = delivery_info['Delivery'].get('Duration')
result['duration'] = delivery_info['Delivery']['Duration'] if duration is not None:
result['duration'] = duration
thumbnails = [] thumbnails = []
if 'Timestamps' in delivery_info['Delivery']: if 'Timestamps' in delivery_info['Delivery']:
for timestamp in delivery_info['Delivery']['Timestamps']: for timestamp in delivery_info['Delivery']['Timestamps']:
thumbnails.append({ object_id = timestamp.get('ObjectIdentifier')
# 'url': 'https://{}.hosted.panopto.com/Panopto/Pages/Viewer/Thumb.aspx?eventTargetPID={}&sessionPID={}&number={}&isPrimary=false&absoluteTime={}'.format( object_sequence_num = timestamp.get('ObjectSequenceNumber')
# org, timestamp['ObjectPublicIdentifier'], timestamp['SessionID'], timestamp['ObjectSequenceNumber'], timestamp['AbsoluteTime']), if object_id is not None and object_sequence_num is not None:
'url': 'https://{}.hosted.panopto.com/Panopto/Pages/Viewer/Image.aspx?id={}&number={}&x=undefined'.format( thumbnails.append({
org, timestamp['ObjectIdentifier'], timestamp['ObjectSequenceNumber']) 'url': 'https://{}.hosted.panopto.com/Panopto/Pages/Viewer/Image.aspx?id={}&number={}&x=undefined'.format(
}) org, object_id, object_sequence_num)
})
# This provides actual thumbnails instead of the above which allows for downloading of real slides
# object_public_id = timestamp.get('ObjectPublicIdentifier')
# session_id = timestamp.get('SessionID')
# absolute_time = timestamp.get('AbsoluteTime')
# if object_public_id is not None and session_id is not None and object_sequence_num is not None and absolute_time is not None:
# thumbnails.append({
# 'url': 'https://{}.hosted.panopto.com/Panopto/Pages/Viewer/Thumb.aspx?eventTargetPID={}&sessionPID={}&number={}&isPrimary=false&absoluteTime={}'.format(
# org, object_public_id, session_id, object_sequence_num, absolute_time),
# })
if len(thumbnails): if len(thumbnails):
if result.get('entries') is not None: if result.get('entries') is not None: