@@ 53,8 53,12 @@ fn main() {
// Parse user command
let command = &cli_args[1].chars().next().unwrap();
+
+ // TODO: check for missing arguments
+
match command {
'b' => block(cli_args, blocklist_file, blocklist),
+ 'w' => watch(cli_args),
_ => help()
}
}
@@ 103,6 107,7 @@ fn load_blocklist(path_to_blocklist: &str) -> String {
// Commands
+// TODO: Remove streamer if it's already on the blocklist
fn block(args: Vec<String>, blocklist_file: String, blocklist: String) {
// args
// 0: path to binary
@@ 137,4 142,23 @@ fn block(args: Vec<String>, blocklist_file: String, blocklist: String) {
fn help() {
unimplemented!("TODO: Implement print help")
+}
+
+// TODO: use user player and quality settings, fork to background
+fn watch(args: Vec<String>) {
+ use std::process;
+
+ if cfg!(target_os = "windows") {
+ process::Command::new("cmd")
+ .args(&["/C", "echo hello"])
+ .spawn()
+ .expect("failed to execute process")
+ } else {
+ let streamlink_command = format!("streamlink -p mpv --twitch-disable-ads \"https://www.twitch.tv/{}\" best", args[2]);
+ process::Command::new("sh")
+ .arg("-c")
+ .arg(streamlink_command)
+ .spawn()
+ .expect("failed to execute process")
+ };
}=
\ No newline at end of file