\n'
return podcast_str
def _html_podcast_performers(podcast_properties: {}) -> str:
"""Returns html for performers of a podcast
"""
if not podcast_properties:
return ''
if not podcast_properties.get('persons'):
return ''
# list of performers
podcast_str = '
\n'
podcast_str += '
\n'
podcast_str += '
\n'
for performer in podcast_properties['persons']:
if not performer.get('text'):
continue
performer_name = performer['text']
performer_title = performer_name
if performer.get('role'):
performer_title += ' (' + performer['role'] + ')'
if performer.get('group'):
performer_title += ', ' + performer['group'] + ''
performer_title = remove_html(performer_title)
performer_url = ''
if performer.get('href'):
performer_url = performer['href']
performer_img = ''
if performer.get('img'):
performer_img = performer['img']
podcast_str += '
\n'
podcast_str += ' \n'
podcast_str += '
\n'
podcast_str += '
\n'
podcast_str += '
\n'
return podcast_str
def _html_podcast_soundbites(link_url: str, extension: str,
podcast_properties: {},
translate: {}) -> str:
"""Returns html for podcast soundbites
"""
if not podcast_properties:
return ''
if not podcast_properties.get('soundbites'):
return ''
podcast_str = '
\n'
podcast_str += '
\n'
podcast_str += '
\n'
ctr = 1
for performer in podcast_properties['soundbites']:
if not performer.get('startTime'):
continue
if not performer['startTime'].isdigit():
continue
if not performer.get('duration'):
continue
if not performer['duration'].isdigit():
continue
end_time = str(float(performer['startTime']) +
float(performer['duration']))
podcast_str += '
\n'
audio_extension = None
if path_is_audio(link_url):
if '.mp3' in link_url:
audio_extension = 'mpeg'
else:
audio_extension = 'ogg'
else:
if podcast_properties.get('linkMimeType'):
if 'audio' in podcast_properties['linkMimeType']:
audio_extension = \
podcast_properties['linkMimeType'].split('/')[1]
# show widgets for soundbites
if audio_extension:
podcast_str += _html_podcast_soundbites(link_url, audio_extension,
podcast_properties,
translate)
# podcast player widget
podcast_str += \
' \n'
elif podcast_properties.get('linkMimeType'):
if '/youtube' in podcast_properties['linkMimeType']:
url = link_url.replace('/watch?v=', '/embed/')
if '&' in url:
url = url.split('&')[0]
if '?utm_' in url:
url = url.split('?utm_')[0]
podcast_str += \
" \n"
elif 'video' in podcast_properties['linkMimeType']:
video_mime_type = podcast_properties['linkMimeType']
video_msg = 'Your browser does not support the video element.'
podcast_str += \
' \n'
podcast_title = \
remove_html(html.unescape(urllib.parse.unquote_plus(newswire_item[0])))
if podcast_title:
podcast_str += \
'\n'
if newswire_item[4]:
podcast_description = \
html.unescape(urllib.parse.unquote_plus(newswire_item[4]))
podcast_description = safe_web_text(podcast_description)
if podcast_description:
podcast_str += '
' + podcast_description + '
\n'
# donate button
if podcast_properties.get('funding'):
if podcast_properties['funding'].get('url'):
donate_url = podcast_properties['funding']['url']
podcast_str += \
'
\n'
if podcast_properties['categories']:
podcast_str += '
'
tags_str = ''
for tag in podcast_properties['categories']:
tag_link = '/users/' + nickname + '/tags/' + tag.replace('#', '')
tags_str += '' + tag + ' '
podcast_str += tags_str.strip() + '