aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSoispha <soispha@vhack.eu>2024-01-01 22:42:02 +0100
committerSoispha <soispha@vhack.eu>2024-01-01 22:42:51 +0100
commit6f337ee548e08064325741271b36ca5197d88d87 (patch)
tree2f1e89cabedf288b0c7e971793fa91b9a91aa143
parentfix(hm/pkgs/scr/ytc): Don't use while in a if situation (diff)
downloadnixos-config-6f337ee548e08064325741271b36ca5197d88d87.zip
fix(hm/pkgs/scr/ytc): Allow titles with commas in them
Diffstat (limited to '')
-rw-r--r--hm/soispha/pkgs/scripts.nix1
-rwxr-xr-xhm/soispha/pkgs/scripts/wrappers/ytc12
2 files changed, 9 insertions, 4 deletions
diff --git a/hm/soispha/pkgs/scripts.nix b/hm/soispha/pkgs/scripts.nix
index e9c70966..a4cab3d4 100644
--- a/hm/soispha/pkgs/scripts.nix
+++ b/hm/soispha/pkgs/scripts.nix
@@ -206,6 +206,7 @@
mpv
ffmpeg
gnused
+ gawk
;
};
};
diff --git a/hm/soispha/pkgs/scripts/wrappers/ytc b/hm/soispha/pkgs/scripts/wrappers/ytc
index ce7f9ba9..7e806449 100755
--- a/hm/soispha/pkgs/scripts/wrappers/ytc
+++ b/hm/soispha/pkgs/scripts/wrappers/ytc
@@ -6,7 +6,7 @@ CONCURRENT=4
OUTPUT_PATH="/tmp/ytcc";
col() {
- echo "$1" | csvtool col "$2" -
+ echo "$1" | csvtool -t ';' col "$2" -
}
play() {
@@ -23,7 +23,11 @@ play() {
return "$output"
}
-bases="$(ytcc --output json list --attributes url --ids "$@" | jq --raw-output 'map("\(.url),\(.id)") | join("\n")')";
+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"
@@ -47,7 +51,7 @@ while read -r base; do
id="$(col "$base" 2)"
if [ "$old_filename" ]; then
- echo "$old_filename,$old_id" >> "$files_to_play"
+ echo "$(escape "$old_filename");$old_id" >> "$files_to_play"
# Check if the process (pid) exists
dbg "PID is '$pid'"
@@ -84,7 +88,7 @@ while read -r base; do
done < "$(tmp echo "$bases")"
wait "$pid"
-echo "$old_filename,$old_id" >> "$files_to_play"
+echo "$(escape "$old_filename");$old_id" >> "$files_to_play"
while read -r base; do
name="$(col "$base" 1)";