From 91b9523a6bdd22de1d5612a560a41cf966b2839f Mon Sep 17 00:00:00 2001 From: Fuwn Date: Thu, 18 Jan 2024 06:29:02 +0000 Subject: feat(watch): local streaming --- src/bashly.yml | 11 ++++++++++- src/watch_command.sh | 10 +++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/bashly.yml b/src/bashly.yml index db88e52..1b0e954 100644 --- a/src/bashly.yml +++ b/src/bashly.yml @@ -30,7 +30,16 @@ commands: required: true help: Episode to watch help: Watch an anime by episode - dependencies: [xdg-open] + dependencies: [xdg-open, base64] + flags: + - long: --browser + short: -b + help: Open the stream in your browser instead of a local video player + - long: --player + short: -p + arg: player + help: Override mpv as the local video player + default: mpv - name: episodes alias: e args: diff --git a/src/watch_command.sh b/src/watch_command.sh index 6c94bf0..0d42267 100644 --- a/src/watch_command.sh +++ b/src/watch_command.sh @@ -1,4 +1,12 @@ -xdg-open "$(get "/stream/$(get "/episodes/${args[id]}" | +PLAYER="$(get "/stream/$(get "/episodes/${args[id]}" | jq -r ".[] | .id" | head -n 1 | sed -E 's/-episode-[0-9]+$//')-episode-1" | jq -r ".plyr.default")" + +if [[ -n "${args[--browser]}" ]]; then + xdg-open "${PLAYER}" +else + "${args[--player]}" "$(echo "${PLAYER}" | + sed -E 's/.*#//' | + base64 --decode)" +fi -- cgit v1.2.3