diff options
author | Soispha <soispha@vhack.eu> | 2024-01-04 19:52:08 +0100 |
---|---|---|
committer | Soispha <soispha@vhack.eu> | 2024-01-04 19:52:08 +0100 |
commit | 6630f7884f00a48daafaa65ef5c62c1c505bc1de (patch) | |
tree | 5b5f310d240bf44a1c82b043903a06adbb310fca | |
parent | fix(hm/pkgs/scr/ytcc/filter_comments): Fail if not running (diff) | |
download | nixos-config-6630f7884f00a48daafaa65ef5c62c1c505bc1de.tar.gz nixos-config-6630f7884f00a48daafaa65ef5c62c1c505bc1de.zip |
fix(hm/pkgs/scr/ytcc/ytc): Keep sorting from input
Diffstat (limited to '')
-rwxr-xr-x | hm/soispha/pkgs/scripts/specific/ytcc/ytc | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/hm/soispha/pkgs/scripts/specific/ytcc/ytc b/hm/soispha/pkgs/scripts/specific/ytcc/ytc index c66ae96c..8306be7e 100755 --- a/hm/soispha/pkgs/scripts/specific/ytcc/ytc +++ b/hm/soispha/pkgs/scripts/specific/ytcc/ytc @@ -2,6 +2,8 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="1.10.2" . %SHELL_LIBRARY_PATH + +# CONSTANTS {{{ CONCURRENT=4 OUTPUT_PATH="/tmp/ytcc"; STATUS_FILE="$XDG_RUNTIME_DIR/ytcc/running"; @@ -34,8 +36,6 @@ escape() { echo "$1" | awk '{gsub(/;/, ","); print}' } -bases="$(ytcc --output json list --attributes url --ids "$@" | jq --raw-output 'map("\(.url);\(.id)") | join("\n")')"; - yt_flags="$(mktmp)" cat << EOF > "$yt_flags" --format bestvideo[height<=?1080]+bestaudio/best @@ -47,6 +47,18 @@ cat << EOF > "$yt_flags" --sponsorblock-mark default --sponsorblock-remove sponsor EOF +# }}} + +if [ "$1" = "id" ]; then + # This is here to keep the sorting in tack + shift 1 + bases="$(mktmp)"; + for id in "$@"; do + ytcc --output json list --attributes url --ids "$id" | jq --raw-output 'map("\(.url);\(.id)") | join("\n")' >> "$bases"; + done +else + die "The first arg must be id, but it was: '$1'" +fi [ -d "$STATUS_PATH" ] || mkdir "$STATUS_PATH"; [ -d "$OUTPUT_PATH" ] || mkdir "$OUTPUT_PATH"; @@ -93,7 +105,7 @@ while read -r base; do old_filename="$filename"; old_id="$id"; -done < "$(tmp echo "$bases")" +done < "$bases" wait "$pid" echo "$(escape "$old_filename");$old_id" >> "$files_to_play" |