Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 微博新增强制调整清晰度功能 #706

Merged
merged 2 commits into from
May 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/live/weibolive/weibolive.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"net/http"
"net/url"
"strings"
"regexp"
"fmt"

"github.com/hr3lxphr6j/bililive-go/src/pkg/utils"
"github.com/hr3lxphr6j/requests"
Expand Down Expand Up @@ -85,6 +87,19 @@ func (l *Live) GetStreamUrls() (us []*url.URL, err error) {
}

streamurl := gjson.GetBytes(body, "data.live_origin_flv_url").String()
queryParams := l.Url.Query()
quality := queryParams.Get("q")
if quality != "" {
targetQuality := "_wb" + quality + "avc.flv"
reg, err := regexp.Compile(`_wb[\d]+avc\.flv`)
if err == nil && reg.MatchString(streamurl) {
streamurl = reg.ReplaceAllString(streamurl, targetQuality)
} else {
streamurl = strings.Replace(streamurl, ".flv", targetQuality, -1)
}
fmt.Println("weibo stream quality fixed: " + streamurl)
}

return utils.GenUrls(streamurl)
}

Expand Down
Loading