This commit is contained in:
2026-05-30 09:24:42 +08:00
parent 6c3de4b2ef
commit e054f458bb
17 changed files with 533 additions and 78 deletions
+11 -12
View File
@@ -9,7 +9,6 @@ package cmd
import (
"axenov/iptv-checker/app"
"axenov/iptv-checker/app/checker"
"axenov/iptv-checker/app/playlist"
"encoding/json"
"fmt"
"log"
@@ -44,18 +43,14 @@ var checkCmd = &cobra.Command{
)
}
var lists []playlist.Playlist
if len(files) == 0 && len(urls) == 0 && len(codes) == 0 {
lists = checker.PrepareListsToCheck(files, urls, codes)
} else {
if currentIteration == 1 {
lists = checker.PrepareListsToCheck(files, urls, codes)
}
}
ch := checker.NewChecker(app.Args.TagsPath)
lists := ch.PrepareListsToCheck(files, urls, codes)
if len(lists) > 0 {
startTime := time.Now()
onlineCount, offlineCount := checker.CheckPlaylists(lists)
ctx := cmd.Context()
onlineCount, offlineCount := ch.CheckPlaylists(ctx, lists)
log.Printf(
"Done! count=%d online=%d offline=%d elapsedTime=%.2fs\n",
@@ -66,8 +61,12 @@ var checkCmd = &cobra.Command{
)
if app.Args.NeedJson {
marshal, _ := json.Marshal(lists)
fmt.Println(string(marshal))
marshal, err := json.Marshal(lists)
if err != nil {
log.Printf("Error marshaling results: %s", err)
} else {
fmt.Println(string(marshal))
}
}
} else {
log.Println("There are no playlists to check")