From 1c665e9d8d1d9c3c9895e04eaacbe4744a65167a Mon Sep 17 00:00:00 2001 From: Soispha Date: Sat, 6 Jan 2024 21:24:56 +0100 Subject: feat(hm/pkgs/scr/specific/ytcc/yts): Add cli interface --- hm/soispha/pkgs/scripts/specific/ytcc/yts | 40 ++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/hm/soispha/pkgs/scripts/specific/ytcc/yts b/hm/soispha/pkgs/scripts/specific/ytcc/yts index 1e8f1c8e..4d6cc6e6 100755 --- a/hm/soispha/pkgs/scripts/specific/ytcc/yts +++ b/hm/soispha/pkgs/scripts/specific/ytcc/yts @@ -19,7 +19,45 @@ help_text=" # These lines can be re-ordered; they are executed from top to bottom. # vim: ft=gitrebase" -table="$(ytcc --output json list | jq --raw-output 'map("pick \(.id) \(.title) (\(.playlists | map(.name) | join(", "))) [\(.duration | gsub("^\\s+|\\s+$";""))]") | join("\n")')" +for arg in "$@"; do + case "$arg" in + "--help") + help; + exit 0; + ;; + "--version") + version; + exit 0; + ;; + esac +done + +case "$1" in + "order") + shift 1; + case "$1" in + "date") + set -- "--order-by" "publish_date" "desc" + ;; + "raw") + shift 1; + if [ -n "$1" ]; then + [ -z "$2" ] && die "A first argument to 'order raw' requires a second" + set -- "--order-by" "$1" "$2" + fi + ;; + *) + die "'$1' is not a valid subcommand for 'order'; See '--help' for a list"; + ;; + esac + ;; + *) + die "'$1' is not a valid subcommand; See '--help' for a list"; + ;; +esac + + +table="$(ytcc --output json list "$@" | jq --raw-output 'map("pick \(.id) \(.title) (\(.playlists | map(.name) | join(", "))) [\(.duration | gsub("^\\s+|\\s+$";""))]") | join("\n")')" selection_file="$(mktmp)"; -- cgit 1.4.1