parent
eebda76ca4
commit
8095e1a8dc
17
download.go
17
download.go
|
|
@ -535,18 +535,21 @@ func (this *downloadEnv) sniffM3u8(urlS string) (afterUrl string, content []byte
|
|||
if err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
if strings.HasSuffix(strings.ToLower(urlS), ".m3u8") {
|
||||
if UrlHasSuffix(urlS, ".m3u8") {
|
||||
// 看这个是不是嵌套的m3u8
|
||||
var m3u8Url string
|
||||
containsTs := false
|
||||
for _, line := range strings.Split(string(content), "\n") {
|
||||
lineOrigin := strings.TrimSpace(line)
|
||||
if strings.HasPrefix(lineOrigin, "#") {
|
||||
continue
|
||||
}
|
||||
line = strings.ToLower(lineOrigin)
|
||||
if strings.HasSuffix(line, ".m3u8") {
|
||||
if UrlHasSuffix(line, ".m3u8") {
|
||||
m3u8Url = lineOrigin
|
||||
break
|
||||
}
|
||||
if strings.HasSuffix(line, ".ts") {
|
||||
if UrlHasSuffix(line, ".ts") {
|
||||
containsTs = true
|
||||
break
|
||||
}
|
||||
|
|
@ -577,6 +580,14 @@ func (this *downloadEnv) sniffM3u8(urlS string) (afterUrl string, content []byte
|
|||
return "", nil, errors.New("未发现m3u8资源_3")
|
||||
}
|
||||
|
||||
func UrlHasSuffix(urlS string, suff string) bool {
|
||||
urlObj, err := url.Parse(urlS)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return strings.HasSuffix(strings.ToLower(urlObj.Path), suff)
|
||||
}
|
||||
|
||||
func (this *downloadEnv) doGetRequest(urlS string) (data []byte, err error) {
|
||||
req, err := http.NewRequest(http.MethodGet, urlS, nil)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
package m3u8d
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestUrlHasSuffix(t *testing.T) {
|
||||
if UrlHasSuffix("/0001.ts", ".ts") == false {
|
||||
t.Fatal()
|
||||
return
|
||||
}
|
||||
if UrlHasSuffix("/0001.Ts", ".ts") == false {
|
||||
t.Fatal()
|
||||
return
|
||||
}
|
||||
if UrlHasSuffix("/0001.ts?v=123", ".ts") == false {
|
||||
t.Fatal()
|
||||
return
|
||||
}
|
||||
if UrlHasSuffix("https://www.example.com/0001.m3u8?hsd=12", "hsd") {
|
||||
t.Fatal()
|
||||
return
|
||||
}
|
||||
if UrlHasSuffix("https://www.example.com/0001.m3U8?hsd=12", ".m3u8") == false {
|
||||
t.Fatal()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
@ -3,15 +3,22 @@ package main
|
|||
import (
|
||||
"fmt"
|
||||
"github.com/orestonce/go2cpp"
|
||||
"golang.org/x/text/encoding/simplifiedchinese"
|
||||
"io/ioutil"
|
||||
"m3u8d"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const version = "1.5.1"
|
||||
|
||||
func main() {
|
||||
BuildCliBinary() // 编译二进制
|
||||
CreateLibForQtUi() // 创建Qt需要使用的.a库文件
|
||||
WriteVersionDotRc()
|
||||
}
|
||||
|
||||
func BuildCliBinary() {
|
||||
|
|
@ -42,7 +49,7 @@ func BuildCliBinary() {
|
|||
},
|
||||
}
|
||||
for _, cfg := range list {
|
||||
name := "m3u8d_cli_v1.5.0_" + cfg.GOOS + "_" + cfg.GOARCH
|
||||
name := "m3u8d_cli_v" + version + "_" + cfg.GOOS + "_" + cfg.GOARCH
|
||||
cmd := exec.Command("go", "build", "-trimpath", "-ldflags", "-s -w", "-o", filepath.Join(wd, "bin", name))
|
||||
cmd.Dir = filepath.Join(wd, "cmd")
|
||||
cmd.Env = append(os.Environ(), "GOOS="+cfg.GOOS)
|
||||
|
|
@ -72,3 +79,70 @@ func CreateLibForQtUi() {
|
|||
ctx.Generate1(m3u8d.RunDownload_Req_ToCurlStr)
|
||||
ctx.MustCreateAmd64LibraryInDir("m3u8d-qt")
|
||||
}
|
||||
|
||||
func WriteVersionDotRc() {
|
||||
tmp := strings.Split(version, ".")
|
||||
ok := len(tmp) == 3
|
||||
for _, v := range tmp {
|
||||
vi, err := strconv.Atoi(v)
|
||||
if err != nil {
|
||||
ok = false
|
||||
break
|
||||
}
|
||||
if vi < 0 {
|
||||
ok = false
|
||||
break
|
||||
}
|
||||
}
|
||||
if ok == false {
|
||||
panic("version invalid: " + strconv.Quote(version))
|
||||
}
|
||||
tmp = append(tmp, "0")
|
||||
v1 := strings.Join(tmp, ",")
|
||||
data := []byte(`IDI_ICON1 ICON "favicon.ico"
|
||||
|
||||
#if defined(UNDER_CE)
|
||||
#include <winbase.h>
|
||||
#else
|
||||
#include <winver.h>
|
||||
#endif
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION ` + v1 + `
|
||||
PRODUCTVERSION ` + v1 + `
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS VS_FF_DEBUG
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS VOS__WINDOWS32
|
||||
FILETYPE VFT_DLL
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "080404b0"
|
||||
BEGIN
|
||||
VALUE "ProductVersion", "` + version + `.0\0"
|
||||
VALUE "ProductName", "m3u8视频下载工具\0"
|
||||
VALUE "LegalCopyright", "https://github.com/orestonce/m3u8d\0"
|
||||
VALUE "FileDescription", "m3u8视频下载工具\0"
|
||||
END
|
||||
END
|
||||
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x804, 1200
|
||||
END
|
||||
END
|
||||
`)
|
||||
data, err := simplifiedchinese.GBK.NewEncoder().Bytes(data)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
err = ioutil.WriteFile("m3u8d-qt/version.rc", data, 0777)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
1
go.mod
1
go.mod
|
|
@ -9,6 +9,7 @@ require (
|
|||
github.com/spf13/cobra v1.4.0
|
||||
github.com/yapingcat/gomedia v0.0.0-20220623101430-02bb90c39484
|
||||
golang.org/x/net v0.0.0-20220617184016-355a448f1bc9
|
||||
golang.org/x/text v0.3.7
|
||||
)
|
||||
|
||||
require (
|
||||
|
|
|
|||
1
go.sum
1
go.sum
|
|
@ -19,6 +19,7 @@ golang.org/x/net v0.0.0-20220617184016-355a448f1bc9/go.mod h1:XRhObCWvk6IyKnWLug
|
|||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ void MainWindow::on_pushButton_RunDownload_clicked()
|
|||
ui->checkBox_Insecure->setEnabled(false);
|
||||
ui->progressBar->setValue(0);
|
||||
ui->lineEdit_SetProxy->setEnabled(false);
|
||||
ui->pushButton_curlMode->setEnabled(false);
|
||||
ui->pushButton_StopDownload->setEnabled(true);
|
||||
|
||||
m_syncUi.AddRunFnOn_OtherThread([this](){
|
||||
|
|
@ -81,6 +82,7 @@ void MainWindow::on_pushButton_RunDownload_clicked()
|
|||
ui->pushButton_RunDownload->setText("开始下载");
|
||||
ui->lineEdit_SetProxy->setEnabled(true);
|
||||
ui->pushButton_StopDownload->setEnabled(false);
|
||||
ui->pushButton_curlMode->setEnabled(true);
|
||||
if (resp.IsCancel) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ IDI_ICON1 ICON "favicon.ico"
|
|||
#endif
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,5,0,0
|
||||
PRODUCTVERSION 1,5,0,0
|
||||
FILEVERSION 1,5,1,0
|
||||
PRODUCTVERSION 1,5,1,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS VS_FF_DEBUG
|
||||
|
|
@ -23,7 +23,7 @@ VS_VERSION_INFO VERSIONINFO
|
|||
BEGIN
|
||||
BLOCK "080404b0"
|
||||
BEGIN
|
||||
VALUE "ProductVersion", "1.5.0.0\0"
|
||||
VALUE "ProductVersion", "1.5.1.0\0"
|
||||
VALUE "ProductName", "m3u8视频下载工具\0"
|
||||
VALUE "LegalCopyright", "https://github.com/orestonce/m3u8d\0"
|
||||
VALUE "FileDescription", "m3u8视频下载工具\0"
|
||||
|
|
|
|||
Loading…
Reference in New Issue