1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
extern crate native_tls;
extern crate playlist_decoder;
extern crate url;
extern crate hls_m3u8;
extern crate log;
extern crate serde;
#[macro_use]
extern crate serde_derive;
extern crate serde_json;
extern crate tree_magic;
mod request;
mod streamcheck;
mod streamdeepscan;
use std::time::Duration;
use std::thread;
pub use streamcheck::{StreamInfo, StreamCheckResult, StreamCheckError};
pub fn check(
url: &str,
timeout: u32,
max_depth: u8,
retries: u8,
) -> Vec<streamcheck::StreamCheckResult> {
let mut working = false;
let mut list: Vec<streamcheck::StreamCheckResult> = Vec::new();
for _i in 0..retries {
list = streamcheck::check(url, false, timeout, max_depth);
for item in list.iter() {
match item {
&Ok(_) => {
working = true;
break;
}
&Err(_) => {}
}
}
if working {
break;
}
thread::sleep(Duration::from_secs(1));
}
list
}