Фикс игнорирования флагов -f/-u/-c при наличии playlists.ini

This commit is contained in:
2025-05-06 22:52:26 +08:00
parent 9c4f09db81
commit a346d9e2d7
2 changed files with 23 additions and 26 deletions

View File

@@ -53,6 +53,7 @@ func PrepareListsToCheck(files []string, urls []string, codes []string) []playli
} }
} }
if len(lists) == 0 || len(codes) > 0 {
ini, err := inifile.Init(app.Args.IniPath) ini, err := inifile.Init(app.Args.IniPath)
if err != nil { if err != nil {
log.Printf("Warning: %s, all --code flags will be ignored\n", err) log.Printf("Warning: %s, all --code flags will be ignored\n", err)
@@ -75,6 +76,7 @@ func PrepareListsToCheck(files []string, urls []string, codes []string) []playli
lists = lists[:app.Args.RandomCount] lists = lists[:app.Args.RandomCount]
} }
} }
}
return lists return lists
} }

View File

@@ -12,7 +12,6 @@ import (
"axenov/iptv-checker/app/logger" "axenov/iptv-checker/app/logger"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"log" "log"
"os"
) )
// checkCmd represents the file command // checkCmd represents the file command
@@ -25,14 +24,10 @@ var checkCmd = &cobra.Command{
files, _ := cmd.Flags().GetStringSlice("file") files, _ := cmd.Flags().GetStringSlice("file")
urls, _ := cmd.Flags().GetStringSlice("url") urls, _ := cmd.Flags().GetStringSlice("url")
codes, _ := cmd.Flags().GetStringSlice("code") codes, _ := cmd.Flags().GetStringSlice("code")
if len(files) < 1 && len(urls) < 1 && len(codes) < 1 {
log.Println("ERROR: You should provide at least one of --file, --url or --code flags")
os.Exit(2)
}
lists := checker.PrepareListsToCheck(files, urls, codes) lists := checker.PrepareListsToCheck(files, urls, codes)
checker.CheckPlaylists(lists) checker.CheckPlaylists(lists)
log.Println("Done!")
}, },
} }