diff --git a/extractor/twitch/Stream.go b/extractor/twitch/Stream.go index d08a104..637e6fc 100644 --- a/extractor/twitch/Stream.go +++ b/extractor/twitch/Stream.go @@ -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") diff --git a/routes/proxy/proxy.go b/routes/proxy/proxy.go index d7e5b55..34f14df 100644 --- a/routes/proxy/proxy.go +++ b/routes/proxy/proxy.go @@ -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