kacarmichael 309eeef59a
Some checks failed
Build Go Binaries / build (push) Has been cancelled
Health/status http endpoint, logging
2026-08-06 01:24:29 -05:00

54 lines
1.4 KiB
Go

package main
import (
"bufio"
"flag"
"fmt"
"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")
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 *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)
}