update api endpoints

This commit is contained in:
Wolfang Torres
2026-06-19 20:17:37 +08:00
parent dde819f1e6
commit 30dd8c8671
3 changed files with 120 additions and 23 deletions

View File

@@ -5,6 +5,7 @@ Produces anki output
# Standard Library
import random
from pathlib import Path
# Pip
from genanki import Deck, Model, Note, Package
@@ -121,7 +122,9 @@ HSK_MODEL = Model(
# Proccess
def output_anki_dictionary(process_file: ProcessFile, results: list[DictionaryResult]):
def output_anki_dictionary(
process_file: ProcessFile, results: list[DictionaryResult]
) -> Path:
"""Creates an anki file from a dictionary results"""
final_file = process_file.output_name.with_suffix(".apkg")
deck_name = "::".join(
@@ -146,9 +149,12 @@ def output_anki_dictionary(process_file: ProcessFile, results: list[DictionaryRe
deck.add_note(note)
package.media_files = audios
package.write_to_file(final_file)
return final_file
def output_anki_phrase(process_file: ProcessFile, results: list[TranslationResult]):
def output_anki_phrase(
process_file: ProcessFile, results: list[TranslationResult]
) -> Path:
"""Creates an anki file from a phrases results"""
final_file = process_file.output_name.with_suffix(".apkg")
deck_name = "::".join(
@@ -170,3 +176,4 @@ def output_anki_phrase(process_file: ProcessFile, results: list[TranslationResul
audios.append(result.audio_path)
package.media_files = audios
package.write_to_file(final_file)
return final_file