mirror of
https://github.com/TeamPiped/piped-proxy.git
synced 2024-08-14 23:50:45 +00:00
Small code improvements.
This commit is contained in:
parent
899997a1ec
commit
59eb2a1db8
1 changed files with 2 additions and 7 deletions
|
@ -322,8 +322,7 @@ async fn index(req: HttpRequest) -> Result<HttpResponse, Box<dyn Error>> {
|
||||||
}
|
}
|
||||||
if content_type == "video/vnd.mpeg.dash.mpd" || content_type == "application/dash+xml" {
|
if content_type == "video/vnd.mpeg.dash.mpd" || content_type == "application/dash+xml" {
|
||||||
let mut resp_str = resp.text().await.unwrap();
|
let mut resp_str = resp.text().await.unwrap();
|
||||||
let clone_resp = resp_str.clone();
|
let captures = RE_DASH_MANIFEST.captures_iter(&resp_str);
|
||||||
let captures = RE_DASH_MANIFEST.captures_iter(&clone_resp);
|
|
||||||
for capture in captures {
|
for capture in captures {
|
||||||
let url = capture.get(1).unwrap().as_str();
|
let url = capture.get(1).unwrap().as_str();
|
||||||
let new_url = localize_url(url, host.as_str());
|
let new_url = localize_url(url, host.as_str());
|
||||||
|
@ -352,11 +351,7 @@ fn localize_url(url: &str, host: &str) -> String {
|
||||||
|
|
||||||
return format!("{}?{}", url.path(), url.query().unwrap());
|
return format!("{}?{}", url.path(), url.query().unwrap());
|
||||||
} else if url.ends_with(".m3u8") || url.ends_with(".ts") {
|
} else if url.ends_with(".m3u8") || url.ends_with(".ts") {
|
||||||
return if url.contains('?') {
|
format!("{}{}host={}", url, if url.contains('?') { "&" } else { "?" }, host)
|
||||||
format!("{}&host={}", url, host)
|
|
||||||
} else {
|
|
||||||
format!("{}?host={}", url, host)
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
url.to_string()
|
url.to_string()
|
||||||
|
|
Loading…
Reference in a new issue