diff options
-rw-r--r-- | hm/soispha/pkgs/default.nix | 2 | ||||
-rw-r--r-- | hm/soispha/pkgs/scripts.nix | 12 | ||||
-rwxr-xr-x | hm/soispha/pkgs/scripts/specific/ytcc/yts | 140 |
3 files changed, 3 insertions, 151 deletions
diff --git a/hm/soispha/pkgs/default.nix b/hm/soispha/pkgs/default.nix index c7ffc64e..c43ec7a7 100644 --- a/hm/soispha/pkgs/default.nix +++ b/hm/soispha/pkgs/default.nix @@ -85,6 +85,8 @@ with pkgs; let imv # Image viewer ytcc # Command line tool to keep track of your favorite playlists on YouTube and many other places. ytc # My tool to download the videos (used in conjunction with the entry above) + yts # My tool to select the videos (used in conjunction with the entry above) + yt # My tool to both select and then download the videos (a merged version of the two entries above) ]; Listen = [ diff --git a/hm/soispha/pkgs/scripts.nix b/hm/soispha/pkgs/scripts.nix index a1eaabbd..f263ff5e 100644 --- a/hm/soispha/pkgs/scripts.nix +++ b/hm/soispha/pkgs/scripts.nix @@ -27,7 +27,7 @@ }: let src = ./scripts/${path}/${name}; dependencies = - [(pkgs.python3.withPackages (ps: dependencies_python ps))] + [(pkgs.python3.withPackages dependencies_python)] ++ dependencies_system; path_setting = if keepPath @@ -262,15 +262,6 @@ path = "wrappers"; dependencies = builtins.attrValues {inherit (pkgs) gawk expect yt-dlp;}; }; - yts-scr = write_shell { - name = "yts"; - path = "specific/ytcc"; - keepPath = true; # We need neovim - completions = true; - dependencies = builtins.attrValues { - inherit (pkgs) ytcc jq gawk ytc; - }; - }; in [ # llp-scr # TODO: see above aumo-scr @@ -293,5 +284,4 @@ in [ update-sys-scr virsh-del-scr yti-scr - yts-scr ] diff --git a/hm/soispha/pkgs/scripts/specific/ytcc/yts b/hm/soispha/pkgs/scripts/specific/ytcc/yts deleted file mode 100755 index 5a22a2c9..00000000 --- a/hm/soispha/pkgs/scripts/specific/ytcc/yts +++ /dev/null @@ -1,140 +0,0 @@ -#!/usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - -TASK_UUID=ce4f9e07-8324-4570-8be6-967955e9271e -# these are used in version() -AUTHORS="Soispha" -YEARS="2023" -NAME="neorg" - -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" - -help() { -cat << EOF -A help script to make selecting videos to play for ytcc easier. - -USAGE: - $NAME [OPTIONS] [COMMAND] - -OPTIONS: - --help | -h - Display this help and exit. - - --version | -v - Display version and copyright information and exit. -COMMANDS: - order MODE - Select the ordering mode. -ARGUMENTS: - MODE := date | raw - date will sort descending by publishing date, - whilest raw esxposes the ytcc interface. See - the help info of the 'ytcc list --help' - '--order-by' option for more details. -EOF -} - -for arg in "$@"; do - case "$arg" in - "--help") - help; - exit 0; - ;; - "--version") - version; - exit 0; - ;; - esac -done - -if [ -n "$1" ]; then - case "$1" in - "order") - shift 1; - case "$1" in - "date") - set -- "--order-by" "publish_date" "desc" - oder_mode_set=true; - ;; - "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 - oder_mode_set=true; - ;; - *) - 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 -fi - -# Set the default ordering mode -[ -z "$oder_mode_set" ] && set -- "--order-by" "publish_date" "desc" - -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)"; - -# This is trapped on EXIT -# shellcheck disable=SC2317 -cleanup() { - task stop "$TASK_UUID" -} -trap cleanup EXIT -task start "$TASK_UUID" - -echo "$table" > "$selection_file"; -echo "$help_text" >> "$selection_file"; - -$EDITOR "$selection_file" - -is_first=true; -while read -r line; do - cmd="$(echo "$line" | awk '{print $1}')"; - case "$cmd" in - "" ) - # An empty line, simply ignore it - ;; - "#") - # 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 - set -- "$id" - else - set -- "$@" "$id" - fi - dbg "Added to be watched: $id" - is_first=false - ;; - esac -done < "$selection_file" - -[ -n "$1" ] && ytc "id" "$@"; -exit 0; -# vim: ft=sh |