diff --git a/fc2/fc2_livestream.go b/fc2/fc2_livestream.go index b6c5650..a29cf39 100644 --- a/fc2/fc2_livestream.go +++ b/fc2/fc2_livestream.go @@ -63,8 +63,6 @@ func (ls *LiveStream) WaitForOnline(ctx context.Context, interval time.Duration) } func (ls *LiveStream) IsOnline(ctx context.Context, options ...GetMetaOptions) (bool, error) { - ls.log.Debug().Msg("checking if online") - return try.DoExponentialBackoffWithContextAndResult( ctx, 5, @@ -97,14 +95,14 @@ func (ls *LiveStream) GetMeta( ctx context.Context, options ...GetMetaOptions, ) (*GetMetaData, error) { + ctx, cancel := context.WithTimeout(ctx, 20*time.Second) + defer cancel() if len(options) > 0 { if !options[0].Refetch && ls.meta != nil { return ls.meta, nil } } - ls.log.Debug().Msg("fetching new meta") - v := url.Values{ "channel": []string{"1"}, "profile": []string{"1"}, @@ -196,6 +194,8 @@ func (ls *LiveStream) GetWebSocketURL(ctx context.Context) (string, error) { "client_app": []string{"browser_hls"}, "ipv6": []string{""}, } + ctx, cancel := context.WithTimeout(ctx, 20*time.Second) + defer cancel() req, err := http.NewRequestWithContext( ctx, "POST", diff --git a/fc2/fc2_websocket.go b/fc2/fc2_websocket.go index cf01a7e..f419ce3 100644 --- a/fc2/fc2_websocket.go +++ b/fc2/fc2_websocket.go @@ -210,6 +210,8 @@ func (w *WebSocket) sendMessage( arguments interface{}, msgID int, ) error { + ctx, cancel := context.WithTimeout(ctx, 15*time.Second) + defer cancel() // Build message msgObj := make(map[string]interface{}) msgObj["name"] = name diff --git a/go.mod b/go.mod index 0f409e6..503de3a 100644 --- a/go.mod +++ b/go.mod @@ -90,7 +90,7 @@ require ( github.com/kisielk/errcheck v1.6.3 // indirect github.com/kisielk/gotool v1.0.0 // indirect github.com/kkHAIKE/contextcheck v1.1.4 // indirect - github.com/klauspost/compress v1.16.7 // indirect + github.com/klauspost/compress v1.17.0 // indirect github.com/kulti/thelper v0.6.3 // indirect github.com/kunwardeep/paralleltest v1.0.8 // indirect github.com/kyoh86/exportloopref v0.1.11 // indirect diff --git a/go.sum b/go.sum index 6b3acd1..336a723 100644 --- a/go.sum +++ b/go.sum @@ -356,6 +356,8 @@ github.com/kkHAIKE/contextcheck v1.1.4/go.mod h1:1+i/gWqokIa+dm31mqGLZhZJ7Uh44DJ github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I= github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/klauspost/compress v1.17.0 h1:Rnbp4K9EjcDuVuHtd0dgA4qNuv9yKDYKK1ulpJwgrqM= +github.com/klauspost/compress v1.17.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= diff --git a/hls/hls_downloader.go b/hls/hls_downloader.go index 54fbd76..703bc77 100644 --- a/hls/hls_downloader.go +++ b/hls/hls_downloader.go @@ -39,6 +39,8 @@ func NewDownloader( } func (hls *Downloader) GetFragmentURLs(ctx context.Context) ([]string, error) { + ctx, cancel := context.WithTimeout(ctx, 20*time.Second) + defer cancel() req, err := http.NewRequestWithContext(ctx, "GET", hls.url, nil) if err != nil { return []string{}, err @@ -141,6 +143,8 @@ func (hls *Downloader) fillQueue(ctx context.Context, urlChan chan<- string) err } func (hls *Downloader) download(ctx context.Context, url string) ([]byte, error) { + ctx, cancel := context.WithTimeout(ctx, 20*time.Second) + defer cancel() req, err := http.NewRequestWithContext(ctx, "GET", url, nil) if err != nil { return []byte{}, err diff --git a/main.go b/main.go index b85578c..d909c25 100644 --- a/main.go +++ b/main.go @@ -25,8 +25,10 @@ var app = &cli.App{ HasBeenSet: true, Action: func(ctx *cli.Context, s bool) error { if s { + log.Logger = log.Logger.Level(zerolog.DebugLevel) zerolog.SetGlobalLevel(zerolog.DebugLevel) } else { + log.Logger = log.Logger.Level(zerolog.InfoLevel) zerolog.SetGlobalLevel(zerolog.InfoLevel) } return nil