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) {
|
||||
let date = playlist.date;
|
||||
let length = config.playlist.length_sec.unwrap();
|
||||
let mut start_sec = 0.0;
|
||||
let mut length = config.playlist.length_sec.unwrap();
|
||||
let start_sec = config.playlist.start_sec.unwrap();
|
||||
let mut begin = start_sec.clone();
|
||||
|
||||
length += start_sec;
|
||||
|
||||
debug!("validate playlist from: <yellow>{date}</>");
|
||||
|
||||
for item in playlist.program.iter() {
|
||||
if *is_terminated.lock().unwrap() {
|
||||
break
|
||||
return
|
||||
}
|
||||
|
||||
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() {
|
||||
error!(
|
||||
"No Metadata from file <b><magenta>{}</></b> at <yellow>{}</>",
|
||||
sec_to_time(start_sec),
|
||||
sec_to_time(begin),
|
||||
item.source
|
||||
);
|
||||
}
|
||||
} else {
|
||||
error!(
|
||||
"File on position <yellow>{}</> not exists: <b><magenta>{}</></b>",
|
||||
sec_to_time(start_sec),
|
||||
sec_to_time(begin),
|
||||
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!(
|
||||
"Playlist from <yellow>{date}</> not long enough, <yellow>{}</> needed!",
|
||||
sec_to_time(length - start_sec),
|
||||
|
Loading…
x
Reference in New Issue
Block a user