Commit: 3b80a2014acc0ec52d37f9dffbdd3137fa683202
Parent: 9b11b92869f18f238a0c068675da24e0d1987224
Author: Ren Tatsumoto
Date: Thu, 27 Aug 2020 16:52:01 +0300
move export function up
Diffstat:
1 file changed, 19 insertions(+), 19 deletions(-)
diff --git a/subs2srs.lua b/subs2srs.lua
@@ -258,6 +258,25 @@ local function sub_rewind()
)
end
+local function export_to_anki()
+ local sub = subs.get()
+
+ if sub ~= nil then
+ local filename = construct_filename(sub)
+ local snapshot_filename = add_extension(filename, '.webp')
+ local audio_filename = add_extension(filename, '.ogg')
+ local snapshot_timestamp = (sub['start'] + sub['end']) / 2
+
+ ffmpeg.create_snapshot(snapshot_timestamp, snapshot_filename)
+ ffmpeg.create_audio(sub['start'], sub['end'], audio_filename)
+
+ ankiconnect.add_note(sub['text'], audio_filename, snapshot_filename)
+ else
+ msg.warn("Nothing to export.")
+ mp.osd_message("Nothing to export.", 1)
+ end
+end
+
------------------------------------------------------------
-- ffmpeg helper
@@ -532,25 +551,6 @@ end
------------------------------------------------------------
-- main
-local function export_to_anki()
- local sub = subs.get()
-
- if sub ~= nil then
- local filename = construct_filename(sub)
- local snapshot_filename = add_extension(filename, '.webp')
- local audio_filename = add_extension(filename, '.ogg')
- local snapshot_timestamp = (sub['start'] + sub['end']) / 2
-
- ffmpeg.create_snapshot(snapshot_timestamp, snapshot_filename)
- ffmpeg.create_audio(sub['start'], sub['end'], audio_filename)
-
- ankiconnect.add_note(sub['text'], audio_filename, snapshot_filename)
- else
- msg.warn("Nothing to export.")
- mp.osd_message("Nothing to export.", 1)
- end
-end
-
if config.autoclip == true then clip_autocopy.enable() end
check_config_sanity()