convert audio files (need ffmpeg)

This commit is contained in:
quenousimporte 2025-02-19 17:48:54 +01:00
parent acae10d185
commit cdc6923a25
1 changed files with 12 additions and 1 deletions

View File

@ -3,6 +3,7 @@ import re
import markdown import markdown
import yaml import yaml
import shutil import shutil
import subprocess
htmltemplate = """<!DOCTYPE html> htmltemplate = """<!DOCTYPE html>
<html> <html>
@ -76,9 +77,19 @@ for folderinfo in index['folders']:
htmlhome += "<li><a href=\"{}\">{}</a></li>".format(filename.replace('.md', '.html'), filetitle) htmlhome += "<li><a href=\"{}\">{}</a></li>".format(filename.replace('.md', '.html'), filetitle)
gmihome += "\n=> {} {}".format(filename.replace('.md', '.gmi').replace(' ', '%20'), filetitle) gmihome += "\n=> {} {}".format(filename.replace('.md', '.gmi').replace(' ', '%20'), filetitle)
else: elif fileextension == ".wav" or fileextension == ".3gp":
# sounds # sounds
# todo: add a property for dest file (to remove accents)
# todo use builtin library
subprocess.run(["ffmpeg",
"-i",
os.path.join(folderinfo['folder'], filename),
os.path.join('out/html', fileroot + ".mp3")])
htmlhome += "<li>{}</li><audio controls><source src=\"{}\"></audio>".format(filetitle, filename)
elif fileextension == ".mp3":
shutil.copy(os.path.join(folderinfo['folder'], filename), 'out/html') shutil.copy(os.path.join(folderinfo['folder'], filename), 'out/html')
htmlhome += "<li>{}</li><audio controls><source src=\"{}\"></audio>".format(filetitle, filename) htmlhome += "<li>{}</li><audio controls><source src=\"{}\"></audio>".format(filetitle, filename)