diff options
author | garret <garret@airmail.cc> | 2021-08-11 21:10:21 +0100 |
---|---|---|
committer | garret <garret@airmail.cc> | 2021-08-11 21:10:21 +0100 |
commit | 39249b596fd066326b945a599c36c70c2b6ea752 (patch) | |
tree | ac161d551ff41b4824112a08c8e8767ae040713f | |
parent | dd4adb78d8c8553ea99cf5ef4dcaf2e1a39d5552 (diff) | |
download | aegisub-scripts-39249b596fd066326b945a599c36c70c2b6ea752.tar.gz aegisub-scripts-39249b596fd066326b945a599c36c70c2b6ea752.tar.bz2 aegisub-scripts-39249b596fd066326b945a599c36c70c2b6ea752.zip |
get path with aegi save dialogue
-rw-r--r-- | chapters.lua | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/chapters.lua b/chapters.lua index fa81714..e9ade7d 100644 --- a/chapters.lua +++ b/chapters.lua @@ -1,7 +1,7 @@ script_name = "Chapter Generator" script_description = "makes chapters" script_author = "garret" -script_version = "2021-04-25" +script_version = "2.0.0-dev" language = "eng" language_ietf = "en" @@ -34,10 +34,15 @@ function get_sane_path() elseif audio_path ~= "?audio" then return audio_path else - return nil + return "" end end +function get_user_path(sane_path) + local path = aegisub.dialog.save("Save Chapter File", sane_path, "chapters.xml", "XML files (.xml)|.xml|All Files (.)|.", false) + return path +end + function main(sub) local times = {} local names = {} @@ -60,14 +65,15 @@ function main(sub) chapters = chapters.." <ChapterAtom>\n <ChapterTimeStart>"..humantime.."</ChapterTimeStart>\n <ChapterDisplay>\n <ChapterString>"..name.."</ChapterString>\n <ChapLanguageIETF>"..language_ietf.."</ChapLanguageIETF>\n <ChapterLanguage>"..language.."</ChapterLanguage>\n </ChapterDisplay>\n </ChapterAtom>\n" end chapters = chapters.." </EditionEntry>\n</Chapters>" - path = get_sane_path() + sane_path = get_sane_path() + path = get_user_path(sane_path) if path ~= nil then - local chapfile = io.open(path.."/chapters.xml", "w") + local chapfile = io.open(path, "w") chapfile:write(chapters) chapfile:close() - aegisub.log("saved to "..path.."/chapters.xml") + aegisub.log("saved to "..path) else - aegisub.log("<!-- couldn't find anywhere to save chapters, logging here - select everything below this message and copy+paste into a .xml file -->\n\n") + aegisub.log("<!-- Chapters not saved, logging here - select everything below this message and copy+paste into a .xml file -->\n\n") aegisub.log(chapters) end end |