Show author on podcast screen

main
Bob Mottram 2023-12-05 11:32:34 +00:00
parent b976ae65f6
commit b1ed807cdf
3 changed files with 35 additions and 0 deletions

View File

@ -1,3 +1,4 @@
37C3
Blue Blue
Debian Debian
Default Default

View File

@ -478,6 +478,30 @@ def _get_podcast_categories(xml_item: str, xml_str: str) -> str:
return podcast_categories return podcast_categories
def _get_podcast_author(xml_item: str, xml_str: str) -> str:
""" get podcast author if specified.
"""
author = None
episode_author_tags = ['<itunes:author', '<author']
for author_tag in episode_author_tags:
item_str = xml_item
if author_tag not in xml_item:
if author_tag not in xml_str:
continue
item_str = xml_str
author_str = item_str.split(author_tag)[1]
if '>' not in author_str:
continue
author_str = author_str.split('>')[1]
if '<' not in author_str:
continue
author = item_str.split('>')[0]
return remove_html(author).strip()
return author
def _valid_podcast_entry(base_dir: str, key: str, entry: {}) -> bool: def _valid_podcast_entry(base_dir: str, key: str, entry: {}) -> bool:
"""Is the given podcast namespace entry valid? """Is the given podcast namespace entry valid?
https://github.com/Podcastindex-org/podcast-namespace/ https://github.com/Podcastindex-org/podcast-namespace/
@ -623,6 +647,11 @@ def xml_podcast_to_dict(base_dir: str, xml_item: str, xml_str: str) -> {}:
# get categories if they exist. These can be turned into hashtags # get categories if they exist. These can be turned into hashtags
podcast_categories = _get_podcast_categories(xml_item, xml_str) podcast_categories = _get_podcast_categories(xml_item, xml_str)
# get the author name
podcast_author = _get_podcast_author(xml_item, xml_str)
if podcast_author:
podcast_properties['author'] = podcast_author
if podcast_episode_image: if podcast_episode_image:
podcast_properties['image'] = podcast_episode_image podcast_properties['image'] = podcast_episode_image
podcast_properties['categories'] = podcast_categories podcast_properties['categories'] = podcast_categories

View File

@ -419,6 +419,11 @@ def html_podcast_episode(translate: {},
'<span itemprop="headline">' + \ '<span itemprop="headline">' + \
podcast_title + \ podcast_title + \
'</span></label></p>\n' '</span></label></p>\n'
if podcast_properties.get('author'):
author = podcast_properties['author']
podcast_str += '<p>' + author + '</p>\n'
transcripts = _html_podcast_transcripts(podcast_properties, translate) transcripts = _html_podcast_transcripts(podcast_properties, translate)
if transcripts: if transcripts:
podcast_str += '<p>' + transcripts + '</p>\n' podcast_str += '<p>' + transcripts + '</p>\n'