added shared attribute user stream table

This commit is contained in:
euzu
2025-10-24 20:03:47 +02:00
parent bf225aaa0d
commit 2f109949d5
2 changed files with 9 additions and 20 deletions
+5 -5
View File
@@ -282,9 +282,9 @@ pub fn get_stream_alternative_url(
return stream_url.to_owned();
};
let modified = stream_url.replace(&input_user_info.base_url, &alt_input_user_info.base_url);
let modified = modified.replace(&input_user_info.username, &alt_input_user_info.username);
modified.replace(&input_user_info.password, &alt_input_user_info.password)
let modified = stream_url.replacen(&input_user_info.base_url, &alt_input_user_info.base_url, 1);
let modified = modified.replacen(&input_user_info.username, &alt_input_user_info.username, 1);
modified.replacen(&input_user_info.password, &alt_input_user_info.password, 1)
}
async fn get_redirect_alternative_url<'a>(
@@ -1141,8 +1141,8 @@ async fn fetch_resource_with_retry(
let should_retry = status.is_server_error()
|| matches!(
status,
reqwest::StatusCode::BAD_REQUEST
| reqwest::StatusCode::REQUEST_TIMEOUT
// reqwest::StatusCode::BAD_REQUEST // 400 is typically client error; retrying likely won't help and adds load.
reqwest::StatusCode::REQUEST_TIMEOUT
| reqwest::StatusCode::TOO_EARLY
| reqwest::StatusCode::TOO_MANY_REQUESTS
);
+4 -15
View File
@@ -158,16 +158,8 @@ async fn get_stream_channel(app_state: &Arc<AppState>, target: &Arc<ConfigTarget
if let Ok((pli, _)) = xtream_repository::xtream_get_item_for_stream_id(virtual_id, app_state, target, None).await {
return Some(pli.to_stream_channel());
}
// fall back to M3U if available
if target.has_output(TargetType::M3u) {
if let Ok(pli) = m3u_get_item_for_stream_id(virtual_id, app_state, target).await {
return Some(pli.to_stream_channel());
}
}
None
} else {
m3u_get_item_for_stream_id(virtual_id, app_state, target).await.ok().map(|pli| pli.to_stream_channel())
}
m3u_get_item_for_stream_id(virtual_id, app_state, target).await.ok().map(|pli| pli.to_stream_channel())
}
async fn resolve_stream_channel(
@@ -222,8 +214,7 @@ async fn hls_api_stream(
app_state.app_config.get_input_by_id(params.input_id),
true,
format!(
"Cant find input for target {target_name}, context {}, stream_id {virtual_id}",
XtreamCluster::Live
"Cant find input for target {target_name}, stream_id {virtual_id}, hls"
)
);
@@ -262,10 +253,10 @@ async fn hls_api_stream(
};
session.stream_url.clone_from(&hls_url);
let stream_channel = resolve_stream_channel(&app_state, &target, virtual_id, &hls_url).await;
if session.virtual_id == virtual_id {
if is_seek_request(XtreamCluster::Live, &req_headers).await {
if is_seek_request(stream_channel.cluster, &req_headers).await {
// partial request means we are in reverse proxy mode, seek happened
let stream_channel = resolve_stream_channel(&app_state, &target, virtual_id, &hls_url).await;
return force_provider_stream_response(
&addr,
&app_state,
@@ -308,8 +299,6 @@ async fn hls_api_stream(
.into_response();
}
let stream_channel = resolve_stream_channel(&app_state, &target, virtual_id, &hls_url).await;
force_provider_stream_response(
&addr,
&app_state,