mirror of
https://github.com/euzu/tuliprox.git
synced 2026-10-24 16:52:28 +02:00
when rewriting m3u paylist, if index files are missing, the original file will be served.
This commit is contained in:
+1
-1
@@ -13,7 +13,7 @@ panic = 'abort' # Abort on panic
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1.0", features = ["derive", "rc"] }
|
||||
serde_yaml = "0"
|
||||
serde_yaml = "0.9.1"
|
||||
serde_json = "1"
|
||||
serde-xml-rs = "0"
|
||||
quick-xml = { version = "0", features = ["serialize"] }
|
||||
|
||||
@@ -5,7 +5,7 @@ const dev = {
|
||||
version: process.env.REACT_APP_VERSION,
|
||||
},
|
||||
api: {
|
||||
serverUrl: 'http://10.41.41.41:8901/api/v1/',
|
||||
serverUrl: 'http://localhost:8901/api/v1/',
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+42
-1
@@ -133,7 +133,7 @@ impl SharedLocks {
|
||||
}
|
||||
}
|
||||
let mut lock = self.shared_locks.write().unwrap();
|
||||
let file = Arc::new(RwLock::new(key.to_string() ));
|
||||
let file = Arc::new(RwLock::new(key.to_string()));
|
||||
lock.insert(key.to_string(), file.clone());
|
||||
file
|
||||
}
|
||||
@@ -192,6 +192,47 @@ pub(crate) struct XtreamAuthorizationResponse {
|
||||
pub server_info: XtreamServerInfo,
|
||||
}
|
||||
|
||||
// macro_rules! create_user_api {
|
||||
// ($name:ident { $($field:ident : $field_type:ty),* $(,)? }) => {
|
||||
// #[derive(Debug, serde::Serialize, serde::Deserialize)]
|
||||
// pub(crate) struct $name {
|
||||
// $(
|
||||
// #[serde(default = "default_as_empty_str")]
|
||||
// pub $field : $field_type
|
||||
// ),*
|
||||
// }
|
||||
//
|
||||
// impl $name {
|
||||
// pub fn from_map(map: &HashMap<String, String>) -> Self {
|
||||
// let mut fields = HashMap::new();
|
||||
// $(
|
||||
// if let Some(value) = map.get(stringify!($field)) {
|
||||
// fields.insert(stringify!($field).to_string(), value.clone());
|
||||
// }
|
||||
// )*
|
||||
// Self {
|
||||
// $(
|
||||
// $field: fields.remove(stringify!($field)).unwrap_or_default(),
|
||||
// )*
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
// }
|
||||
//
|
||||
// create_user_api!(
|
||||
// UserApiRequest {
|
||||
// username: String,
|
||||
// password: String,
|
||||
// token: String,
|
||||
// action: String,
|
||||
// series_id: String,
|
||||
// vod_id: String,
|
||||
// stream_id: String,
|
||||
// category_id: String,
|
||||
// limit: String,
|
||||
// });
|
||||
|
||||
|
||||
#[derive(Debug, serde::Serialize, serde::Deserialize)]
|
||||
pub(crate) struct UserApiRequest {
|
||||
|
||||
@@ -9,9 +9,11 @@ use crate::repository::m3u_repository::{get_m3u_file_paths, get_m3u_url_for_stre
|
||||
|
||||
async fn m3u_api(
|
||||
api_req: web::Query<UserApiRequest>,
|
||||
//_api_req: web::Query<HashMap<String, String>>,
|
||||
req: HttpRequest,
|
||||
app_state: web::Data<AppState>,
|
||||
) -> HttpResponse {
|
||||
//let api_req = UserApiRequest::from_map(&_api_req);
|
||||
match get_user_target(&api_req, &app_state) {
|
||||
Some((user, target)) => {
|
||||
let filename = target.get_m3u_filename();
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ fn _save_config_main(file_path: &str, backup_dir: &str, cfg: &ConfigDto) -> Opti
|
||||
}
|
||||
|
||||
pub(crate) async fn save_config_api_proxy_user(
|
||||
mut req: web::Json<Vec<TargetUser>>,
|
||||
req: web::Json<Vec<TargetUser>>,
|
||||
app_state: web::Data<AppState>,
|
||||
) -> HttpResponse {
|
||||
let mut users = req.0;
|
||||
|
||||
@@ -240,7 +240,6 @@ pub(crate) fn write_strm_playlist(target: &ConfigTarget, cfg: &Config, new_playl
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
pub(crate) fn rewrite_m3u_playlist(cfg: &Config, target: &ConfigTarget, user: &UserCredentials) -> Option<String> {
|
||||
let filename = target.get_m3u_filename();
|
||||
if filename.is_some() {
|
||||
@@ -265,7 +264,15 @@ pub(crate) fn rewrite_m3u_playlist(cfg: &Config, target: &ConfigTarget, user: &U
|
||||
}
|
||||
}
|
||||
return Some(result.join("\n"));
|
||||
};
|
||||
} else if m3u_path.exists() {
|
||||
match std::fs::read_to_string(&m3u_path) {
|
||||
Ok(result) => return Some(result),
|
||||
Err(err) => {
|
||||
error!("Could not open file {}: {}", &m3u_path.to_str().unwrap(), err);
|
||||
return None;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
None
|
||||
|
||||
Reference in New Issue
Block a user