check for ads

This commit is contained in:
jb-alvarado 2022-03-01 21:08:44 +01:00
parent 9d02bb8afd
commit 80c16af683

View File

@ -23,7 +23,7 @@ pub fn read_json(config: &Config, seek: bool) -> Playlist {
let mut seek_first = seek; let mut seek_first = seek;
if playlist_path.is_dir() { if playlist_path.is_dir() {
let date = get_date(true, start_sec, 0.0); let date = get_date(seek, start_sec, 0.0);
let d: Vec<&str> = date.split('-').collect(); let d: Vec<&str> = date.split('-').collect();
playlist_path = playlist_path playlist_path = playlist_path
.join(d[0]) .join(d[0])
@ -57,11 +57,25 @@ pub fn read_json(config: &Config, seek: bool) -> Playlist {
time_sec += length_sec time_sec += length_sec
} }
let cloned_program = playlist.program.clone();
for (i, item) in playlist.program.iter_mut().enumerate() { for (i, item) in playlist.program.iter_mut().enumerate() {
item.begin = Some(start_sec); item.begin = Some(start_sec);
item.index = Some(i); item.index = Some(i);
item.last_ad = Some(false);
item.next_ad = Some(false);
let mut source_cmd: Vec<String> = vec![]; let mut source_cmd: Vec<String> = vec![];
if i > 0 && cloned_program[i - 1].category == "advertisement".to_string() {
item.last_ad = Some(true);
}
if i + 1 < cloned_program.len() {
if cloned_program[i + 1].category == "advertisement".to_string() {
item.next_ad = Some(true);
}
}
if seek_first { if seek_first {
let tmp_length = item.out - item.seek; let tmp_length = item.out - item.seek;