From 882725dcd878172b477335039a4bbb07ea424fe4 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Wed, 8 Nov 2023 22:10:46 +0100 Subject: update for anki 23.10 --- bulk-audio/bulk-audio.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'bulk-audio/bulk-audio.py') diff --git a/bulk-audio/bulk-audio.py b/bulk-audio/bulk-audio.py index 15ab33f..2ac307e 100755 --- a/bulk-audio/bulk-audio.py +++ b/bulk-audio/bulk-audio.py @@ -108,13 +108,10 @@ def main(): if options.clear_audio: if not options.dry_run: note[options.audio_field] = "" - note.flush() + col.update_note(note) print(f"cleared \"{options.audio_field}\" field!") continue - # autosave deck every 20 cards - if note_index % 20 == 0: col.save() - # skip any notes that already have audio if not options.force_override and len(note[options.audio_field]) > 0: print("skipped -> audio field not empty") @@ -132,7 +129,7 @@ def main(): if exit_code != 0: if not options.dry_run: note[options.audio_field] = "noaudio" - note.flush() + col.update_note(note) edited_notes += 1 print("skipped -> no recording available, marked as 'noaudio'") continue @@ -150,12 +147,10 @@ def main(): audio_str = f"[sound:{filename}]" if not options.dry_run: note[options.audio_field] = audio_str - note.flush() + col.update_note(note) print(f"written audio as {audio_str}") edited_notes += 1 - # save collection (and exit) - col.save() if edited_notes == 0: print("-- Done: no edits --") else: -- cgit v1.2.3