From 4275ae04684806492486709cce86fdcfe4b871d0 Mon Sep 17 00:00:00 2001 From: euzu Date: Wed, 9 Jul 2025 17:32:49 +0200 Subject: [PATCH] Added default user agent for requests if none given --- backend/src/api/model/streams/provider_stream_factory.rs | 4 ++-- backend/src/model/config/video_download.rs | 3 +-- backend/src/utils/network/request.rs | 5 +++++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/backend/src/api/model/streams/provider_stream_factory.rs b/backend/src/api/model/streams/provider_stream_factory.rs index 77498a45d..ed0707672 100644 --- a/backend/src/api/model/streams/provider_stream_factory.rs +++ b/backend/src/api/model/streams/provider_stream_factory.rs @@ -7,9 +7,9 @@ use crate::api::model::streams::client_stream::ClientStream; use crate::api::model::streams::provider_stream::{create_channel_unavailable_stream, get_header_filter_for_item_type}; use crate::api::model::streams::timed_client_stream::TimedClientStream; use shared::model::PlaylistItemType; -use crate::model::{Config, DEFAULT_USER_AGENT}; +use crate::model::{Config}; use crate::tools::atomic_once_flag::AtomicOnceFlag; -use crate::utils::request::{classify_content_type, get_request_headers, sanitize_sensitive_info, MimeCategory}; +use crate::utils::request::{classify_content_type, get_request_headers, sanitize_sensitive_info, MimeCategory, DEFAULT_USER_AGENT}; use crate::utils::{debug_if_enabled}; use shared::utils::{filter_request_header}; use futures::stream::{self}; diff --git a/backend/src/model/config/video_download.rs b/backend/src/model/config/video_download.rs index eb072a509..1a2e193ba 100644 --- a/backend/src/model/config/video_download.rs +++ b/backend/src/model/config/video_download.rs @@ -2,8 +2,7 @@ use shared::error::{create_tuliprox_error_result, TuliproxError, TuliproxErrorKi use regex::Regex; use std::borrow::BorrowMut; use std::collections::HashMap; - -pub const DEFAULT_USER_AGENT: &str = "VLC/3.0.16 LibVLC/3.0.16"; +use crate::utils::request::DEFAULT_USER_AGENT; #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Default)] #[serde(deny_unknown_fields)] diff --git a/backend/src/utils/network/request.rs b/backend/src/utils/network/request.rs index 4317d8786..f674902d6 100644 --- a/backend/src/utils/network/request.rs +++ b/backend/src/utils/network/request.rs @@ -27,6 +27,8 @@ use shared::utils::{filter_request_header}; use crate::utils::{get_file_path, persist_file}; use shared::utils::{CONSTANTS, DASH_EXT, DASH_EXT_FRAGMENT, DASH_EXT_QUERY, ENCODING_DEFLATE, ENCODING_GZIP, HLS_EXT, HLS_EXT_FRAGMENT, HLS_EXT_QUERY}; +pub const DEFAULT_USER_AGENT: &str = "VLC/3.0.16 LibVLC/3.0.16"; + pub async fn get_input_epg_content_as_file(client: Arc, input: &ConfigInput, working_dir: &str, url_str: &str, persist_filepath: Option) -> Result { debug_if_enabled!("getting input epg content working_dir: {}, url: {}", working_dir, sanitize_sensitive_info(url_str)); if url_str.parse::().is_ok() { @@ -170,6 +172,9 @@ pub fn get_request_headers(request_header trace!("Request headers {he:?}"); } } + if !headers.contains_key(axum::http::header::USER_AGENT) { + headers.insert(axum::http::header::USER_AGENT, HeaderValue::from_static(DEFAULT_USER_AGENT)); + } headers }