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