Support speex audio format

main
Bob Mottram 2022-10-20 20:37:59 +01:00
parent 9ce0664c65
commit 08df47318f
11 changed files with 24 additions and 5 deletions

View File

@ -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',

View File

@ -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

View File

@ -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:

View File

@ -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

View File

@ -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

View File

@ -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'
],

View File

@ -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"

View File

@ -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'

View File

@ -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'

View File

@ -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:

View File

@ -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):