about summary refs log tree commit diff stats
path: root/hm
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xhm/soispha/pkgs/scripts/specific/ytcc/ytc18
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"