mirror of
https://codeberg.org/SafeTwitch/safetwitch-backend.git
synced 2024-12-22 05:02:58 -05:00
Add option to exclude audio only
This commit is contained in:
parent
8d5ca942a6
commit
25d2da75b9
2 changed files with 14 additions and 3 deletions
|
@ -7,14 +7,20 @@ import (
|
|||
"strings"
|
||||
)
|
||||
|
||||
func GetStream(streamerName string) (string, error) {
|
||||
func GetStream(streamerName string, withAudioOnly bool) (string, error) {
|
||||
|
||||
tokenwsig, err := getPlaybackAccessToken(streamerName, "")
|
||||
token := tokenwsig.Token
|
||||
signature := tokenwsig.Signature
|
||||
|
||||
playlistUrl := "https://usher.ttvnw.net/api/channel/hls/" + strings.ToLower(streamerName) + ".m3u8"
|
||||
params := fmt.Sprintf("?sig=%s&token=%s&acmb=e30=&allow_source=true&allow_audio_only=true&fast_bread=true&p=4189675&player_backend=mediaplayer&playlist_include_framerate=true&reassignments_supported=true&transcode_mode=cbr_v1&cdm=wv&player_version=1.20.0", signature, token)
|
||||
var params string
|
||||
|
||||
if withAudioOnly {
|
||||
params = fmt.Sprintf("?sig=%s&token=%s&acmb=e30=&allow_source=true&allow_audio_only=true&fast_bread=true&p=4189675&player_backend=mediaplayer&playlist_include_framerate=true&reassignments_supported=true&transcode_mode=cbr_v1&cdm=wv&player_version=1.20.0", signature, token)
|
||||
} else {
|
||||
params = fmt.Sprintf("?sig=%s&token=%s&acmb=e30=&fast_bread=true&p=4189675&player_backend=mediaplayer&playlist_include_framerate=true&reassignments_supported=true&transcode_mode=cbr_v1&cdm=wv&player_version=1.20.0", signature, token)
|
||||
}
|
||||
|
||||
req, err := http.NewRequest("GET", playlistUrl+params, nil)
|
||||
req.Header.Add("Client-Id", "ue6666qo983tsx6so1t0vnawi233wa")
|
||||
|
|
|
@ -40,7 +40,12 @@ func Routes(route *gin.Engine) {
|
|||
|
||||
auth.GET("/stream/:username/hls.m3u8", func(context *gin.Context) {
|
||||
streamer := context.Param("username")
|
||||
playlistFile, err := twitch.GetStream(streamer)
|
||||
withAudioOnly := false
|
||||
if context.Query("withAudioOnly") == "true" {
|
||||
withAudioOnly = true
|
||||
}
|
||||
|
||||
playlistFile, err := twitch.GetStream(streamer, withAudioOnly)
|
||||
if err != nil {
|
||||
context.Error(err)
|
||||
return
|
||||
|
|
Loading…
Reference in a new issue