Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
a99349e75d
|
|||
|
4f6f54b631
|
|||
|
895146b472
|
|||
|
522012d7d5
|
|||
|
a3c33d7ec1
|
|||
|
d7f28413b2
|
@@ -14,7 +14,7 @@ import (
|
|||||||
"github.com/redis/go-redis/v9"
|
"github.com/redis/go-redis/v9"
|
||||||
)
|
)
|
||||||
|
|
||||||
const VERSION = "1.1.0"
|
const VERSION = "1.1.3"
|
||||||
|
|
||||||
// Arguments описывает аргументы командной строки
|
// Arguments описывает аргументы командной строки
|
||||||
type Arguments struct {
|
type Arguments struct {
|
||||||
|
|||||||
@@ -196,6 +196,9 @@ func CheckChannels(pls playlist.Playlist) playlist.Playlist {
|
|||||||
return pls
|
return pls
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pls.OnlineCount = 0
|
||||||
|
pls.OfflineCount = 0
|
||||||
|
|
||||||
timeout, routines := calcParameters(count)
|
timeout, routines := calcParameters(count)
|
||||||
httpClient := http.Client{Timeout: timeout}
|
httpClient := http.Client{Timeout: timeout}
|
||||||
chSemaphores := make(chan struct{}, routines)
|
chSemaphores := make(chan struct{}, routines)
|
||||||
|
|||||||
57
cmd/check.go
57
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 {
|
||||||
@@ -35,13 +35,8 @@ var checkCmd = &cobra.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
currentIteration := 1
|
currentIteration := 1
|
||||||
iterationCount := app.Args.RepeatCount
|
|
||||||
if iterationCount <= 0 {
|
|
||||||
iterationCount = 1
|
|
||||||
}
|
|
||||||
|
|
||||||
for {
|
for {
|
||||||
if app.Args.RepeatCount > 1 {
|
if app.Args.RepeatCount != 1 {
|
||||||
log.Printf(
|
log.Printf(
|
||||||
"@ New iteration current=%d count=%d\n",
|
"@ New iteration current=%d count=%d\n",
|
||||||
currentIteration,
|
currentIteration,
|
||||||
@@ -49,27 +44,41 @@ 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)
|
||||||
log.Printf(
|
} else {
|
||||||
"Done! count=%d online=%d offline=%d elapsedTime=%.2fs\n",
|
if currentIteration == 1 {
|
||||||
len(lists),
|
lists = checker.PrepareListsToCheck(files, urls, codes)
|
||||||
onlineCount,
|
}
|
||||||
offlineCount,
|
|
||||||
time.Since(startTime).Seconds(),
|
|
||||||
)
|
|
||||||
|
|
||||||
if app.Args.NeedJson {
|
|
||||||
marshal, _ := json.Marshal(lists)
|
|
||||||
fmt.Println(string(marshal))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if app.Args.RepeatCount <= 1 || uint(currentIteration) == app.Args.RepeatCount {
|
if len(lists) > 0 {
|
||||||
break
|
startTime := time.Now()
|
||||||
|
onlineCount, offlineCount := checker.CheckPlaylists(lists)
|
||||||
|
|
||||||
|
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")
|
||||||
}
|
}
|
||||||
|
|
||||||
currentIteration++
|
if app.Args.RepeatCount != 0 {
|
||||||
|
if uint(currentIteration) == app.Args.RepeatCount {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
currentIteration++
|
||||||
|
}
|
||||||
log.Printf("Waiting for new iteration... seconds=%d\n", app.Args.RepeatEverySec)
|
log.Printf("Waiting for new iteration... seconds=%d\n", app.Args.RepeatEverySec)
|
||||||
time.Sleep(time.Duration(app.Args.RepeatEverySec) * time.Second)
|
time.Sleep(time.Duration(app.Args.RepeatEverySec) * time.Second)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user