From fe063377e6e3aef5dc83030fd39baf93a353949f Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 13 Jan 2022 15:30:55 +0000 Subject: [PATCH] Tidying --- newswire.py | 72 +++++++++++++++++++++++++++++------------------------ 1 file changed, 40 insertions(+), 32 deletions(-) diff --git a/newswire.py b/newswire.py index 5888206c0..a65dafe47 100644 --- a/newswire.py +++ b/newswire.py @@ -384,6 +384,45 @@ def _xml2str_to_hashtag_categories(base_dir: str, xml_str: str, False, force) +def _get_podcast_categories(xml_item: str, xml_str: str) -> str: + """ get podcast categories if they exist. These can be turned into hashtags + """ + podcast_categories = [] + episode_category_tags = ['' in episode_category: + episode_category = episode_category.split('>')[1] + if '<' in episode_category: + episode_category = episode_category.split('<')[0] + episode_category = \ + episode_category.lower().replace(' ', '') + episode_category = episode_category.replace('#', '') + if episode_category not in podcast_categories: + if valid_hash_tag(episode_category): + podcast_categories.append('#' + episode_category) + + return podcast_categories + + def xml_podcast_to_dict(xml_item: str, xml_str: str) -> {}: """podcasting extensions for RSS feeds See https://github.com/Podcastindex-org/podcast-namespace/ @@ -476,38 +515,7 @@ def xml_podcast_to_dict(xml_item: str, xml_str: str) -> {}: break # get categories if they exist. These can be turned into hashtags - podcast_categories = [] - episode_category_tags = ['' in episode_category: - episode_category = episode_category.split('>')[1] - if '<' in episode_category: - episode_category = episode_category.split('<')[0] - episode_category = \ - episode_category.lower().replace(' ', '') - episode_category = episode_category.replace('#', '') - if episode_category not in podcast_categories: - if valid_hash_tag(episode_category): - podcast_categories.append('#' + episode_category) - continue + podcast_categories = _get_podcast_categories(xml_item, xml_str) if podcast_episode_image: podcast_properties['image'] = podcast_episode_image