From 4f6f54b63153995ba8b331f25625d84eeefc7e8a Mon Sep 17 00:00:00 2001 From: Anthony Axenov Date: Sun, 23 Nov 2025 00:30:10 +0800 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BA=D0=B0=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=B4=D0=B3=D0=BE=D1=82=D0=BE=D0=B2=D0=BA=D0=B8=20?= =?UTF-8?q?=D1=81=D0=BF=D0=B8=D1=81=D0=BA=D0=B0=20=D0=BB=D0=B8=D1=81=D1=82?= =?UTF-8?q?=D0=BE=D0=B2=20=D0=B4=D0=BB=D1=8F=20=D0=BF=D1=80=D0=BE=D0=B2?= =?UTF-8?q?=D0=B5=D1=80=D0=BA=D0=B8=20=D0=BD=D0=B0=20=D0=BA=D0=B0=D0=B6?= =?UTF-8?q?=D0=B4=D0=BE=D0=B9=20=D0=B8=D1=82=D0=B5=D1=80=D0=B0=D1=86=D0=B8?= =?UTF-8?q?=D0=B8=20--repeat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/check.go | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/cmd/check.go b/cmd/check.go index be9438a..ffaec3d 100644 --- a/cmd/check.go +++ b/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 {