mirror of
https://github.com/Xinrea/bili-shadowreplay.git
synced 2025-11-24 20:15:34 +08:00
fix: douyin segment with params
This commit is contained in:
@@ -412,6 +412,7 @@ mod tests {
|
||||
).await.unwrap();
|
||||
assert_eq!(stream.index(), "https://hs.hls.huya.com/huyalive/156976698-156976698-674209784144068608-314076852-10057-A-0-1.m3u8?ratio=2000&wsSecret=7abc7dec8809146f31f92046eb044e3b&wsTime=68fa41ba&fm=RFdxOEJjSjNoNkRKdDZUWV8kMF8kMV8kMl8kMw%3D%3D&ctype=tars_mobile&fs=bgct&t=103");
|
||||
assert_eq!(stream.ts_url("1.ts"), "https://hs.hls.huya.com/huyalive/1.ts?ratio=2000&wsSecret=7abc7dec8809146f31f92046eb044e3b&wsTime=68fa41ba&fm=RFdxOEJjSjNoNkRKdDZUWV8kMF8kMV8kMl8kMw%3D%3D&ctype=tars_mobile&fs=bgct&t=103");
|
||||
assert_eq!(stream.ts_url("1.ts?expires=1760808243"), "https://hs.hls.huya.com/huyalive/1.ts?expires=1760808243&ratio=2000&wsSecret=7abc7dec8809146f31f92046eb044e3b&wsTime=68fa41ba&fm=RFdxOEJjSjNoNkRKdDZUWV8kMF8kMV8kMl8kMw%3D%3D&ctype=tars_mobile&fs=bgct&t=103");
|
||||
assert_eq!(stream.host, "https://hs.hls.huya.com");
|
||||
assert_eq!(
|
||||
stream.base,
|
||||
|
||||
@@ -80,9 +80,18 @@ impl HlsStream {
|
||||
if self.extra.is_empty() {
|
||||
format!("{}{}", self.host, base_url)
|
||||
} else {
|
||||
// Remove the trailing '?' from base_url and add it properly
|
||||
let base_without_query = base_url.trim_end_matches('?');
|
||||
format!("{}{}?{}", self.host, base_without_query, self.extra)
|
||||
// Check if base_url already contains query parameters
|
||||
if base_url.contains('?') {
|
||||
// If seg_name already has query params, append extra with '&'
|
||||
// Remove trailing '?' or '&' before appending
|
||||
let base_trimmed = base_url.trim_end_matches('?').trim_end_matches('&');
|
||||
format!("{}{}&{}", self.host, base_trimmed, self.extra)
|
||||
} else {
|
||||
// If no query params, add them with '?'
|
||||
// Remove trailing '?' from base_url if present
|
||||
let base_without_query = base_url.trim_end_matches('?');
|
||||
format!("{}{}?{}", self.host, base_without_query, self.extra)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user