Podcasts may not have people list

main
Bob Mottram 2022-01-12 17:44:49 +00:00
parent 8686a29ac1
commit d5553fe8a0
3 changed files with 23 additions and 7 deletions

View File

@ -14071,6 +14071,7 @@ class PubServer(BaseHTTPRequestHandler):
nickname = nickname.split('/')[0]
episode_timestamp = self.path.split('?podepisode=')[1].strip()
episode_timestamp = episode_timestamp.replace('__', ' ')
episode_timestamp = episode_timestamp.replace('aa', ':')
if self.server.newswire.get(episode_timestamp):
pod_episode = self.server.newswire[episode_timestamp]
html_str = \

View File

@ -384,10 +384,9 @@ def xml_podcast_to_dict(xml_str: str) -> {}:
See https://github.com/Podcastindex-org/podcast-namespace/
blob/main/docs/1.0.md
"""
if 'podcastindex.org/namespace/1.0' not in xml_str:
return {}
if '<podcast:' not in xml_str:
return {}
if '<itunes:' not in xml_str:
return {}
podcast_properties = {
"locations": [],
@ -446,6 +445,7 @@ def xml_podcast_to_dict(xml_str: str) -> {}:
ctr += 1
# get the image for the podcast, if it exists
podcast_episode_image = None
episode_image_tags = ['<itunes:image']
for image_tag in episode_image_tags:
if image_tag not in xml_str:
@ -455,7 +455,7 @@ def xml_podcast_to_dict(xml_str: str) -> {}:
episode_image = episode_image.split('href="')[1]
if '"' in episode_image:
episode_image = episode_image.split('"')[0]
podcast_properties['image'] = episode_image
podcast_episode_image = episode_image
break
else:
if '>' in episode_image:
@ -463,8 +463,22 @@ def xml_podcast_to_dict(xml_str: str) -> {}:
if '<' in episode_image:
episode_image = episode_image.split('<')[0]
if '://' in episode_image and '.' in episode_image:
podcast_properties['image'] = episode_image
podcast_episode_image = episode_image
break
if podcast_episode_image:
podcast_properties['image'] = podcast_episode_image
if '<itunes:explicit>Y' in xml_str or \
'<itunes:explicit>T' in xml_str or \
'<itunes:explicit>1' in xml_str:
podcast_properties['explicit'] = True
else:
podcast_properties['explicit'] = False
else:
if '<podcast:' not in xml_str:
return {}
return podcast_properties

View File

@ -270,9 +270,10 @@ def _html_newswire(base_dir: str, newswire: {}, nickname: str, moderator: bool,
# change the link url to a podcast episode screen
podcast_properties = item[8]
if podcast_properties:
if podcast_properties.get('persons') and \
podcast_properties.get('image'):
if podcast_properties.get('image') and \
'explicit' in podcast_properties:
episode_id = date_str.replace(' ', '__')
episode_id = episode_id.replace(':', 'aa')
link_url = \
'/users/' + nickname + '/?podepisode=' + episode_id