aboutsummaryrefslogtreecommitdiffstats
path: root/macros/garret.chapters.lua
diff options
context:
space:
mode:
authorgarret <garret@airmail.cc>2024-02-25 23:01:13 +0000
committergarret <garret@airmail.cc>2024-02-25 23:08:47 +0000
commit67d261ab378fa9166ee6e0c31b7cb4e32a019925 (patch)
tree1fbd2153481e675f283f731c1da59d584513f2c9 /macros/garret.chapters.lua
parent5edf42a777b02ab939ab751a7d3e7eb0a7efde70 (diff)
downloadaegisub-scripts-67d261ab378fa9166ee6e0c31b7cb4e32a019925.tar.gz
aegisub-scripts-67d261ab378fa9166ee6e0c31b7cb4e32a019925.tar.bz2
aegisub-scripts-67d261ab378fa9166ee6e0c31b7cb4e32a019925.zip
get rid of dependencycontrol bullshit
there is no sense in me keeping it around when all it does is add faff to writing the script add useless noise to the filenames/paths and enforces its opinions upon me which i dont agree with and all for absolutely ZERO reason since i don't even have a feed in the first place if you want to take my scripts and package them into a dependencycontrol feed, you are more than welcome to do so, provided you comply with the terms of the licence. but your life is going to be a little bit harder i'm afraid, sorry about that. i will keep all the script_namespace, depctrl registration and such around for the time being (removing it is >effort)
Diffstat (limited to 'macros/garret.chapters.lua')
-rw-r--r--macros/garret.chapters.lua94
1 files changed, 0 insertions, 94 deletions
diff --git a/macros/garret.chapters.lua b/macros/garret.chapters.lua
deleted file mode 100644
index bcb78b9..0000000
--- a/macros/garret.chapters.lua
+++ /dev/null
@@ -1,94 +0,0 @@
-script_name = "Chapter Generator"
-script_description = "Makes XML chapters for matroska."
-script_author = "garret"
-script_version = "2.1.0"
-script_namespace = "garret.chapters"
-
-local haveDepCtrl, DependencyControl, depctrl = pcall(require, "l0.DependencyControl")
-
-if haveDepCtrl then
- depctrl = DependencyControl {
- --feed="TODO",
- }
-end
-
---local config = simpleconf.get_config(aegisub.decode_path(config_dir.."/"..script_namespace..".conf"), {language = "eng", language_ietf = "en"})
-local config = {language = "eng", language_ietf = "en"}
-
-
-function ms_to_human(start) -- From Significance
- local timecode=math.floor(start/1000)
- local tc1=math.floor(timecode/60)
- local tc2=timecode%60
- local tc3=start%1000
- local tc4="00"
- if tc2==60 then tc2=0 tc1=tc1+1 end
- if tc1>119 then tc1=tc1-120 tc4="02" end
- if tc1>59 then tc1=tc1-60 tc4="01" end
- if tc1<10 then tc1="0"..tc1 end
- if tc2<10 then tc2="0"..tc2 end
- if tc3<100 then tc3="0"..tc3 end
- linetime=tc4..":"..tc1..":"..tc2.."."..tc3
- if linetime=="00:00:00.00" then linetime="00:00:00.033" end
- return linetime
-end
-
-function get_sane_path()
- script_path = aegisub.decode_path("?script")
- audio_path = aegisub.decode_path("?audio")
- video_path = aegisub.decode_path("?video")
- if script_path ~= "?script" then
- return script_path
- elseif video_path ~= "?video" then
- return video_path
- elseif audio_path ~= "?audio" then
- return audio_path
- else
- return ""
- end
-end
-
-function get_user_path(default_dir)
- local path = aegisub.dialog.save("Save Chapter File", default_dir, "chapters.xml", "XML files|*.xml|All Files|*", false)
- return path
-end
-
-function main(sub)
- local times = {}
- local names = {}
- for i=1,#sub do
- local line = sub[i]
- if line.class == "dialogue" then
- local fx = line.effect
- if fx:match("[Cc]hapter") or fx:match("[Cc]hptr") or fx:match("[Cc]hap") then
- line.comment = true
- table.insert(times, line.start_time)
- table.insert(names, line.text)
- sub[i] = line
- end
- end
- end
- aegisub.set_undo_point(script_name)
- local chapters = "<?xml version=\"1.0\"?>\n<!-- <!DOCTYPE Chapters SYSTEM \"matroskachapters.dtd\"> -->\n<Chapters>\n <EditionEntry>\n"
- for j, k in ipairs(times) do
- local humantime = ms_to_human(k)
- local name = names[j]
- chapters = chapters.." <ChapterAtom>\n <ChapterTimeStart>"..humantime.."</ChapterTimeStart>\n <ChapterDisplay>\n <ChapterString>"..name.."</ChapterString>\n <ChapLanguageIETF>"..config.language_ietf.."</ChapLanguageIETF>\n <ChapterLanguage>"..config.language.."</ChapterLanguage>\n </ChapterDisplay>\n </ChapterAtom>\n"
- end
- chapters = chapters.." </EditionEntry>\n</Chapters>"
- sane_path = get_sane_path()
- path = get_user_path(sane_path)
- if path ~= nil then
- local chapfile = io.open(path, "w")
- chapfile:write(chapters)
- chapfile:close()
- else
- aegisub.cancel()
- end
-end
-
-if haveDepCtrl then
- depctrl:registerMacro(main)
-else
- aegisub.register_macro(script_name, script_description, main)
-end