This commit is contained in:
49
cmd/check.go
Normal file
49
cmd/check.go
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 2025, Антон Аксенов
|
||||
* This file is part of iptvc project
|
||||
* MIT License: https://git.axenov.dev/IPTV/iptvc/src/branch/master/LICENSE
|
||||
*/
|
||||
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"axenov/iptv-checker/app"
|
||||
"axenov/iptv-checker/app/checker"
|
||||
"axenov/iptv-checker/app/logger"
|
||||
"github.com/spf13/cobra"
|
||||
"log"
|
||||
"os"
|
||||
)
|
||||
|
||||
// checkCmd represents the file command
|
||||
var checkCmd = &cobra.Command{
|
||||
Use: "check",
|
||||
Short: "Check playlists",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
logger.Init(app.Args.NeedQuiet)
|
||||
|
||||
files, _ := cmd.Flags().GetStringSlice("file")
|
||||
urls, _ := cmd.Flags().GetStringSlice("url")
|
||||
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)
|
||||
checker.CheckPlaylists(lists)
|
||||
},
|
||||
}
|
||||
|
||||
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().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")
|
||||
rootCmd.AddCommand(checkCmd)
|
||||
}
|
||||
Reference in New Issue
Block a user