From ab9a894ca7181989b8ec57fbc2d6d849104701e1 Mon Sep 17 00:00:00 2001 From: xugo Date: Thu, 12 Oct 2023 09:46:33 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=20=E4=BF=AE=E5=A4=8D=E8=8E=B7=E5=8F=96=20?= =?UTF-8?q?hls=20=E6=B5=81=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/hls/server_sub_session.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/pkg/hls/server_sub_session.go b/pkg/hls/server_sub_session.go index 5624b48e..65f95917 100644 --- a/pkg/hls/server_sub_session.go +++ b/pkg/hls/server_sub_session.go @@ -9,12 +9,13 @@ package hls import ( - "github.com/q191201771/lal/pkg/base" - "github.com/q191201771/naza/pkg/connection" - "github.com/q191201771/naza/pkg/nazamd5" "net/http" "strings" "time" + + "github.com/q191201771/lal/pkg/base" + "github.com/q191201771/naza/pkg/connection" + "github.com/q191201771/naza/pkg/nazamd5" ) type SubSession struct { @@ -121,5 +122,14 @@ func GetAppNameFromUrlCtx(urlCtx base.UrlContext, hlsUrlPattern string) string { } func GetStreamNameFromUrlCtx(urlCtx base.UrlContext) string { - return urlCtx.GetFilenameWithoutType() + filename := urlCtx.LastItemOfPath + filetype := urlCtx.GetFileType() + if filetype == "m3u8" && (filename == playlistM3u8FileName || filename == recordM3u8FileName) { + uriItems := strings.Split(urlCtx.Path, "/") + if l := len(uriItems); l >= 2 { + return uriItems[len(uriItems)-2] + } + } + fileNameWithoutType := urlCtx.GetFilenameWithoutType() + return fileNameWithoutType }