diff options
Diffstat (limited to 'bilibili/streaming.go')
-rw-r--r-- | bilibili/streaming.go | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/bilibili/streaming.go b/bilibili/streaming.go index cc915a3..ec99565 100644 --- a/bilibili/streaming.go +++ b/bilibili/streaming.go @@ -59,8 +59,17 @@ func (b Bilibili) CopyLiveStream( defer cancelGuardian() // blocking copy - n, err := io.Copy(out, resp.Body) + n, err, isCancelled := common.Copy(ctx, out, resp.Body) + if isCancelled { + // cancelled by context + // this error is useless + err = nil + } + if !isCancelled && err != nil { + // real error happens + b.error.Printf("Stream copying was interrupted unexpectedly: %v", err) + } b.info.Printf("Bytes copied: %v", n) - return + return err } |