Skip to content

Commit

Permalink
v1.0.2 add .wav format
Browse files Browse the repository at this point in the history
  • Loading branch information
emisjerry committed May 16, 2020
1 parent de47530 commit bacffb6
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions autosub-ahk.ahk
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
; Generated by AutoGUI 2.6.2
; Generated by AutoGUI 2.6.2
; ===========================
; Author: Jerry Jian
; YouTube: https://www.youtube.com/channel/UC2xBvmv-lhsY4suxv46lplg?view_as=subscriber
; Blog: http://jdev.tw/blog
; v1.0 2020/05/13
; Call gen.bat to generate subtitle. You can change the autosub parameters in gen.bat.
; v1.0.1 2020/05/14 minor changes
; v1.0.2 2020/05/16 Add .wav to allowed video format
; ===========================
#SingleInstance Force
#NoEnv
Expand All @@ -19,7 +20,7 @@ global videoFiles
global VIDEO_FORMAT_FAILED
videoFiles := []

version := "v1.0.1"
version := "v1.0.2"
; 多語系設定
if (A_Language in 0404, 0c04, 1404) { ; Chinese_Taiwan, Hong Kong, Macau
TITLE := "AutoSub-AHK 字幕產生器"
Expand All @@ -28,35 +29,35 @@ if (A_Language in 0404, 0c04, 1404) { ; Chinese_Taiwan, Hong Kong, Macau
VIDEO_FILES := "選擇影片檔案(&S)"
OUTPUT_FILENAME := "輸出檔名(&O)"
OUTPUT_MSG := "(副檔名必須為.txt或.srt)"
DRAG_MSG := "拖曳功能已啟用"
DRAG_MSG := "(.mp4或.wav) 拖曳功能已啟用"
BTN_OK := "確定執行(&E)"
BTN_CLOSE := "關閉(&C)"
VIDEO_SELECT_TITLE := "選擇影片檔案(可複選)"
VIDEO_FORMAT_FAILED := "影片副檔名必須是 .mp4"
VIDEO_FORMAT_FAILED := "影片副檔名必須是 .mp4或.wav"
} else if (A_Language in 0804,1004) { ; Chinese_PRC, singapore
TITLE := "AutoSub-AHK 字幕产生器"
LANGUAGES := "zh-TW 中文(繁体)|zh-CN 中文(简体)||en-US English|ja-JP 日本语|ko-KR 한국어|yue-hant-hk 粤语"
VIDEO_LANGUAGE := "视频语言(&L)"
VIDEO_FILES := "选择视频文件(&S)"
OUTPUT_FILENAME := "输出档名(&O)"
OUTPUT_MSG := "(副档名必须为.txt或.srt)"
DRAG_MSG := "拖拽功能已启用"
DRAG_MSG := "(.mp4或.wav) 拖拽功能已启用"
BTN_OK := "确定执行(&E)"
BTN_CLOSE := "关闭(&C)"
VIDEO_SELECT_TITLE := "选择影片文件(可复选)"
VIDEO_FORMAT_FAILED := "影片副档名必须为 .mp4"
VIDEO_FORMAT_FAILED := "影片副档名必须为 .mp4或.wav"
} else {
TITLE := "AutoSub-AHK SubTITLEs Generator"
LANGUAGES := "zh-TW Chinese(Traditional)|zh-CN Chinese(Simplified)|en-US English||ja-JP Japanese|ko-KR Korean|yue-hant-hk Hong Konf"
VIDEO_LANGUAGE := "Video &Language"
VIDEO_FILES := "&Select Video File(s)"
OUTPUT_FILENAME := "&Output file name"
OUTPUT_MSG := "(File extension must ends with .txt or .srt)"
DRAG_MSG := "Drag and Drop Enabled"
DRAG_MSG := "(.mp4 or .wav) Drag and Drop Enabled"
BTN_OK := "&Execute"
BTN_CLOSE := "&Close"
VIDEO_SELECT_TITLE := "Select video file(s)"
VIDEO_FORMAT_FAILED := "Video's extension must be .mp4"
VIDEO_FORMAT_FAILED := "Video's extension must be .mp4 or .wav"
}

Menu Tray, Icon, %I_ICON%
Expand Down Expand Up @@ -108,7 +109,7 @@ Return

btnSelectFiles:
;FileSelectFile, OutputVar , Options, RootDir\Filename, Title, Filter
FileSelectFile, files, M3, , %VIDEO_SELECT_TITLE%, *.mp4 ; M3 = Multiselect existing files.
FileSelectFile, files, M3, , %VIDEO_SELECT_TITLE%, *.mp4;*.wav ; M3 = Multiselect existing files.
if (files = "") {
return
}
Expand All @@ -132,6 +133,7 @@ btnSelectFiles:
if (index = 1) {
name := element
StringReplace name, name, .mp4, .srt
StringReplace name, name, .wav, .srt
GuiControl, , edtOutputFilename, %name%
}
files := files . element . "|"
Expand Down Expand Up @@ -169,6 +171,7 @@ btnOK(CtrlHwnd, GuiEvent, EventInfo, ErrLevel := "") {
} else {
edtOutputFilename := videoFilename
StringReplace edtOutputFilename, edtOutputFilename, .mp4, .srt
StringReplace edtOutputFilename, edtOutputFilename, .wav, .srt
newFilename := deleteOldFile(edtOutputFilename, Language)
if (InStr(edtOutputFilename, ".txt") > 0) {
batFilename := "gen-txt.bat"
Expand Down Expand Up @@ -209,6 +212,7 @@ GuiDropFiles(GuiHwnd, FileArray, CtrlHwnd, X, Y) {
if (index = 1) {
name := element
StringReplace name, name, .mp4, .srt
StringReplace name, name, .wav, .srt
GuiControl, , edtOutputFilename, %name%
}
files := files . element . "|"
Expand All @@ -226,12 +230,14 @@ ListBox1:
Return

/*
* 檢查輸入的影片副檔名是否為.mp4
* 檢查輸入的影片副檔名是否為.mp4或.wav
*/
chkVideoFile(file) {
;MsgBox file=%file%
iPos := InStr(file, ".mp4")
if (iPos <= 0) {
StringUpper, file, file
iPos1 := InStr(file, ".MP4")
iPos2 := InStr(file, ".WAV")
if (iPos1 <= 0 && iPos2 <= 0) {
MsgBox %VIDEO_FORMAT_FAILED% (%file%)
Return false
}
Expand All @@ -248,4 +254,4 @@ deleteOldFile(file, language) {
FileDelete, %newFilename%
}
return newFilename
}
}

0 comments on commit bacffb6

Please sign in to comment.