dotfiles/scripts/playtwitch

25 lines
692 B
Text
Raw Normal View History

2021-10-02 16:48:26 +02:00
#!/usr/bin/env scriptisto
2021-07-20 17:02:31 +02:00
2021-10-02 16:48:26 +02:00
(*
scriptisto-begin
script_src: playtwitch.ml
build_cmd: dune build playtwitch.exe
target_bin: ./_build/default/playtwitch.exe
files:
- path: dune
content: (executable (name playtwitch) (libraries clap))
scriptisto-end
*)
2021-07-20 17:02:31 +02:00
2021-10-02 16:48:26 +02:00
Clap.description "play a twitch stream using streamlink";
let stream_name = Clap.mandatory_string ~placeholder:"stream_name" () in
let quality = Clap.default_string ~placeholder:"quality" "best" in
Clap.close ();
2021-07-20 17:02:31 +02:00
2021-10-02 16:48:26 +02:00
let stream_name = "https://twitch.tv/" ^ stream_name in
2021-07-20 17:02:31 +02:00
2021-10-02 16:48:26 +02:00
let exit =
String.concat " " [ "streamlink"; stream_name; quality ] |> Sys.command
in
if exit != 0 then Stdlib.print_endline "streamlink crashed :("