Skip to content

Instantly share code, notes, and snippets.

@karasugawasu
Created May 2, 2018 17:42
Show Gist options
  • Save karasugawasu/99febda650d0fd6a749afdbf28888dd4 to your computer and use it in GitHub Desktop.
Save karasugawasu/99febda650d0fd6a749afdbf28888dd4 to your computer and use it in GitHub Desktop.
例の奴のTrim情報から適当にチャプター情報を取得
Dim logfiles
Dim ChapterText
Dim ChapCnt
Dim logTrim
Dim ChapBuf
Dim ChapBufAf
Dim ChapSa
Dim ChapTime
Dim FiletmpName
FiletmpName = WScript.Arguments(0)
Set objFso = CreateObject("Scripting.FileSystemObject")
Set objFile = objFso.OpenTextFile(FiletmpName & ".mp4chapter.txt", 2, True)
ChapterText = "#Chapter 1:" & vbCrLf & "AddChapter(0,Chapter 1)" & vbCrLf
On Error Resume Next
If objFso.FileExists(FiletmpName & ".avspmod.avs") = True Then
tmp = CreateObject("Scripting.FileSystemObject").OpenTextFile(FiletmpName & ".avspmod.avs").ReadAll
Else
tmp = CreateObject("Scripting.FileSystemObject").OpenTextFile(FiletmpName & ".avs").ReadAll
End If
If Err.Number = 0 Or tmp <> "" Then
logfiles = Split(tmp,vbCrLf)
logfiles = Filter(logfiles, "Trim(")
logTrim = Replace(logfiles(0), " " , "")
logTrim = Replace(logTrim,"++" ,"")
logTrim = Replace(logTrim,"(" ,"")
logTrim = Replace(logTrim,")" ,"")
logTrim = Split(logTrim, "Trim")
ChapCnt = 1
ChapBuf = Split(logTrim(ChapCnt), ",")
ChapBufAf = Split(logTrim(ChapCnt + 1 ),",")
ChapSa = ((ChapBufAf(0) - ChapBuf(1)) + ChapBuf(0)) - 1
ChapTime = ChapBufAf(0) - ChapSa
ChapterText = ChapterText & "#Chapter " & ChapCnt + 1 & ":" & vbCrLf & "AddChapter(" & ChapTime & ",Chapter " & ChapCnt + 1 &")" & vbCrLf
ChapCnt = ChapCnt + 1
Do While Ubound(logTrim) > ChapCnt
ChapBuf = Split(logTrim(ChapCnt), ",")
ChapBufAf = Split(logTrim(ChapCnt + 1 ),",")
ChapSa = (ChapBufAf(0) - ChapBuf(1)) + ChapSa
ChapTime = ChapBufAf(0) - ChapSa
ChapterText = ChapterText & "#Chapter " & ChapCnt + 1 & ":" & vbCrLf & "AddChapter(" & ChapTime & ",Chapter " & ChapCnt + 1 &")" & vbCrLf
ChapCnt = ChapCnt + 1
Loop
End If
objFile.WriteLine ChapterText
objFile.Close
set objFso = Nothing
Set objFile = Nothing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment