Support fake png as ts file
parent
71f55b91e9
commit
c6b731d558
17
download.go
17
download.go
|
|
@ -1,6 +1,7 @@
|
||||||
package m3u8d
|
package m3u8d
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"crypto/aes"
|
"crypto/aes"
|
||||||
"crypto/cipher"
|
"crypto/cipher"
|
||||||
|
|
@ -9,7 +10,6 @@ import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/orestonce/gopool"
|
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
@ -22,6 +22,8 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/orestonce/gopool"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TsInfo 用于保存 ts 文件的下载地址和文件名
|
// TsInfo 用于保存 ts 文件的下载地址和文件名
|
||||||
|
|
@ -36,6 +38,8 @@ type GetProgress_Resp struct {
|
||||||
StatusBar string
|
StatusBar string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var PNG_SIGN = []byte{0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A}
|
||||||
|
|
||||||
func GetProgress() (resp GetProgress_Resp) {
|
func GetProgress() (resp GetProgress_Resp) {
|
||||||
var sleepTh int32
|
var sleepTh int32
|
||||||
var speedV string
|
var speedV string
|
||||||
|
|
@ -416,6 +420,12 @@ func (this *downloadEnv) downloadTsFile(ts TsInfo, download_dir, key string) (er
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Detect Fake png file
|
||||||
|
if bytes.HasPrefix(origData, PNG_SIGN) {
|
||||||
|
origData = origData[8:]
|
||||||
|
}
|
||||||
|
|
||||||
// https://en.wikipedia.org/wiki/MPEG_transport_stream
|
// https://en.wikipedia.org/wiki/MPEG_transport_stream
|
||||||
// Some TS files do not start with SyncByte 0x47, they can not be played after merging,
|
// Some TS files do not start with SyncByte 0x47, they can not be played after merging,
|
||||||
// Need to remove the bytes before the SyncByte 0x47(71).
|
// Need to remove the bytes before the SyncByte 0x47(71).
|
||||||
|
|
@ -583,6 +593,11 @@ func (this *downloadEnv) sniffM3u8(urlS string) (afterUrl string, content []byte
|
||||||
containsTs = true
|
containsTs = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
// Support fake png ts
|
||||||
|
if UrlHasSuffix(line, ".png") {
|
||||||
|
containsTs = true
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if containsTs {
|
if containsTs {
|
||||||
return urlS, content, ""
|
return urlS, content, ""
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue