mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-03 04:26:36 +08:00
bug处理
This commit is contained in:
@@ -94,8 +94,8 @@ func appendQueryToHLSSegments(playlist, rawQuery string) string {
|
|||||||
if strings.TrimSpace(rawQuery) == "" {
|
if strings.TrimSpace(rawQuery) == "" {
|
||||||
return playlist
|
return playlist
|
||||||
}
|
}
|
||||||
// Segment fetches only need auth/profile tokens; drop start= so a seek
|
// Segment fetches do not need start=, but must keep _seek as a cache-busting
|
||||||
// restart does not keep forcing EnsureJobFrom on every .ts hit.
|
// generation because every transcode restart reuses seg_00000.ts names.
|
||||||
q := filterHLSSegmentQuery(rawQuery)
|
q := filterHLSSegmentQuery(rawQuery)
|
||||||
if q == "" {
|
if q == "" {
|
||||||
return playlist
|
return playlist
|
||||||
@@ -131,7 +131,7 @@ func filterHLSSegmentQuery(rawQuery string) string {
|
|||||||
key = part[:i]
|
key = part[:i]
|
||||||
}
|
}
|
||||||
switch strings.ToLower(key) {
|
switch strings.ToLower(key) {
|
||||||
case "start", "_seek":
|
case "start":
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
kept = append(kept, part)
|
kept = append(kept, part)
|
||||||
|
|||||||
@@ -302,9 +302,12 @@ func TestRequestTokenFromMediaBrowserAuthorizationHeader(t *testing.T) {
|
|||||||
|
|
||||||
func TestAppendQueryToHLSSegments(t *testing.T) {
|
func TestAppendQueryToHLSSegments(t *testing.T) {
|
||||||
in := "#EXTM3U\n#EXTINF:4.0,\nseg_00000.ts\n#EXTINF:4.0,\nseg_00001.ts?old=1\n"
|
in := "#EXTM3U\n#EXTINF:4.0,\nseg_00000.ts\n#EXTINF:4.0,\nseg_00001.ts?old=1\n"
|
||||||
got := appendQueryToHLSSegments(in, "token=abc")
|
got := appendQueryToHLSSegments(in, "token=abc&start=120.5&_seek=1001")
|
||||||
if !strings.Contains(got, "seg_00000.ts?token=abc") {
|
if !strings.Contains(got, "seg_00000.ts?token=abc&_seek=1001") {
|
||||||
t.Fatalf("missing tokenized segment: %q", got)
|
t.Fatalf("missing token or seek generation on segment: %q", got)
|
||||||
|
}
|
||||||
|
if strings.Contains(got, "start=120.5") {
|
||||||
|
t.Fatalf("segment URL must not contain transcode start: %q", got)
|
||||||
}
|
}
|
||||||
if !strings.Contains(got, "seg_00001.ts?old=1") {
|
if !strings.Contains(got, "seg_00001.ts?old=1") {
|
||||||
t.Fatalf("existing query should be preserved: %q", got)
|
t.Fatalf("existing query should be preserved: %q", got)
|
||||||
|
|||||||
@@ -284,11 +284,14 @@ func TestShouldReplaceHLSJob(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestFilterHLSSegmentQueryDropsStart(t *testing.T) {
|
func TestFilterHLSSegmentQueryDropsStart(t *testing.T) {
|
||||||
got := filterHLSSegmentQuery("token=abc&start=120.5&profile_id=1")
|
got := filterHLSSegmentQuery("token=abc&start=120.5&_seek=1001&profile_id=1")
|
||||||
if strings.Contains(got, "start=") {
|
if strings.Contains(got, "start=") {
|
||||||
t.Fatalf("start should be stripped, got %q", got)
|
t.Fatalf("start should be stripped, got %q", got)
|
||||||
}
|
}
|
||||||
if !strings.Contains(got, "token=abc") || !strings.Contains(got, "profile_id=1") {
|
if !strings.Contains(got, "token=abc") || !strings.Contains(got, "profile_id=1") {
|
||||||
t.Fatalf("auth/profile query should remain, got %q", got)
|
t.Fatalf("auth/profile query should remain, got %q", got)
|
||||||
}
|
}
|
||||||
|
if !strings.Contains(got, "_seek=1001") {
|
||||||
|
t.Fatalf("_seek must remain to isolate cached segment generations, got %q", got)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user