diff --git a/newswire.py b/newswire.py index 717b706d5..0bd032607 100644 --- a/newswire.py +++ b/newswire.py @@ -501,7 +501,7 @@ def xml_podcast_to_dict(xml_item: str, xml_str: str) -> {}: # get the image for the podcast, if it exists podcast_episode_image = None - episode_image_tags = [' {}: episode_image = episode_image.split('"')[0] podcast_episode_image = episode_image break + elif 'url="' in episode_image: + episode_image = episode_image.split('url="')[1] + if '"' in episode_image: + episode_image = episode_image.split('"')[0] + podcast_episode_image = episode_image + break else: if '>' in episode_image: episode_image = episode_image.split('>')[1] @@ -1019,9 +1025,15 @@ def _atom_feed_yt_to_dict(base_dir: str, domain: str, xml_str: str, description = atom_item.split('')[1] description = description.split('')[0] description = remove_html(description) - link = atom_item.split('')[1] - link = link.split('')[0] - link = 'https://www.youtube.com/watch?v=' + link.strip() + + link, link_mime_type = get_link_from_rss_item(atom_item) + if not link: + link = atom_item.split('')[1] + link = link.split('')[0] + link = 'https://www.youtube.com/watch?v=' + link.strip() + if not link: + continue + pub_date = atom_item.split('')[1] pub_date = pub_date.split('')[0] @@ -1030,13 +1042,16 @@ def _atom_feed_yt_to_dict(base_dir: str, domain: str, xml_str: str, if _valid_feed_date(pub_date_str): post_filename = '' votes_status = [] + podcast_properties = xml_podcast_to_dict(atom_item, xml_str) + if podcast_properties: + podcast_properties['linkMimeType'] = link_mime_type _add_newswire_dict_entry(base_dir, domain, result, pub_date_str, title, link, votes_status, post_filename, description, moderated, mirrored, [], 32, session, debug, - None) + podcast_properties) post_ctr += 1 if post_ctr >= max_posts_per_source: break