~krathalan/wtwitch-rust

eabe56a45a476d4bfb9629167d7b58d5c893d01e — Hunter Peavey 3 years ago da2ffeb master
Minor updates
1 files changed, 33 insertions(+), 25 deletions(-)

M src/main.rs
M src/main.rs => src/main.rs +33 -25
@@ 176,26 176,26 @@ fn block(args: Vec<String>, blocklist_file: String, blocklist: String) {
fn help() {
    println!("{} - terminal user interface for Twitch

    => [w]atch [name]      - Watch [name] streamer.
    => [s]ub [name(s)]     - Subscribe to [name] streamer.
                             You can subscribe to multiple streamers in one command.
    => [u]nsub [name(s)]   - Unsubscribe from [name] streamer.
                             You can unsubscribe from multiple streamers in one command.
    => [c]heck             - View your settings and the status of streamers you are
                             subscribed to.
    => [e] [search-term]   - Search games/categories for [search-term].
    => [n] [search-term]   - Search streamers/channels for [search-term].
    => [g]ame [name]       - View the top streamers for [name] game/category.
    => [t]op               - View the top games and streamers on Twitch.
    => [l]                 - Toggle the usage of colors in wtwitch output.
    => [p]layer [program]  - Change the player program that gets passed to streamlink.
    => [q]uality [quality] - Change the video quality that gets passed to streamlink.
    => [b]lock [name(s)]   - Block [name] streamer, preventing them from appearing in any
                             output. You can block multiple streamers in one command.
    => [v]ersion           - Print the current version of wtwitch.
    => [h]elp              - Print this help.
=> [w]atch [name]      - Watch [name] streamer.
=> [s]ub [name(s)]     - Subscribe to [name] streamer.
                            You can subscribe to multiple streamers in one command.
=> [u]nsub [name(s)]   - Unsubscribe from [name] streamer.
                            You can unsubscribe from multiple streamers in one command.
=> [c]heck             - View your settings and the status of streamers you are
                            subscribed to.
=> [e] [search-term]   - Search games/categories for [search-term].
=> [n] [search-term]   - Search streamers/channels for [search-term].
=> [g]ame [name]       - View the top streamers for [name] game/category.
=> [t]op               - View the top games and streamers on Twitch.
=> [l]                 - Toggle the usage of colors in wtwitch output.
=> [p]layer [program]  - Change the player program that gets passed to streamlink.
=> [q]uality [quality] - Change the video quality that gets passed to streamlink.
=> [b]lock [name(s)]   - Block [name] streamer, preventing them from appearing in any
                            output. You can block multiple streamers in one command.
=> [v]ersion           - Print the current version of wtwitch.
=> [h]elp              - Print this help.
    
    See \"man {}\" or https://krathalan.net/wtwitch.html for more information.", PROGRAM_NAME, PROGRAM_NAME);
See \"man {}\" or https://krathalan.net/wtwitch.html for more information.", PROGRAM_NAME, PROGRAM_NAME);
}

fn version() {


@@ 218,12 218,20 @@ fn watch(streamer: String, player: String, quality: String) {
    if cfg!(target_os = "windows") {
        panic!("{} does not yet support launching a stream on Windows", PROGRAM_NAME);
    } else {
        let streamlink_command = format!("streamlink -p {} --twitch-disable-ads \"https://www.twitch.tv/{}\" {}", player, streamer, quality);
        process::Command::new("sh")
                .arg("-c")
                .arg(streamlink_command)
                .stdout(process::Stdio::null())
        let streamer_url = format!("https://www.twitch.tv/{}", streamer);
        println!("{}, {}", player, quality);
        let child = process::Command::new("streamlink")
                .arg("-p")
                .arg(player)
                .arg("--twitch-disable-ads")
                .arg(streamer_url)
                .arg(quality.trim_start_matches("\"").trim_end_matches("\""))
                .stdout(process::Stdio::piped())
                .spawn()
                .expect("Failed to open streamlink")
                .expect("Failed to open streamlink");

        let output = child.wait_with_output().expect("failed to wait on child");

        println!("{:?}", output);
    };
}
\ No newline at end of file