wip7
This commit is contained in:
+14
-25
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2025, Антон Аксенов
|
||||
* Copyright (c) 2025-2026, Антон Аксенов
|
||||
* This file is part of iptvc project
|
||||
* MIT License: https://git.axenov.dev/IPTV/iptvc/src/branch/master/LICENSE
|
||||
*/
|
||||
@@ -24,15 +24,10 @@ var checkCmd = &cobra.Command{
|
||||
Short: "Check playlists",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
app.Init()
|
||||
|
||||
files, _ := cmd.Flags().GetStringSlice("file")
|
||||
urls, _ := cmd.Flags().GetStringSlice("url")
|
||||
codes, _ := cmd.Flags().GetStringSlice("code")
|
||||
|
||||
waitSeconds := app.Args.RepeatEverySec
|
||||
if waitSeconds <= 0 {
|
||||
waitSeconds = 5
|
||||
}
|
||||
applyAppOverrides(cmd)
|
||||
applyCacheOverrides(cmd)
|
||||
applyCheckOverrides(cmd)
|
||||
app.InitCache()
|
||||
|
||||
currentIteration := 1
|
||||
for {
|
||||
@@ -45,11 +40,11 @@ var checkCmd = &cobra.Command{
|
||||
}
|
||||
|
||||
var lists []playlist.Playlist
|
||||
if len(files) == 0 && len(urls) == 0 && len(codes) == 0 {
|
||||
lists = checker.PrepareListsToCheck(files, urls, codes)
|
||||
if len(app.Args.Files) == 0 && len(app.Args.Urls) == 0 && len(app.Args.Codes) == 0 {
|
||||
lists = checker.PrepareListsToCheck(app.Args.Files, app.Args.Urls, app.Args.Codes)
|
||||
} else {
|
||||
if currentIteration == 1 {
|
||||
lists = checker.PrepareListsToCheck(files, urls, codes)
|
||||
lists = checker.PrepareListsToCheck(app.Args.Files, app.Args.Urls, app.Args.Codes)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,22 +74,16 @@ var checkCmd = &cobra.Command{
|
||||
}
|
||||
currentIteration++
|
||||
}
|
||||
log.Printf("Waiting for new iteration... seconds=%d\n", app.Args.RepeatEverySec)
|
||||
time.Sleep(time.Duration(app.Args.RepeatEverySec) * time.Second)
|
||||
// AllCooldown хранится в миллисекундах, поэтому переводим в time.Millisecond
|
||||
cooldown := time.Duration(app.Config.Check.Playlists.AllCooldown.Value()) * time.Millisecond
|
||||
log.Printf("Waiting for new iteration... cooldown=%s\n", cooldown)
|
||||
time.Sleep(cooldown)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
checkCmd.Flags().StringVarP(&app.Args.TagsPath, "tags", "t", "./channels.json", "path to a local tagfile")
|
||||
checkCmd.Flags().StringVarP(&app.Args.IniPath, "ini", "i", "./playlists.ini", "path to a local ini-file")
|
||||
checkCmd.Flags().UintVarP(&app.Args.RandomCount, "random", "r", 0, "take this count of random playlists to check from ini-file")
|
||||
checkCmd.Flags().UintVarP(&app.Args.RepeatCount, "repeat", "", 1, "repeat same check X times")
|
||||
checkCmd.Flags().UintVarP(&app.Args.RepeatEverySec, "every", "", 5, "wait N seconds after every check")
|
||||
checkCmd.Flags().BoolVarP(&app.Args.NeedJson, "json", "j", false, "print results in JSON format in the end")
|
||||
checkCmd.Flags().BoolVarP(&app.Args.NeedQuiet, "quiet", "q", false, "suppress logs (does not affect on -j)")
|
||||
checkCmd.Flags().StringSliceP("file", "f", []string{}, "path to a local playlist file (m3u/m3u8)")
|
||||
checkCmd.Flags().StringSliceP("url", "u", []string{}, "URL to a remote playlist (http/https)")
|
||||
checkCmd.Flags().StringSliceP("code", "c", []string{}, "code of playlist from ini-file")
|
||||
addCommonCheckFlags(checkCmd, 1)
|
||||
addCheckOnlyFlags(checkCmd)
|
||||
rootCmd.AddCommand(checkCmd)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user