7 Commits

Author SHA1 Message Date
6c3de4b2ef Исправления по Makefile (перетирались бинарники под разные арзитектуры в релизных архивах) 2025-11-23 01:15:38 +08:00
a99349e75d Версия v1.1.3
All checks were successful
Release / release (push) Successful in 3m23s
2025-11-23 00:30:59 +08:00
4f6f54b631 Исправлена логика подготовки списка листов для проверки на каждой итерации --repeat 2025-11-23 00:30:10 +08:00
895146b472 Версия v1.1.2
All checks were successful
Release / release (push) Successful in 4m2s
2025-11-22 21:28:39 +08:00
522012d7d5 Фикс подсчёта онлайн-оффлайн каналов 2025-11-22 21:28:06 +08:00
a3c33d7ec1 Версия v1.1.1
All checks were successful
Release / release (push) Successful in 4m53s
2025-11-22 19:28:00 +08:00
d7f28413b2 Скорректировано поведение --repeat
При значении 0 количество итераций будет бесконечным
2025-11-22 19:27:33 +08:00
4 changed files with 57 additions and 47 deletions

View File

@@ -3,14 +3,6 @@
BINARY_NAME := iptvc
GOARCH ?= amd64
LINUX_PATH := "bin/linux_$(GOARCH)"
WINDOWS_PATH := "bin/windows_$(GOARCH)"
DARWIN_PATH := "bin/darwin_$(GOARCH)"
LINUX_FILE := "$(LINUX_PATH)/$(BINARY_NAME)"
WINDOWS_FILE := "$(WINDOWS_PATH)/$(BINARY_NAME).exe"
DARWIN_FILE := "$(DARWIN_PATH)/$(BINARY_NAME)"
## clean: Remove all compiled binaries
clean:
@go clean
@@ -18,29 +10,35 @@ clean:
## linux: Build new binaries for linux
linux:
@rm -rf $(LINUX_PATH)
@GOARCH=$(GOARCH) GOOS=linux go build -o $(LINUX_FILE) . && echo "Compiled: $(LINUX_FILE)"
@rm -rf bin/linux_$(GOARCH)
@GOARCH=$(GOARCH) GOOS=linux go build -o bin/linux_$(GOARCH)/$(BINARY_NAME) .
@zip -j bin/linux_$(GOARCH).zip bin/linux_$(GOARCH)/$(BINARY_NAME)
@echo "Compiled: bin/linux_$(GOARCH)/$(BINARY_NAME) ($(GOARCH))"
## win: Build new binaries for windows
win:
@rm -rf $(WINDOWS_PATH)
@GOARCH=$(GOARCH) GOOS=windows go build -o $(WINDOWS_FILE) . && echo "Compiled: $(WINDOWS_FILE)"
@rm -rf bin/windows_$(GOARCH)
@GOARCH=$(GOARCH) GOOS=windows go build -o bin/windows_$(GOARCH)/$(BINARY_NAME).exe .
@zip -j bin/windows_$(GOARCH).zip bin/windows_$(GOARCH)/$(BINARY_NAME).exe
@echo "Compiled: bin/windows_$(GOARCH)/$(BINARY_NAME).exe ($(GOARCH))"
## darwin: Build new binaries for darwin
darwin:
@rm -rf $(DARWIN_PATH)
@GOARCH=$(GOARCH) GOOS=darwin go build -o $(DARWIN_FILE) . && echo "Compiled: $(DARWIN_FILE)"
## all: Build new binaries for linux, windows and darwin
all: clean linux win darwin
@rm -rf bin/darwin_$(GOARCH)
@GOARCH=$(GOARCH) GOOS=darwin go build -o bin/darwin_$(GOARCH)/$(BINARY_NAME) .
@zip -j bin/darwin_$(GOARCH).zip bin/darwin_$(GOARCH)/$(BINARY_NAME)
@echo "Compiled: bin/darwin_$(GOARCH)/$(BINARY_NAME) ($(GOARCH))"
## release: Build all binaries and zip them
release: linux win darwin
@zip -j $(LINUX_PATH).zip $(LINUX_FILE)
@zip -j $(DARWIN_PATH).zip $(DARWIN_FILE)
@zip -j $(WINDOWS_PATH).zip $(WINDOWS_FILE)
release: clean
@make linux GOARCH=amd64
@make linux GOARCH=arm64
@make win GOARCH=amd64
@make win GOARCH=arm64
@make darwin GOARCH=amd64
@make darwin GOARCH=arm64
## help: Show this message and exit
help: Makefile
@echo "Available recipes:"
@sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /'
@sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /'

View File

@@ -14,7 +14,7 @@ import (
"github.com/redis/go-redis/v9"
)
const VERSION = "1.1.0"
const VERSION = "1.1.3"
// Arguments описывает аргументы командной строки
type Arguments struct {

View File

@@ -196,6 +196,9 @@ func CheckChannels(pls playlist.Playlist) playlist.Playlist {
return pls
}
pls.OnlineCount = 0
pls.OfflineCount = 0
timeout, routines := calcParameters(count)
httpClient := http.Client{Timeout: timeout}
chSemaphores := make(chan struct{}, routines)

View File

@@ -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 {
@@ -35,13 +35,8 @@ var checkCmd = &cobra.Command{
}
currentIteration := 1
iterationCount := app.Args.RepeatCount
if iterationCount <= 0 {
iterationCount = 1
}
for {
if app.Args.RepeatCount > 1 {
if app.Args.RepeatCount != 1 {
log.Printf(
"@ New iteration current=%d count=%d\n",
currentIteration,
@@ -49,27 +44,41 @@ var checkCmd = &cobra.Command{
)
}
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))
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)
}
}
if app.Args.RepeatCount <= 1 || uint(currentIteration) == app.Args.RepeatCount {
break
if len(lists) > 0 {
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)
time.Sleep(time.Duration(app.Args.RepeatEverySec) * time.Second)
}