Support for flac audio format

main
Bob Mottram 2022-04-18 14:44:08 +01:00
parent 8094ca0849
commit 4b9fd94498
5 changed files with 12 additions and 1 deletions

View File

@ -416,6 +416,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('.flac') or \
path.endswith('.mp3'): path.endswith('.mp3'):
return True return True
return False return False

View File

@ -313,6 +313,7 @@ def post_message_to_outbox(session, translate: {},
"avif": "avif", "avif": "avif",
"audio/mpeg": "mp3", "audio/mpeg": "mp3",
"ogg": "ogg", "ogg": "ogg",
"flac": "flac",
"opus": "opus", "opus": "opus",
"mp4": "mp4", "mp4": "mp4",
"webm": "webm", "webm": "webm",

View File

@ -227,7 +227,10 @@ def _add_embedded_video_from_sites(translate: {}, content: str,
def _add_embedded_audio(translate: {}, content: str) -> str: def _add_embedded_audio(translate: {}, content: str) -> str:
"""Adds embedded audio for mp3/ogg/opus """Adds embedded audio for mp3/ogg/opus
""" """
if not ('.mp3' in content or '.ogg' in content or '.opus' in content): if not ('.mp3' in content or
'.ogg' in content or
'.opus' in content or
'.flac' in content):
return content return content
if '<audio ' in content: if '<audio ' in content:
@ -238,6 +241,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 '.flac' in content:
extension = '.flac'
words = content.strip('\n').split(' ') words = content.strip('\n').split(' ')
for wrd in words: for wrd in words:

View File

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

View File

@ -1219,6 +1219,8 @@ def get_post_attachments_as_html(post_json_object: {}, box_name: str,
extension = '.ogg' extension = '.ogg'
elif attach['url'].endswith('.opus'): elif attach['url'].endswith('.opus'):
extension = '.opus' extension = '.opus'
elif attach['url'].endswith('.flac'):
extension = '.flac'
if attach['url'].endswith(extension): if attach['url'].endswith(extension):
if attachment_ctr > 0: if attachment_ctr > 0:
attachment_str += '<br>' attachment_str += '<br>'