From 08df47318f1682bd4cd4f81b1e901e42f6b057fc Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 20 Oct 2022 20:37:59 +0100 Subject: [PATCH] Support speex audio format --- content.py | 1 + daemon.py | 2 +- epicyon.py | 6 +++--- manual/manual.md | 2 ++ media.py | 4 ++++ metadata.py | 2 ++ outbox.py | 2 ++ utils.py | 3 ++- webapp_media.py | 3 +++ webapp_podcast.py | 2 ++ webapp_utils.py | 2 ++ 11 files changed, 24 insertions(+), 5 deletions(-) diff --git a/content.py b/content.py index b7e386de9..45dd940a2 100644 --- a/content.py +++ b/content.py @@ -1442,6 +1442,7 @@ def save_media_in_form_post(media_bytes, debug: bool, 'mp3': 'audio/mpeg', 'ogg': 'audio/ogg', 'opus': 'audio/opus', + 'spx': 'audio/speex', 'flac': 'audio/flac', 'zip': 'application/zip', 'csv': 'text/csv', diff --git a/daemon.py b/daemon.py index e2a174464..5b8f1f2d7 100644 --- a/daemon.py +++ b/daemon.py @@ -21104,7 +21104,7 @@ def run_daemon(map_format: str, httpd.dogwhistles = load_dogwhistles(dogwhistles_filename) # list of preferred podcast formats - # eg ['audio/opus', 'audio/mp3'] + # eg ['audio/opus', 'audio/mp3', 'audio/speex'] httpd.preferred_podcast_formats = preferred_podcast_formats # for each account, whether bold reading is enabled diff --git a/epicyon.py b/epicyon.py index 2485dcfbb..811bae57b 100644 --- a/epicyon.py +++ b/epicyon.py @@ -297,7 +297,7 @@ def _command_options() -> None: parser.add_argument('--podcast-formats', dest='podcast_formats', type=str, default=None, help='Preferred podcast formats separated ' + - 'by commas. eg. "opus, mp3"') + 'by commas. eg. "opus, mp3, spx"') parser.add_argument('--ytdomain', dest='yt_replace_domain', type=str, default=None, help='Domain used to replace youtube.com') @@ -1220,9 +1220,9 @@ def _command_options() -> None: domain = argb.domain set_config_param(base_dir, 'domain', domain) - # comma separated list of preferred audio formats. eg. "opus", "mp3" + # comma separated list of preferred audio formats. eg. "opus", "mp3", "spx" # in order of preference - preferred_podcast_formats = ['ogg', 'mpeg', 'opus'] + preferred_podcast_formats = ['ogg', 'mpeg', 'opus', 'spx'] if argb.podcast_formats: podcast_formats_str = argb.podcast_formats else: diff --git a/manual/manual.md b/manual/manual.md index 5da2d1757..80103c9d0 100644 --- a/manual/manual.md +++ b/manual/manual.md @@ -535,6 +535,8 @@ If you have the *artist* role then from the top of the left column of the main t ## Federated shares # Search +To search, select the magnifying glass icon from the top right of the centre column of the main timeline. This will take you to a separate screen where you can enter your search query. + ## Searching your posts ## Searching hashtags diff --git a/media.py b/media.py index 97d9fa8b8..2a62d98f9 100644 --- a/media.py +++ b/media.py @@ -579,6 +579,9 @@ def attach_media(base_dir: str, http_prefix: str, file_extension = 'jpg' if media_type == 'audio/mpeg': file_extension = 'mp3' + if media_type == 'audio/speex' or \ + media_type == 'audio/x-speex': + file_extension = 'spx' domain = get_full_domain(domain, port) @@ -665,6 +668,7 @@ def path_is_audio(path: str) -> bool: """ if path.endswith('.ogg') or \ path.endswith('.opus') or \ + path.endswith('.spx') or \ path.endswith('.flac') or \ path.endswith('.mp3'): return True diff --git a/metadata.py b/metadata.py index 7352582f9..56f4d4bbe 100644 --- a/metadata.py +++ b/metadata.py @@ -194,6 +194,8 @@ def meta_data_instance(show_accounts: bool, 'video/ogv', 'audio/ogg', 'audio/opus', + 'audio/speex', + 'audio/x-speex', 'audio/flac', 'audio/mpeg' ], diff --git a/outbox.py b/outbox.py index 6e6011106..16d5befb5 100644 --- a/outbox.py +++ b/outbox.py @@ -355,6 +355,8 @@ def post_message_to_outbox(session, translate: {}, "ogg": "ogg", "flac": "flac", "opus": "opus", + "audio/speex": "spx", + "audio/x-speex": "spx", "mp4": "mp4", "webm": "webm", "ogv": "ogv" diff --git a/utils.py b/utils.py index 16cc94ad9..8920372d9 100644 --- a/utils.py +++ b/utils.py @@ -490,7 +490,7 @@ def get_video_extensions() -> []: def get_audio_extensions() -> []: """Returns a list of the possible audio file extensions """ - return ('mp3', 'ogg', 'flac', 'opus') + return ('mp3', 'ogg', 'flac', 'opus', 'spx') def get_image_extensions() -> []: @@ -2898,6 +2898,7 @@ def media_file_mime_type(filename: str) -> str: 'mp3': 'audio/mpeg', 'ogg': 'audio/ogg', 'opus': 'audio/opus', + 'spx': 'audio/speex', 'flac': 'audio/flac', 'mp4': 'video/mp4', 'ogv': 'video/ogv' diff --git a/webapp_media.py b/webapp_media.py index db1ba6250..46427ee3b 100644 --- a/webapp_media.py +++ b/webapp_media.py @@ -280,6 +280,7 @@ def _add_embedded_audio(translate: {}, content: str) -> str: if not ('.mp3' in content or '.ogg' in content or '.opus' in content or + '.spx' in content or '.flac' in content): return content @@ -291,6 +292,8 @@ def _add_embedded_audio(translate: {}, content: str) -> str: extension = '.ogg' elif '.opus' in content: extension = '.opus' + elif '.spx' in content: + extension = '.spx' elif '.flac' in content: extension = '.flac' diff --git a/webapp_podcast.py b/webapp_podcast.py index 94bfc0a43..25108df52 100644 --- a/webapp_podcast.py +++ b/webapp_podcast.py @@ -354,6 +354,8 @@ def html_podcast_episode(translate: {}, audio_extension = 'mpeg' elif '.opus' in link_url: audio_extension = 'opus' + elif '.spx' in link_url: + audio_extension = 'spx' elif '.flac' in link_url: audio_extension = 'flac' else: diff --git a/webapp_utils.py b/webapp_utils.py index 800fdc23c..c8deec424 100644 --- a/webapp_utils.py +++ b/webapp_utils.py @@ -1374,6 +1374,8 @@ def get_post_attachments_as_html(base_dir: str, extension = '.ogg' elif attach['url'].endswith('.opus'): extension = '.opus' + elif attach['url'].endswith('.spx'): + extension = '.spx' elif attach['url'].endswith('.flac'): extension = '.flac' if attach['url'].endswith(extension):