Skip to content

Commit 1723558

Browse files
committed
Introduce "chapters" subcommand
1 parent 9c4388f commit 1723558

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

markut.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,6 +1334,37 @@ var Subcommands = map[string]Subcommand{
13341334
return true
13351335
},
13361336
},
1337+
"chapters": {
1338+
Description: "Generate YouTube chapters list that is easily copy-pastable to the Video Description",
1339+
Run: func(commandName string, args []string) bool {
1340+
subFlag := flag.NewFlagSet(commandName, flag.ContinueOnError)
1341+
markutPtr := subFlag.String("markut", "MARKUT", "Path to the MARKUT file")
1342+
1343+
err := subFlag.Parse(args)
1344+
1345+
if err == flag.ErrHelp {
1346+
return true
1347+
}
1348+
1349+
if err != nil {
1350+
fmt.Printf("ERROR: Could not parse command line arguments: %s\n", err)
1351+
return false
1352+
}
1353+
1354+
context, ok := defaultContext()
1355+
ok = ok && context.evalMarkutFile(nil, *markutPtr, false) && context.finishEval()
1356+
if !ok {
1357+
return false
1358+
}
1359+
1360+
fmt.Printf("Chapters:\n");
1361+
for _, chapter := range context.chapters {
1362+
fmt.Printf("- %s - %s\n", millisToYouTubeTs(chapter.Timestamp), chapter.Label)
1363+
}
1364+
1365+
return true
1366+
},
1367+
},
13371368
}
13381369

13391370
func usage() {

0 commit comments

Comments
 (0)