check if fullvod exists; store config in UserConfigDir
All checks were successful
/ build-linux-amd64 (push) Successful in 1m10s
All checks were successful
/ build-linux-amd64 (push) Successful in 1m10s
This commit is contained in:
parent
c3dc6f095e
commit
e8a6f4208c
4 changed files with 60 additions and 13 deletions
47
main.go
47
main.go
|
|
@ -28,19 +28,29 @@ var helpText string
|
|||
const segmentExtension = "mkv"
|
||||
|
||||
func showHelp() {
|
||||
execSplits := strings.Split(os.Args[0], "/")
|
||||
execName := execSplits[len(execSplits) - 1]
|
||||
fmt.Printf(helpText, execName)
|
||||
fmt.Println(helpText)
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
func main() {
|
||||
// config
|
||||
userConfigDir, err := os.UserConfigDir()
|
||||
if err != nil {
|
||||
log.Fatalf("Could not determine user configuration directory: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
config.CONFIG_FILENAME = path.Join(userConfigDir, "vodular", "config.toml")
|
||||
cfg, err := config.ReadConfig(config.CONFIG_FILENAME)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to read config: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
if cfg == nil {
|
||||
err = os.MkdirAll(path.Dir(config.CONFIG_FILENAME), 0750)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to create config directory: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
err = config.GenerateConfig(config.CONFIG_FILENAME)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to generate config: %v", err)
|
||||
|
|
@ -57,7 +67,6 @@ func main() {
|
|||
// arguments
|
||||
if len(os.Args) < 2 || os.Args[1] == "--help" || os.Args[1] == "-h" {
|
||||
showHelp()
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
var verbose bool = false
|
||||
|
|
@ -76,7 +85,6 @@ func main() {
|
|||
fallthrough
|
||||
case "--help":
|
||||
showHelp()
|
||||
os.Exit(0)
|
||||
|
||||
case "-v":
|
||||
fallthrough
|
||||
|
|
@ -228,19 +236,34 @@ func main() {
|
|||
os.Exit(1)
|
||||
}
|
||||
fmt.Printf(
|
||||
"\n================================\n" +
|
||||
"TITLE:\n%s\n\n" +
|
||||
"DESCRIPTION:\n%s\n" +
|
||||
"\n================================\n\n" +
|
||||
"< TITLE >\n%s\n\n" +
|
||||
"< DESCRIPTION >\n%s\n" +
|
||||
"\n================================\n",
|
||||
title, description,
|
||||
)
|
||||
}
|
||||
|
||||
// concatenate VOD segments into full VOD
|
||||
video.SizeBytes, err = vid.ConcatVideo(video, vodFiles, verbose)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to concatenate VOD segments: %v", err)
|
||||
os.Exit(1)
|
||||
fullVodExists := func () bool {
|
||||
// check if full VOD already exists with expected duration
|
||||
if fullVodProbe, err := scanner.ProbeSegment(video.Filename); err != nil {
|
||||
var totalLength float64 = 0
|
||||
for _, filename := range vodFiles {
|
||||
probe, err := scanner.ProbeSegment(filename)
|
||||
if err != nil { continue }
|
||||
totalLength += probe.Format.Duration
|
||||
}
|
||||
return fullVodProbe.Format.Duration == totalLength
|
||||
}
|
||||
return false
|
||||
}()
|
||||
if !fullVodExists {
|
||||
video.SizeBytes, err = vid.ConcatVideo(video, vodFiles, verbose)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to concatenate VOD segments: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
// youtube oauth flow
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue