mirror of
https://github.com/teacat/chaturbate-dvr.git
synced 2025-10-29 16:59:59 +00:00
Hang when the internet is disconnected
This commit is contained in:
parent
9596980c1b
commit
fa976d484e
@ -76,6 +76,9 @@ failed to fetch the video segments after retried, XXX might went offline.
|
||||
cannot find segment XXX, will try again. (1/5)
|
||||
無法找到影片段落,燒後會重新嘗試。(1/5)
|
||||
|
||||
inserting XXX segment to the master file.
|
||||
正在插入片段 XXX 至主要影片檔案。
|
||||
inserting XXX segment to the master file. (total: XXX)
|
||||
正在插入片段 XXX 至主要影片檔案。(總共:XXX)
|
||||
|
||||
skipped XXX due to the empty body!
|
||||
跳過 XXX 片段因為其為空白內容!
|
||||
```
|
||||
10
main.go
10
main.go
@ -192,7 +192,12 @@ func combineSegment(master *os.File, filename string) {
|
||||
<-time.After(4 * time.Second)
|
||||
|
||||
for {
|
||||
<-time.After(800 * time.Millisecond)
|
||||
<-time.After(300 * time.Millisecond)
|
||||
|
||||
if index == segmentIndex {
|
||||
<-time.After(1 * time.Second)
|
||||
continue
|
||||
}
|
||||
|
||||
if !pathx.Exists(fmt.Sprintf("%s~%d.ts", filename, index)) {
|
||||
if retry >= 5 {
|
||||
@ -213,7 +218,7 @@ func combineSegment(master *os.File, filename string) {
|
||||
//
|
||||
b, _ := ioutil.ReadFile(fmt.Sprintf("%s~%d.ts", filename, index))
|
||||
master.Write(b)
|
||||
log.Printf("inserting %d segment to the master file.", index)
|
||||
log.Printf("inserting %d segment to the master file. (total: %d)", index, segmentIndex)
|
||||
//
|
||||
os.Remove(fmt.Sprintf("%s~%d.ts", filename, index))
|
||||
//
|
||||
@ -226,6 +231,7 @@ func fetchSegment(master *os.File, segment *m3u8.MediaSegment, baseURL string, f
|
||||
_, body, _ := gorequest.New().Get(fmt.Sprintf("%s%s", baseURL, segment.URI)).EndBytes()
|
||||
log.Printf("fetching %s (size: %d)\n", segment.URI, len(body))
|
||||
if len(body) == 0 {
|
||||
log.Printf("skipped %s due to the empty body!\n", segment.URI)
|
||||
return
|
||||
}
|
||||
//
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user