Merge pull request #11 from mK33y/patch-3

Update main.go
This commit is contained in:
Yami Odymel 2022-09-07 06:06:22 +08:00 committed by GitHub
commit 6569e74147
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

12
main.go
View File

@ -122,7 +122,7 @@ func parseM3U8Source(url string) (chunks []*m3u8.MediaSegment, wait float64, err
// capture captures the specified channel streaming. // capture captures the specified channel streaming.
func capture(username string) { func capture(username string) {
// Define the video filename by current time //04.09.22 added username into filename mKeey. // Define the video filename by current time //04.09.22 added username into filename mK33y.
filename := username + "_" + time.Now().Format("2006-01-02_15-04-05") filename := username + "_" + time.Now().Format("2006-01-02_15-04-05")
// Get the channel page content body. // Get the channel page content body.
body := getBody(username) body := getBody(username)
@ -186,8 +186,11 @@ func isDuplicateSegment(URI string) bool {
} }
// combineSegment combines the segments to the master video file in the background. // combineSegment combines the segments to the master video file in the background.
// fixed segment problems mK33y.
// still needs some attention here
func combineSegment(master *os.File, filename string) { func combineSegment(master *os.File, filename string) {
index := 1 index := 1
delete := 1
var retry int var retry int
<-time.After(4 * time.Second) <-time.After(4 * time.Second)
@ -220,8 +223,11 @@ func combineSegment(master *os.File, filename string) {
master.Write(b) master.Write(b)
log.Printf("inserting %d segment to the master file. (total: %d)", index, segmentIndex) log.Printf("inserting %d segment to the master file. (total: %d)", index, segmentIndex)
// //
os.Remove(fmt.Sprintf("./%s/%s~%d.ts", savePath, filename, index)) e := os.Remove(fmt.Sprintf("./%s/%s~%d.ts", savePath, filename, delete))
// if e != nil {
delete--
}
delete++
index++ index++
} }
} }