From dd67e64417f5dd7afa77d3d4e9c39e0b36d652c6 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 13 Jan 2022 20:48:31 +0000 Subject: [PATCH 1/7] Set audio player width within posts --- epicyon-profile.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/epicyon-profile.css b/epicyon-profile.css index 22801b1e6..f8f6f27f2 100644 --- a/epicyon-profile.css +++ b/epicyon-profile.css @@ -223,6 +223,10 @@ body, html { image-rendering: var(--rendering); } +audio { + width: 100%; +} + video { width: 100%; } From 3d2072aae906a4d0d108887cb144751ce135ff0a Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 13 Jan 2022 21:16:52 +0000 Subject: [PATCH 2/7] Add nsfw hashtag to podcasts marked as explicit --- newswire.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/newswire.py b/newswire.py index d30025dfb..915a63c54 100644 --- a/newswire.py +++ b/newswire.py @@ -226,6 +226,9 @@ def _add_newswire_dict_entry(base_dir: str, domain: str, # extract hashtags from the text of the feed post post_tags = get_newswire_tags(all_text, max_tags) + if podcast_properties.get('explicit'): + post_tags.append('#NSFW') + # Include tags from podcast categories if podcast_properties: post_tags += podcast_properties['categories'] From f49863e5d7391c2613b28917b9bc79bc4cac853e Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 13 Jan 2022 21:19:51 +0000 Subject: [PATCH 3/7] Check for duplicates --- newswire.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/newswire.py b/newswire.py index 915a63c54..394f97ab4 100644 --- a/newswire.py +++ b/newswire.py @@ -227,7 +227,8 @@ def _add_newswire_dict_entry(base_dir: str, domain: str, post_tags = get_newswire_tags(all_text, max_tags) if podcast_properties.get('explicit'): - post_tags.append('#NSFW') + if '#NSFW' not in post_tags: + post_tags.append('#NSFW') # Include tags from podcast categories if podcast_properties: From f8ee7e4da51a33bb9fe483fc45b2b8b032d87081 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 13 Jan 2022 22:26:01 +0000 Subject: [PATCH 4/7] Different rss link style --- newswire.py | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/newswire.py b/newswire.py index 394f97ab4..356f5912d 100644 --- a/newswire.py +++ b/newswire.py @@ -567,10 +567,20 @@ def get_link_from_rss_item(rss_item: str) -> (str, str): if '://' in link: return link, mime_type - link = rss_item.split('')[1] - link = link.split('')[0] - if '://' not in link: - return None, None + if '' in rss_item and '' in rss_item: + link = rss_item.split('')[1] + link = link.split('')[0] + if '://' not in link: + return None, None + elif '' in link_str: + link_str = link_str.split('>')[0] + if 'href="' in link_str: + link_str = link_str.split('href="')[1] + if '"' in link_str: + link = link_str.split('"')[0] + return link, mime_type @@ -609,9 +619,7 @@ def _xml2str_to_dict(base_dir: str, domain: str, xml_str: str, continue if '' not in rss_item: continue - if '' not in rss_item: - continue - if '' not in rss_item: + if '' not in rss_item: continue @@ -708,9 +716,7 @@ def _xml1str_to_dict(base_dir: str, domain: str, xml_str: str, continue if '' not in rss_item: continue - if '' not in rss_item: - continue - if '' not in rss_item: + if '' not in rss_item: continue @@ -793,9 +799,7 @@ def _atom_feed_to_dict(base_dir: str, domain: str, xml_str: str, continue if '' not in atom_item: continue - if '' not in atom_item: - continue - if '' not in atom_item: + if '' not in atom_item: continue From 7a04a9f323afe59012507193daa7ba2c342a9c5f Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 13 Jan 2022 22:37:53 +0000 Subject: [PATCH 5/7] Unit test for rss link --- tests.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests.py b/tests.py index 4d086b1f8..ea7349a6c 100644 --- a/tests.py +++ b/tests.py @@ -6477,6 +6477,16 @@ def _test_get_link_from_rss_item() -> None: assert link.startswith('https://anchor.fm') assert not mime_type + rss_item = \ + '' + \ + 'Wed, 12 Jan 2022 14:28:46 GMT' + link, mime_type = get_link_from_rss_item(rss_item) + assert link + assert link.startswith('https://test.link/creativecommons') + def run_all_tests(): base_dir = os.getcwd() From b2f9a046edaddc3ff4fad6f0e55910b3846a8dcd Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 13 Jan 2022 22:57:16 +0000 Subject: [PATCH 6/7] Skip first entry in atom feed --- newswire.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/newswire.py b/newswire.py index 356f5912d..f561ef53c 100644 --- a/newswire.py +++ b/newswire.py @@ -983,7 +983,11 @@ def _atom_feed_yt_to_dict(base_dir: str, domain: str, xml_str: str, atom_items = xml_str.split('') post_ctr = 0 max_bytes = max_feed_item_size_kb * 1024 + first_entry = True for atom_item in atom_items: + if first_entry: + first_entry = False + continue if not atom_item: continue if not atom_item.strip(): From 838868e81127b7254933e626d07c623384e6d386 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 13 Jan 2022 23:06:04 +0000 Subject: [PATCH 7/7] Check that properties exist --- newswire.py | 8 ++++---- webapp_podcast.py | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/newswire.py b/newswire.py index f561ef53c..425220c5b 100644 --- a/newswire.py +++ b/newswire.py @@ -226,12 +226,12 @@ def _add_newswire_dict_entry(base_dir: str, domain: str, # extract hashtags from the text of the feed post post_tags = get_newswire_tags(all_text, max_tags) - if podcast_properties.get('explicit'): - if '#NSFW' not in post_tags: - post_tags.append('#NSFW') - # Include tags from podcast categories if podcast_properties: + if podcast_properties.get('explicit'): + if '#NSFW' not in post_tags: + post_tags.append('#NSFW') + post_tags += podcast_properties['categories'] # combine the tags into a single list diff --git a/webapp_podcast.py b/webapp_podcast.py index 1f30c36d2..b4d3ae48e 100644 --- a/webapp_podcast.py +++ b/webapp_podcast.py @@ -23,6 +23,8 @@ from webapp_utils import html_keyboard_navigation 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 '' @@ -72,6 +74,8 @@ def _html_podcast_soundbites(link_url: str, extension: str, translate: {}) -> str: """Returns html for podcast soundbites """ + if not podcast_properties: + return '' if not podcast_properties.get('soundbites'): return ''