Aaron 7f4078961e
Some checks failed
Build Go Binaries / build (push) Has been cancelled
Check flag
2026-08-07 01:37:39 +00:00

60 lines
1.6 KiB
Go

package main
import (
"bufio"
"flag"
"fmt"
"m3u8-downloader/cmd/check"
"m3u8-downloader/cmd/downloader"
"m3u8-downloader/cmd/processor"
"m3u8-downloader/cmd/transfer"
"m3u8-downloader/pkg/constants"
"m3u8-downloader/pkg/logging"
"os"
"strings"
)
func main() {
url := flag.String("url", "", "M3U8 playlist URL")
eventName := flag.String("event", "", "Event name")
debug := flag.Bool("debug", false, "Enable debug mode")
transferOnly := flag.Bool("transfer", false, "Transfer-only mode: transfer existing files without downloading")
processOnly := flag.Bool("process", false, "Process-only mode: process existing files without downloading")
checkOnly := flag.Bool("check", false, "Connection-check mode: test the stream URL and NAS connectivity, then exit")
flag.Parse()
// Must happen before the first logging.MustGetFactory() call anywhere in
// the program, since the logging factory reads its level from this
// config singleton once and caches it.
if *debug {
constants.MustGetConfig().Logging.Level = "debug"
}
logging.MustGetFactory().App.Info("m3u8-downloader starting", "debug", *debug)
if *checkOnly {
os.Exit(check.Run(*url))
}
if *transferOnly {
transfer.RunTransferOnly(*eventName)
return
}
if *processOnly {
processor.Process(*eventName)
return
}
if *url == "" {
reader := bufio.NewReader(os.Stdin)
fmt.Print("Enter M3U8 playlist URL: ")
inputUrl, _ := reader.ReadString('\n')
inputUrl = strings.TrimSpace(inputUrl)
downloader.Download(inputUrl, *eventName, *debug)
return
}
downloader.Download(*url, *eventName, *debug)
}