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 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.
|
||||
///
|
||||
|
@ -1,13 +1,11 @@
|
||||
use std::{
|
||||
sync::{
|
||||
use std::sync::{
|
||||
atomic::{AtomicBool, Ordering},
|
||||
Arc,
|
||||
},
|
||||
};
|
||||
|
||||
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:
|
||||
///
|
||||
|
@ -20,7 +20,6 @@ mod generator;
|
||||
pub mod json_serializer;
|
||||
mod json_validate;
|
||||
mod logging;
|
||||
mod source;
|
||||
|
||||
pub use arg_parse::get_args;
|
||||
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_validate::validate_playlist;
|
||||
pub use logging::{init_logging, send_mail};
|
||||
pub use source::{validate_source};
|
||||
|
||||
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.
|
||||
#[cfg(not(test))]
|
||||
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