Aegisub/aegisub/automation/tests/karaoke-parse-test.lua
Amar Takhar 91d73ec8ea SVN Transition Step 3/7
1. cd aegisub/
  2. svn mv *cpp *h src/
  3. svn mv Makefile.am MatroskaParser.c auto4_perldata.inc bitmaps boost \
     changelog.txt config gl include libosxutil libresrc md5.c msvc mythes.cxx \
     mythes.hxx res.rc src/
  4. cd ..
  5. svn mv FFmpegSource2/ INSTALL Makefile.am README  acinclude.m4 \
     autogen.sh automation/ bin build configure.in desktop dummy.txt lib \
     libass/ m4macros/ packages/ po/ scripts/ universalchardet/ aegisub/
  6. mkdir -p docs/wiki_convert
  7. svn add docs/wiki_convert
  8. cd docs
  9. svn mv aegisub_convert_docs.pl convert.bat output wiki_convert/

* See r2749 for full description.

Originally committed to SVN as r2752.
2009-03-08 08:30:39 +00:00

33 lines
850 B
Lua

-- Automation 4 test file
-- Create a Macro feature, that displays some text
script_name = "Automation 4 test 3"
script_description = "Test parse_karaoke_data"
script_author = "Niels Martin Hansen"
script_version = "1"
function copy_table(tab)
local res = {}
for key, val in pairs(tab) do
res[key] = val
end
return res
end
function karatest(subtitles, selected_lines, active_line)
for i = #selected_lines, 1, -1 do
local ri = selected_lines[i]
local l = subtitles[ri]
local k = aegisub.parse_karaoke_data(l)
for j = 1, #k do
local nl = copy_table(l)
l.text = string.format("{\\t(%d,%d,\\fscx50)}%s", k[j].start_time, k[j].end_time, k[j].text_stripped)
subtitles.insert(ri+j, l)
end
end
aegisub.set_undo_point("karaoke-like stuff")
end
aegisub.register_macro("Karaoke fun", "Makes karaoke-like stuff", karatest, nil)