Исправлена логика подготовки списка листов для проверки на каждой итерации --repeat
This commit is contained in:
39
cmd/check.go
39
cmd/check.go
@@ -9,6 +9,7 @@ package cmd
|
||||
import (
|
||||
"axenov/iptv-checker/app"
|
||||
"axenov/iptv-checker/app/checker"
|
||||
"axenov/iptv-checker/app/playlist"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
@@ -27,7 +28,6 @@ var checkCmd = &cobra.Command{
|
||||
files, _ := cmd.Flags().GetStringSlice("file")
|
||||
urls, _ := cmd.Flags().GetStringSlice("url")
|
||||
codes, _ := cmd.Flags().GetStringSlice("code")
|
||||
lists := checker.PrepareListsToCheck(files, urls, codes)
|
||||
|
||||
waitSeconds := app.Args.RepeatEverySec
|
||||
if waitSeconds <= 0 {
|
||||
@@ -44,20 +44,33 @@ var checkCmd = &cobra.Command{
|
||||
)
|
||||
}
|
||||
|
||||
startTime := time.Now()
|
||||
onlineCount, offlineCount := checker.CheckPlaylists(lists)
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
log.Printf(
|
||||
"Done! count=%d online=%d offline=%d elapsedTime=%.2fs\n",
|
||||
len(lists),
|
||||
onlineCount,
|
||||
offlineCount,
|
||||
time.Since(startTime).Seconds(),
|
||||
)
|
||||
if len(lists) > 0 {
|
||||
startTime := time.Now()
|
||||
onlineCount, offlineCount := checker.CheckPlaylists(lists)
|
||||
|
||||
if app.Args.NeedJson {
|
||||
marshal, _ := json.Marshal(lists)
|
||||
fmt.Println(string(marshal))
|
||||
log.Printf(
|
||||
"Done! count=%d online=%d offline=%d elapsedTime=%.2fs\n",
|
||||
len(lists),
|
||||
onlineCount,
|
||||
offlineCount,
|
||||
time.Since(startTime).Seconds(),
|
||||
)
|
||||
|
||||
if app.Args.NeedJson {
|
||||
marshal, _ := json.Marshal(lists)
|
||||
fmt.Println(string(marshal))
|
||||
}
|
||||
} else {
|
||||
log.Println("There are no playlists to check")
|
||||
}
|
||||
|
||||
if app.Args.RepeatCount != 0 {
|
||||
|
||||
Reference in New Issue
Block a user