Skip to content

Commit dcfcf92

Browse files
committed
fix parameters
1 parent 75b262b commit dcfcf92

File tree

7 files changed

+18
-20
lines changed

7 files changed

+18
-20
lines changed

cmd/tv/main.go

-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
package main
44

55
import (
6-
"os"
76
"tv/internal/core"
87
"tv/internal/sys"
98
"tv/internal/web"
@@ -37,11 +36,6 @@ func main() {
3736
if err := web.Router(); err != nil {
3837
log.Fatal(err)
3938
}
40-
if _, err := os.Stat(sys.Options.MediaPath); os.IsNotExist(err) {
41-
if err := os.MkdirAll(sys.Options.MediaPath, 0755); err != nil {
42-
log.Fatal("Cannot create media folder", err)
43-
}
44-
}
4539
go core.Start()
4640
if err := tibulaWeb.Start(); err != nil {
4741
log.Fatal("Cannot start the web service: ", err)

internal/core/channels.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,13 @@ import (
1616
"github.com/eja/tibula/log"
1717
)
1818

19-
const channelsBatch = 100
20-
2119
func checkChannels() (err error) {
2220
db := tibula.Session()
2321
if err = db.Open(sys.Options.DbType, sys.Options.DbName, sys.Options.DbUser, sys.Options.DbPass, sys.Options.DbHost, sys.Options.DbPort); err != nil {
2422
return
2523
}
2624
for {
27-
timeLastCheck := time.Now().Add(-time.Duration(sys.Options.CheckInterval) * time.Second).Format("2006-01-02 15:04:05")
25+
timeLastCheck := time.Now().Add(-time.Duration(sys.Options.TvCheckInterval) * time.Second).Format("2006-01-02 15:04:05")
2826
timeLastWorking := time.Now().Add(-30 * 24 * time.Hour).Format("2006-01-02 15:04:05")
2927
rows, err := db.Rows(`SELECT * FROM tvChannels WHERE
3028
(checkLast < ? OR checkLast IS NULL OR checkLast = "") AND
@@ -36,7 +34,7 @@ func checkChannels() (err error) {
3634
name != ""
3735
ORDER BY power DESC, checkLast ASC
3836
LIMIT ?
39-
`, timeLastCheck, timeLastWorking, timeLastWorking, channelsBatch)
37+
`, timeLastCheck, timeLastWorking, timeLastWorking, sys.Options.TvCheckBatch)
4038
if err != nil {
4139
return err
4240
}
@@ -46,7 +44,7 @@ func checkChannels() (err error) {
4644
var videoSize string
4745
status := 0
4846
ABR := 0
49-
framePath := filepath.Join(sys.Options.MediaPath, row["name"]+".png")
47+
framePath := filepath.Join(sys.Options.TvMediaPath, row["name"]+".png")
5048

5149
cors, subtitles, err := checkPlaylist(row["sourceUrl"])
5250
if err != nil {

internal/core/main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import (
1111
const tag = "[tv] [core]"
1212

1313
func Start() (err error) {
14-
if _, err = os.Stat(sys.Options.MediaPath); err != nil {
15-
err = os.MkdirAll(sys.Options.MediaPath, os.ModePerm)
14+
if _, err = os.Stat(sys.Options.TvMediaPath); err != nil {
15+
err = os.MkdirAll(sys.Options.TvMediaPath, os.ModePerm)
1616
if err != nil {
1717
return err
1818
}

internal/sys/main.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ import (
1212
var Options typeConfigSys
1313

1414
func Configure() error {
15-
flag.StringVar(&Options.MediaPath, "media-path", "/opt/eja/tv/media", "Media folder path")
16-
flag.IntVar(&Options.CheckInterval, "check-interval", 3600, "Channels check interval")
15+
flag.StringVar(&Options.TvMediaPath, "tv-media-path", "/opt/eja/tv/media", "Media folder path")
16+
flag.IntVar(&Options.TvCheckInterval, "tv-check-interval", 3600, "Channels check interval")
17+
flag.IntVar(&Options.TvCheckBatch, "tv-check-batch", 10, "Channels check batch")
1718

1819
if err := sys.Configure(); err != nil {
1920
return err

internal/sys/types.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ import (
88

99
type typeConfigSys struct {
1010
sys.TypeConfig
11-
MediaPath string `json:"media_path,omitempty"`
12-
CheckInterval int `json:"check_interval,omitempty"`
11+
TvMediaPath string `json:"tv_media_path,omitempty"`
12+
TvCheckInterval int `json:"tv_check_interval,omitempty"`
13+
TvCheckBatch int `json:"tv_check_batch,omitempty"`
1314
}
1415

1516
var String = sys.String

internal/sys/version.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
package sys
44

55
const Name = "tv"
6-
const Version = "8.7.1"
6+
const Version = "8.7.2"

internal/sys/wizard.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,14 @@ func Wizard() error {
1818
return err
1919
}
2020

21-
Options.MediaPath = sys.WizardPrompt("Media folder path")
21+
Options.TvMediaPath = sys.WizardPrompt("Media folder path")
2222
checkInterval := sys.WizardPrompt("Channels check interval")
2323
if checkInterval != "" {
24-
Options.CheckInterval = int(Number(checkInterval))
24+
Options.TvCheckInterval = int(Number(checkInterval))
25+
}
26+
checkBatch := sys.WizardPrompt("Channels check batch size")
27+
if checkBatch != "" {
28+
Options.TvCheckBatch = int(Number(checkBatch))
2529
}
2630

2731
tibula.Assets = dbAssets

0 commit comments

Comments
 (0)