check remote source video really exists
This commit is contained in:
parent
d2a89c66ab
commit
398ec1e449
@ -10,7 +10,10 @@ use std::{
|
|||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use simplelog::*;
|
use simplelog::*;
|
||||||
|
|
||||||
use crate::utils::{check_sync, gen_dummy, get_delta, get_sec, is_close, json_serializer::read_json, modified_time, seek_and_length, GlobalConfig, Media, PlayoutStatus, DUMMY_LEN, validate_source};
|
use crate::utils::{
|
||||||
|
check_sync, gen_dummy, get_delta, get_sec, is_close, json_serializer::read_json, modified_time,
|
||||||
|
seek_and_length, validate_source, GlobalConfig, Media, PlayoutStatus, DUMMY_LEN,
|
||||||
|
};
|
||||||
|
|
||||||
/// Struct for current playlist.
|
/// Struct for current playlist.
|
||||||
///
|
///
|
||||||
@ -427,7 +430,7 @@ fn timed_source(
|
|||||||
|
|
||||||
/// Generate the source CMD, or when clip not exist, get a dummy.
|
/// Generate the source CMD, or when clip not exist, get a dummy.
|
||||||
fn gen_source(config: &GlobalConfig, mut node: Media) -> Media {
|
fn gen_source(config: &GlobalConfig, mut node: Media) -> Media {
|
||||||
if validate_source(&node.source) {
|
if validate_source(&node.source) {
|
||||||
node.add_probe();
|
node.add_probe();
|
||||||
node.cmd = Some(seek_and_length(
|
node.cmd = Some(seek_and_length(
|
||||||
node.source.clone(),
|
node.source.clone(),
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
use std::{
|
use std::sync::{
|
||||||
sync::{
|
atomic::{AtomicBool, Ordering},
|
||||||
atomic::{AtomicBool, Ordering},
|
Arc,
|
||||||
Arc,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use simplelog::*;
|
use simplelog::*;
|
||||||
|
|
||||||
use crate::utils::{sec_to_time, GlobalConfig, MediaProbe, Playlist, validate_source};
|
use crate::utils::{sec_to_time, validate_source, GlobalConfig, MediaProbe, Playlist};
|
||||||
|
|
||||||
/// Validate a given playlist, to check if:
|
/// Validate a given playlist, to check if:
|
||||||
///
|
///
|
||||||
|
@ -20,7 +20,6 @@ mod generator;
|
|||||||
pub mod json_serializer;
|
pub mod json_serializer;
|
||||||
mod json_validate;
|
mod json_validate;
|
||||||
mod logging;
|
mod logging;
|
||||||
mod source;
|
|
||||||
|
|
||||||
pub use arg_parse::get_args;
|
pub use arg_parse::get_args;
|
||||||
pub use config::GlobalConfig;
|
pub use config::GlobalConfig;
|
||||||
@ -29,7 +28,6 @@ pub use generator::generate_playlist;
|
|||||||
pub use json_serializer::{read_json, Playlist, DUMMY_LEN};
|
pub use json_serializer::{read_json, Playlist, DUMMY_LEN};
|
||||||
pub use json_validate::validate_playlist;
|
pub use json_validate::validate_playlist;
|
||||||
pub use logging::{init_logging, send_mail};
|
pub use logging::{init_logging, send_mail};
|
||||||
pub use source::{validate_source};
|
|
||||||
|
|
||||||
use crate::filter::filter_chains;
|
use crate::filter::filter_chains;
|
||||||
|
|
||||||
@ -491,6 +489,23 @@ pub fn validate_ffmpeg(config: &GlobalConfig) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn validate_source(source: &String) -> bool {
|
||||||
|
let re: Regex = Regex::new(r"^https?://.*").unwrap();
|
||||||
|
|
||||||
|
if re.is_match(source) {
|
||||||
|
let probe = MediaProbe::new(source.clone());
|
||||||
|
match probe.video_streams {
|
||||||
|
Some(_video_streams) => true,
|
||||||
|
None => {
|
||||||
|
error!("Remote file not exist: {source}");
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return Path::new(&source).is_file();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Get system time, in non test case.
|
/// Get system time, in non test case.
|
||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
pub fn time_now() -> DateTime<Local> {
|
pub fn time_now() -> DateTime<Local> {
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
use std::path::Path;
|
|
||||||
|
|
||||||
use regex::Regex;
|
|
||||||
|
|
||||||
pub fn validate_source(source: &str) -> bool
|
|
||||||
{
|
|
||||||
let re = Regex::new(r"^https?://.*").unwrap();
|
|
||||||
return Path::new(&source).is_file() || re.is_match(&source);
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user