mirror of
https://mzte.de/git/LordMZTE/dotfiles.git
synced 2024-12-19 21:53:42 +01:00
port playtwitch to ocaml
This commit is contained in:
parent
5a6e1ffc39
commit
c7689af9ff
2 changed files with 21 additions and 15 deletions
|
@ -1,18 +1,24 @@
|
||||||
#!/bin/sh
|
#!/usr/bin/env scriptisto
|
||||||
|
|
||||||
# play a twitch stream using streamlink
|
(*
|
||||||
|
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
|
||||||
|
*)
|
||||||
|
|
||||||
__usage="
|
Clap.description "play a twitch stream using streamlink";
|
||||||
USAGE:
|
let stream_name = Clap.mandatory_string ~placeholder:"stream_name" () in
|
||||||
$0 <stream_name> [quality]
|
let quality = Clap.default_string ~placeholder:"quality" "best" in
|
||||||
|
Clap.close ();
|
||||||
|
|
||||||
ARGS:
|
let stream_name = "https://twitch.tv/" ^ stream_name in
|
||||||
<stream_name> Name of the stream to play
|
|
||||||
[quality] quality to use [default: best]
|
|
||||||
"
|
|
||||||
|
|
||||||
if [ -z $1 ] || [ $# -gt 2 ] || [ $1 = "--help" ]; then
|
let exit =
|
||||||
echo -e "$__usage"
|
String.concat " " [ "streamlink"; stream_name; quality ] |> Sys.command
|
||||||
else
|
in
|
||||||
streamlink https://twitch.tv/$1 ${2:-best}
|
if exit != 0 then Stdlib.print_endline "streamlink crashed :("
|
||||||
fi
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ let run cmd =
|
||||||
(String.concat " "
|
(String.concat " "
|
||||||
[ "Command"; cmd; "exited with code"; string_of_int status ]))
|
[ "Command"; cmd; "exited with code"; string_of_int status ]))
|
||||||
| _ ->
|
| _ ->
|
||||||
Stdlib.print_endline (String.concat " " [ "Command"; cmd; "not found." ])
|
String.concat " " [ "Command"; cmd; "not found." ] |> Stdlib.print_endline
|
||||||
|
|
||||||
let () =
|
let () =
|
||||||
Clap.description "Update the system";
|
Clap.description "Update the system";
|
||||||
|
|
Loading…
Reference in a new issue