get correct preview path, create mission hsl folders
This commit is contained in:
parent
51d3c9f10e
commit
f64c22131e
@ -1288,20 +1288,28 @@ async fn get_file(
|
|||||||
/// Can be used for HLS Playlist and other static files in public folder
|
/// Can be used for HLS Playlist and other static files in public folder
|
||||||
///
|
///
|
||||||
/// ```BASH
|
/// ```BASH
|
||||||
/// curl -X GET http://127.0.0.1:8787/live/stream.m3u8
|
/// curl -X GET http://127.0.0.1:8787/live/1/stream.m3u8
|
||||||
/// ```
|
/// ```
|
||||||
#[get("/{public:((live|preview|public).*|.*(ts|m3u8))}")]
|
#[get("/{public:live|preview|public}/{id}/{file_stem:.*}")]
|
||||||
async fn get_public(public: web::Path<String>) -> Result<actix_files::NamedFile, ServiceError> {
|
async fn get_public(
|
||||||
|
path: web::Path<(String, i32, String)>,
|
||||||
|
controllers: web::Data<Mutex<ChannelController>>,
|
||||||
|
) -> Result<actix_files::NamedFile, ServiceError> {
|
||||||
|
let (public, id, file_stem) = path.into_inner();
|
||||||
let public_path = public_path();
|
let public_path = public_path();
|
||||||
|
|
||||||
let absolute_path = if public_path.is_absolute() {
|
let absolute_path = if file_stem.ends_with(".ts") || file_stem.ends_with(".m3u8") {
|
||||||
|
let manager = controllers.lock().unwrap().get(id).unwrap();
|
||||||
|
let config = manager.config.lock().unwrap();
|
||||||
|
config.global.hls_path.join(public)
|
||||||
|
} else if public_path.is_absolute() {
|
||||||
public_path.to_path_buf()
|
public_path.to_path_buf()
|
||||||
} else {
|
} else {
|
||||||
env::current_dir()?.join(public_path)
|
env::current_dir()?.join(public_path)
|
||||||
}
|
}
|
||||||
.clean();
|
.clean();
|
||||||
|
|
||||||
let path = absolute_path.join(public.as_str());
|
let path = absolute_path.join(file_stem.as_str());
|
||||||
let file = actix_files::NamedFile::open(path)?;
|
let file = actix_files::NamedFile::open(path)?;
|
||||||
|
|
||||||
Ok(file
|
Ok(file
|
||||||
|
@ -684,12 +684,12 @@ impl PlayoutConfig {
|
|||||||
|
|
||||||
for item in cmd.iter_mut() {
|
for item in cmd.iter_mut() {
|
||||||
if item.ends_with(".ts") || (item.ends_with(".m3u8") && item != "master.m3u8") {
|
if item.ends_with(".ts") || (item.ends_with(".m3u8") && item != "master.m3u8") {
|
||||||
let filename = Path::new(item)
|
if let Ok((hls_path, _, _)) = norm_abs_path(&global.hls_path, &item) {
|
||||||
.file_name()
|
let parent = hls_path.parent().expect("HLS parent path");
|
||||||
.unwrap()
|
|
||||||
.to_string_lossy()
|
if !parent.is_dir() {
|
||||||
.to_string();
|
fs::create_dir_all(parent).await.expect("Create HLS path");
|
||||||
if let Ok((hls_path, _, _)) = norm_abs_path(&global.hls_path, &filename) {
|
}
|
||||||
item.clone_from(&hls_path.to_string_lossy().to_string());
|
item.clone_from(&hls_path.to_string_lossy().to_string());
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
2
frontend
2
frontend
@ -1 +1 @@
|
|||||||
Subproject commit 7d0bfa9d368e82e2ddcbb90f0163c0691a615621
|
Subproject commit e8fd6f65bf255c55c1ca509f9fe59c2c7875c394
|
@ -186,7 +186,7 @@ INSERT INTO
|
|||||||
VALUES
|
VALUES
|
||||||
(
|
(
|
||||||
'Channel 1',
|
'Channel 1',
|
||||||
'http://127.0.0.1:8787/stream.m3u8',
|
'http://127.0.0.1:8787/live/1/stream.m3u8',
|
||||||
'jpg,jpeg,png',
|
'jpg,jpeg,png',
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user