diff options
author | Soispha <soispha@vhack.eu> | 2024-01-01 18:23:30 +0100 |
---|---|---|
committer | Soispha <soispha@vhack.eu> | 2024-01-01 18:29:08 +0100 |
commit | b15530850f7220985d605eb366e9c01927fa4048 (patch) | |
tree | af3fccd5cbd7cadae26fe223213eda1cdcc24dea /hm | |
parent | fix(hm/pkgs/ytc): Wait for last mpv instance to exit before starting burndown (diff) | |
download | nixos-config-b15530850f7220985d605eb366e9c01927fa4048.tar.gz nixos-config-b15530850f7220985d605eb366e9c01927fa4048.zip |
feat(hm/pkgs/yts): Init
Diffstat (limited to '')
-rw-r--r-- | hm/soispha/pkgs/scripts.nix | 10 | ||||
-rwxr-xr-x | hm/soispha/pkgs/scripts/wrappers/yts | 61 |
2 files changed, 71 insertions, 0 deletions
diff --git a/hm/soispha/pkgs/scripts.nix b/hm/soispha/pkgs/scripts.nix index 0b32a9c1..e9c70966 100644 --- a/hm/soispha/pkgs/scripts.nix +++ b/hm/soispha/pkgs/scripts.nix @@ -214,6 +214,15 @@ path = "wrappers"; dependencies = builtins.attrValues {inherit (pkgs) gawk expect yt-dlp;}; }; + yts-scr = write_script { + name = "yts"; + path = "wrappers"; + keep_path = true; # We need neovim + dependencies = builtins.attrValues { + inherit (pkgs) ytcc jq gawk; + inherit ytc-scr; + }; + }; in [ # llp-scr # TODO: see above aumo-scr @@ -232,4 +241,5 @@ in [ virsh-del-scr ytc-scr yti-scr + yts-scr ] diff --git a/hm/soispha/pkgs/scripts/wrappers/yts b/hm/soispha/pkgs/scripts/wrappers/yts new file mode 100755 index 00000000..5abecb9b --- /dev/null +++ b/hm/soispha/pkgs/scripts/wrappers/yts @@ -0,0 +1,61 @@ +#!/usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="1.10.0" . %SHELL_LIBRARY_PATH + +TASK_UUID=ce4f9e07-8324-4570-8be6-967955e9271e + +help_text=" +# +# Commands: +# w, watch <id> = watch id +# d, drop <id> = mark id as watched +# p, pick <id> = leave id as is; This is a noop +# +# 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")')" + +selection_file="$(mktmp)"; + +task start "$TASK_UUID" + +echo "$table" > "$selection_file"; +echo "$help_text" >> "$selection_file"; + +$EDITOR "$selection_file" + +ids="" +is_first=true; +while read -r line; do + cmd="$(echo "$line" | awk '{print $1}')"; + case "$cmd" in + "#" ) + # This is a comment, do nothing here + ;; + "pick" | "p") + # noop do nothing here + ;; + "drop" | "d") + id="$(echo "$line" | awk '{print $2}')"; + ytcc mark "$id"; + dbg "Marked as watched: $id" + ;; + "watch" | "w") + id="$(echo "$line" | awk '{print $2}')"; + if [ "$is_first" = "true" ]; then + ids="$id"; + else + ids="$ids,$id"; + fi + dbg "Added to be watched: $id" + is_first=false + ;; + esac +done < "$selection_file" + +[ "$ids" != "" ] && ytc "$ids"; + +task stop "$TASK_UUID" +# vim: ft=sh |