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

[Panopto] Replace % with format() wrt PEP 3101

This commit is contained in:
Kevin Mark 2017-07-06 20:39:39 -04:00
parent bd7d8149d7
commit 0807e39d85

View File

@ -37,7 +37,7 @@ class PanoptoIE(PanoptoBaseIE):
def _get_contribs_str(contribs): def _get_contribs_str(contribs):
s = '' s = ''
for c in contribs: for c in contribs:
s += '%s, ' % c['DisplayName'] s += '{}, ' .format(c['DisplayName'])
return s[:-2] if len(contribs) else '' return s[:-2] if len(contribs) else ''
def _real_extract(self, url): def _real_extract(self, url):
@ -45,7 +45,7 @@ class PanoptoIE(PanoptoBaseIE):
org = self._match_organization(url) org = self._match_organization(url)
delivery_info = self._download_json( delivery_info = self._download_json(
'https://%s.hosted.panopto.com/Panopto/Pages/Viewer/DeliveryInfo.aspx' % org, 'https://{}.hosted.panopto.com/Panopto/Pages/Viewer/DeliveryInfo.aspx'.format(org),
video_id, video_id,
query={ query={
'deliveryId': video_id, 'deliveryId': video_id,
@ -66,8 +66,8 @@ 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: (%s) %s' % 'API error: ({}) {}'.format(delivery_info['ErrorCode'],
(delivery_info['ErrorCode'], delivery_info['ErrorMessage'] if 'ErrorMessage' in delivery_info else '') delivery_info['ErrorMessage'] if 'ErrorMessage' in delivery_info else '')
) )
streams = [] streams = []
@ -94,8 +94,8 @@ class PanoptoIE(PanoptoBaseIE):
result = { result = {
'id': video_id, 'id': video_id,
'title': delivery_info['Delivery']['SessionName'], 'title': delivery_info['Delivery']['SessionName'],
'thumbnail': 'https://%s.hosted.panopto.com/Panopto/Services/FrameGrabber.svc/FrameRedirect?objectId=%s&mode=Delivery&random=%s' % 'thumbnail': 'https://{}.hosted.panopto.com/Panopto/Services/FrameGrabber.svc/FrameRedirect?objectId={}&mode=Delivery&random={}'.format(
(org, video_id, random()), org, video_id, random()),
} }
if len(streams) == 1: if len(streams) == 1:
@ -117,10 +117,10 @@ class PanoptoIE(PanoptoBaseIE):
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({ thumbnails.append({
# 'url': 'https://%s.hosted.panopto.com/Panopto/Pages/Viewer/Thumb.aspx?eventTargetPID=%s&sessionPID=%s&number=%s&isPrimary=false&absoluteTime=%s' % # 'url': 'https://{}.hosted.panopto.com/Panopto/Pages/Viewer/Thumb.aspx?eventTargetPID={}&sessionPID={}&number={}&isPrimary=false&absoluteTime={}'.format(
# (org, timestamp['ObjectPublicIdentifier'], timestamp['SessionID'], timestamp['ObjectSequenceNumber'], timestamp['AbsoluteTime']), # org, timestamp['ObjectPublicIdentifier'], timestamp['SessionID'], timestamp['ObjectSequenceNumber'], timestamp['AbsoluteTime']),
'url': 'https://%s.hosted.panopto.com/Panopto/Pages/Viewer/Image.aspx?id=%s&number=%s&x=undefined' % 'url': 'https://{}.hosted.panopto.com/Panopto/Pages/Viewer/Image.aspx?id={}&number={}&x=undefined'.format(
(org, timestamp['ObjectIdentifier'], timestamp['ObjectSequenceNumber']) org, timestamp['ObjectIdentifier'], timestamp['ObjectSequenceNumber'])
}) })
if len(thumbnails): if len(thumbnails):
@ -145,7 +145,7 @@ class PanoptoFolderIE(PanoptoBaseIE):
org = self._match_organization(url) org = self._match_organization(url)
folder_data = self._download_json( folder_data = self._download_json(
'https://%s.hosted.panopto.com/Panopto/Services/Data.svc/GetSessions' % org, 'https://{}.hosted.panopto.com/Panopto/Services/Data.svc/GetSessions'.format(org),
folder_id, folder_id,
'Downloading folder listing', 'Downloading folder listing',
'Failed to download folder listing', 'Failed to download folder listing',
@ -190,8 +190,8 @@ class PanoptoFolderIE(PanoptoBaseIE):
} }
if 'prev_folders' in smuggled: if 'prev_folders' in smuggled:
new_folder['title'] = smuggled['prev_folders'] + ' -- ' + new_folder['title'] new_folder['title'] = smuggled['prev_folders'] + ' -- ' + new_folder['title']
new_folder['url'] = smuggle_url('https://%s.hosted.panopto.com/Panopto/Pages/Sessions/List.aspx#folderID="%s"' % new_folder['url'] = smuggle_url('https://{}.hosted.panopto.com/Panopto/Pages/Sessions/List.aspx#folderID="{}"'
(org, subfolder['ID']), {'prev_folders': new_folder['title']}) .format(org, subfolder['ID']), {'prev_folders': new_folder['title']})
entries.append(new_folder) entries.append(new_folder)
if not entries: if not entries: