mpv2oboeru

mpv helpers to create flashcards from movies and TV shows
git clone anongit@rnpnr.xyz:mpv2oboeru.git
Log | Files | Refs | Feed | README | LICENSE

Commit: ac8cdea4a6e3ef943774a1dbd0ad77920662b5b7
Parent: 531fa2f1a8a45aeb1cd1e5de9c419be2bf4a27b1
Author: Ren Tatsumoto
Date:   Mon,  9 Nov 2020 13:48:34 +0300

add a function to export media without the sentence

Diffstat:
Msubs2srs.lua | 21+++++++++++++++++++++
1 file changed, 21 insertions(+), 0 deletions(-)

diff --git a/subs2srs.lua b/subs2srs.lua @@ -345,6 +345,27 @@ local function minutes_ago(m) return (os.time() - 60 * m) * 1000 end +local function export_media() + local timings = { + ['start'] = subs.get_timing('start'), + ['end'] = subs.get_timing('end'), + } + if not timings['start'] or not timings['end'] then + notify("Timings are not set. Aborting.", "warn", 2) + return + end + + local snapshot_filename, audio_filename = construct_media_filenames(timings) + local snapshot_time = (timings['start'] + timings['end']) / 2 + + encoder.create_snapshot(snapshot_time, snapshot_filename) + encoder.create_audio(timings['start'], timings['end'], audio_filename) + + local note_fields = construct_note_fields(nil, snapshot_filename, audio_filename) + ankiconnect.add_note(note_fields, true) + subs.clear() +end + local function export_to_anki(gui) local sub = subs.get() subs.clear()