Support speex audio format

merge-requests/30/head
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', 'mp3': 'audio/mpeg',
'ogg': 'audio/ogg', 'ogg': 'audio/ogg',
'opus': 'audio/opus', 'opus': 'audio/opus',
'spx': 'audio/speex',
'flac': 'audio/flac', 'flac': 'audio/flac',
'zip': 'application/zip', 'zip': 'application/zip',
'csv': 'text/csv', 'csv': 'text/csv',

View File

@ -21104,7 +21104,7 @@ def run_daemon(map_format: str,
httpd.dogwhistles = load_dogwhistles(dogwhistles_filename) httpd.dogwhistles = load_dogwhistles(dogwhistles_filename)
# list of preferred podcast formats # list of preferred podcast formats
# eg ['audio/opus', 'audio/mp3'] # eg ['audio/opus', 'audio/mp3', 'audio/speex']
httpd.preferred_podcast_formats = preferred_podcast_formats httpd.preferred_podcast_formats = preferred_podcast_formats
# for each account, whether bold reading is enabled # 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', parser.add_argument('--podcast-formats', dest='podcast_formats',
type=str, default=None, type=str, default=None,
help='Preferred podcast formats separated ' + help='Preferred podcast formats separated ' +
'by commas. eg. "opus, mp3"') 'by commas. eg. "opus, mp3, spx"')
parser.add_argument('--ytdomain', dest='yt_replace_domain', parser.add_argument('--ytdomain', dest='yt_replace_domain',
type=str, default=None, type=str, default=None,
help='Domain used to replace youtube.com') help='Domain used to replace youtube.com')
@ -1220,9 +1220,9 @@ def _command_options() -> None:
domain = argb.domain domain = argb.domain
set_config_param(base_dir, 'domain', 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 # in order of preference
preferred_podcast_formats = ['ogg', 'mpeg', 'opus'] preferred_podcast_formats = ['ogg', 'mpeg', 'opus', 'spx']
if argb.podcast_formats: if argb.podcast_formats:
podcast_formats_str = argb.podcast_formats podcast_formats_str = argb.podcast_formats
else: 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 ## Federated shares
# Search # 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 your posts
## Searching hashtags ## Searching hashtags

View File

@ -579,6 +579,9 @@ def attach_media(base_dir: str, http_prefix: str,
file_extension = 'jpg' file_extension = 'jpg'
if media_type == 'audio/mpeg': if media_type == 'audio/mpeg':
file_extension = 'mp3' file_extension = 'mp3'
if media_type == 'audio/speex' or \
media_type == 'audio/x-speex':
file_extension = 'spx'
domain = get_full_domain(domain, port) domain = get_full_domain(domain, port)
@ -665,6 +668,7 @@ def path_is_audio(path: str) -> bool:
""" """
if path.endswith('.ogg') or \ if path.endswith('.ogg') or \
path.endswith('.opus') or \ path.endswith('.opus') or \
path.endswith('.spx') or \
path.endswith('.flac') or \ path.endswith('.flac') or \
path.endswith('.mp3'): path.endswith('.mp3'):
return True return True

View File

@ -194,6 +194,8 @@ def meta_data_instance(show_accounts: bool,
'video/ogv', 'video/ogv',
'audio/ogg', 'audio/ogg',
'audio/opus', 'audio/opus',
'audio/speex',
'audio/x-speex',
'audio/flac', 'audio/flac',
'audio/mpeg' 'audio/mpeg'
], ],

View File

@ -355,6 +355,8 @@ def post_message_to_outbox(session, translate: {},
"ogg": "ogg", "ogg": "ogg",
"flac": "flac", "flac": "flac",
"opus": "opus", "opus": "opus",
"audio/speex": "spx",
"audio/x-speex": "spx",
"mp4": "mp4", "mp4": "mp4",
"webm": "webm", "webm": "webm",
"ogv": "ogv" "ogv": "ogv"

View File

@ -490,7 +490,7 @@ def get_video_extensions() -> []:
def get_audio_extensions() -> []: def get_audio_extensions() -> []:
"""Returns a list of the possible audio file 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() -> []: def get_image_extensions() -> []:
@ -2898,6 +2898,7 @@ def media_file_mime_type(filename: str) -> str:
'mp3': 'audio/mpeg', 'mp3': 'audio/mpeg',
'ogg': 'audio/ogg', 'ogg': 'audio/ogg',
'opus': 'audio/opus', 'opus': 'audio/opus',
'spx': 'audio/speex',
'flac': 'audio/flac', 'flac': 'audio/flac',
'mp4': 'video/mp4', 'mp4': 'video/mp4',
'ogv': 'video/ogv' 'ogv': 'video/ogv'

View File

@ -280,6 +280,7 @@ def _add_embedded_audio(translate: {}, content: str) -> str:
if not ('.mp3' in content or if not ('.mp3' in content or
'.ogg' in content or '.ogg' in content or
'.opus' in content or '.opus' in content or
'.spx' in content or
'.flac' in content): '.flac' in content):
return content return content
@ -291,6 +292,8 @@ def _add_embedded_audio(translate: {}, content: str) -> str:
extension = '.ogg' extension = '.ogg'
elif '.opus' in content: elif '.opus' in content:
extension = '.opus' extension = '.opus'
elif '.spx' in content:
extension = '.spx'
elif '.flac' in content: elif '.flac' in content:
extension = '.flac' extension = '.flac'

View File

@ -354,6 +354,8 @@ def html_podcast_episode(translate: {},
audio_extension = 'mpeg' audio_extension = 'mpeg'
elif '.opus' in link_url: elif '.opus' in link_url:
audio_extension = 'opus' audio_extension = 'opus'
elif '.spx' in link_url:
audio_extension = 'spx'
elif '.flac' in link_url: elif '.flac' in link_url:
audio_extension = 'flac' audio_extension = 'flac'
else: else:

View File

@ -1374,6 +1374,8 @@ def get_post_attachments_as_html(base_dir: str,
extension = '.ogg' extension = '.ogg'
elif attach['url'].endswith('.opus'): elif attach['url'].endswith('.opus'):
extension = '.opus' extension = '.opus'
elif attach['url'].endswith('.spx'):
extension = '.spx'
elif attach['url'].endswith('.flac'): elif attach['url'].endswith('.flac'):
extension = '.flac' extension = '.flac'
if attach['url'].endswith(extension): if attach['url'].endswith(extension):