From 2911eb217e5d80e97634fdcb066ec4d898d0824a Mon Sep 17 00:00:00 2001 From: YamiOdymel Date: Thu, 13 Feb 2020 15:15:40 +0800 Subject: [PATCH] Fixing dropping frames --- main.go | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index 902dc49..13ed50a 100644 --- a/main.go +++ b/main.go @@ -214,11 +214,18 @@ func fetchSegment(master *os.File, segment *m3u8.MediaSegment, baseURL string, f break } // - b, _ := ioutil.ReadFile(fmt.Sprintf("%s~%d.ts", filename, index-1)) - if _, err := master.Write(b); err != nil { - panic(err) + if retry > 3 { + // + b, _ := ioutil.ReadFile(fmt.Sprintf("%s~%d.ts", filename, index)) + master.Write(b) + // + os.Remove(fmt.Sprintf("%s~%d.ts", filename, index)) + return } // + b, _ := ioutil.ReadFile(fmt.Sprintf("%s~%d.ts", filename, index-1)) + master.Write(b) + // os.Remove(fmt.Sprintf("%s~%d.ts", filename, index-1)) } @@ -237,8 +244,8 @@ func endpoint(c *cli.Context) error { continue } // Otherwise we keep checking the channel status until the user is online. - log.Printf("%s is offlined, check again after 1 minutes...", c.String("username")) - <-time.After(time.Minute * 1) + log.Printf("%s is offlined, check again after %d minutes...", c.String("username"), c.Int("interval")) + <-time.After(time.Minute * time.Duration(c.Int("interval"))) } return nil } @@ -258,6 +265,12 @@ func main() { Value: "", Usage: "video quality with `high`, `medium` and `low`", }, + &cli.IntFlag{ + Name: "interval", + Aliases: []string{"i"}, + Value: 1, + Usage: "minutes to check if a channel goes online or not", + }, }, Name: "chaturbate-dvr", Usage: "watching a specified chaturbate channel and auto saved to local file",