set correct start time
This commit is contained in:
parent
f023445d60
commit
5fc0a1856d
@ -6,14 +6,17 @@ use crate::utils::{sec_to_time, GlobalConfig, MediaProbe, Playlist};
|
|||||||
|
|
||||||
pub async fn validate_playlist(playlist: Playlist, is_terminated: Arc<Mutex<bool>>, config: GlobalConfig) {
|
pub async fn validate_playlist(playlist: Playlist, is_terminated: Arc<Mutex<bool>>, config: GlobalConfig) {
|
||||||
let date = playlist.date;
|
let date = playlist.date;
|
||||||
let length = config.playlist.length_sec.unwrap();
|
let mut length = config.playlist.length_sec.unwrap();
|
||||||
let mut start_sec = 0.0;
|
let start_sec = config.playlist.start_sec.unwrap();
|
||||||
|
let mut begin = start_sec.clone();
|
||||||
|
|
||||||
|
length += start_sec;
|
||||||
|
|
||||||
debug!("validate playlist from: <yellow>{date}</>");
|
debug!("validate playlist from: <yellow>{date}</>");
|
||||||
|
|
||||||
for item in playlist.program.iter() {
|
for item in playlist.program.iter() {
|
||||||
if *is_terminated.lock().unwrap() {
|
if *is_terminated.lock().unwrap() {
|
||||||
break
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if Path::new(&item.source).is_file() {
|
if Path::new(&item.source).is_file() {
|
||||||
@ -22,22 +25,22 @@ pub async fn validate_playlist(playlist: Playlist, is_terminated: Arc<Mutex<bool
|
|||||||
if probe.format.is_none() {
|
if probe.format.is_none() {
|
||||||
error!(
|
error!(
|
||||||
"No Metadata from file <b><magenta>{}</></b> at <yellow>{}</>",
|
"No Metadata from file <b><magenta>{}</></b> at <yellow>{}</>",
|
||||||
sec_to_time(start_sec),
|
sec_to_time(begin),
|
||||||
item.source
|
item.source
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
error!(
|
error!(
|
||||||
"File on position <yellow>{}</> not exists: <b><magenta>{}</></b>",
|
"File on position <yellow>{}</> not exists: <b><magenta>{}</></b>",
|
||||||
sec_to_time(start_sec),
|
sec_to_time(begin),
|
||||||
item.source
|
item.source
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
start_sec += item.out - item.seek;
|
begin += item.out - item.seek;
|
||||||
}
|
}
|
||||||
|
|
||||||
if length > start_sec + 1.0 && !*is_terminated.lock().unwrap() {
|
if length > begin + 1.0 {
|
||||||
error!(
|
error!(
|
||||||
"Playlist from <yellow>{date}</> not long enough, <yellow>{}</> needed!",
|
"Playlist from <yellow>{date}</> not long enough, <yellow>{}</> needed!",
|
||||||
sec_to_time(length - start_sec),
|
sec_to_time(length - start_sec),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user