activer replace_emojis

This commit is contained in:
Francois Pelletier 2023-05-17 20:30:03 -04:00
parent 7b16b3a180
commit 1851e0a029

22
main.py
View file

@ -17,6 +17,7 @@ from extract_emojis import replace_emojis
from list_dir import list_dir
from responses import Styles, Formats, App
def convert_video(images_path, output_path, width, height, fps, stilltime):
"""
Convert images in output_path into a mp4 file usine OpenCV.
@ -42,7 +43,7 @@ def convert_video(images_path, output_path, width, height, fps, stilltime):
file = os.path.join(images_path, files[i])
logging.log(logging.INFO, f'Converting {file} to mp4')
img = cv2.imread(file)
for j in range(fps*stilltime):
for j in range(fps * stilltime):
frame_array.append(img)
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
@ -79,6 +80,7 @@ async def get_formats(style: str):
formats = Formats(formats=list_dir(f"./styles/{style}/"))
return formats
@app.get("/format_parameters/{style}/{format}/")
async def get_format_parameters(style: str, format: str):
# open styles/format_parameters.json as a dictionary
@ -120,15 +122,15 @@ async def generer(specs: DocumentSpecs):
text_to_convert = replace_emojis(specs.content)
result = pypandoc.convert_text(source=specs.content,
to='pdf',
format='markdown+implicit_figures+smart+emoji',
encoding='utf-8',
extra_args=pdoc_args,
filters=filters,
cworkdir=os.getcwd(),
outputfile=pdf_file_path
)
pypandoc.convert_text(source=text_to_convert,
to='pdf',
format='markdown+implicit_figures+smart+emoji',
encoding='utf-8',
extra_args=pdoc_args,
filters=filters,
cworkdir=os.getcwd(),
outputfile=pdf_file_path
)
except RuntimeError as rerr:
logging.exception(rerr)