summaryrefslogtreecommitdiff
path: root/home
diff options
context:
space:
mode:
authorxyz <gky44px1999@gmail.com>2021-12-15 21:40:56 -0800
committerxyz <gky44px1999@gmail.com>2021-12-15 21:40:56 -0800
commit84e4e67a503eefd311f0585337cc4a14b2b029d0 (patch)
treefed5023f12619987702e73931bb4df7ed9d79acd /home
parentb4e672a86e91dbcd67cf94adc957cc550d19fed4 (diff)
`[ -n "$a" ]` and `[ "$a" ]` seems the same, I decided to use the latter
Diffstat (limited to 'home')
-rwxr-xr-xhome/xyz/.local/bin/curlncm6
-rwxr-xr-xhome/xyz/.local/bin/dirnameall4
2 files changed, 5 insertions, 5 deletions
diff --git a/home/xyz/.local/bin/curlncm b/home/xyz/.local/bin/curlncm
index 73a6e66f..25f39aa9 100755
--- a/home/xyz/.local/bin/curlncm
+++ b/home/xyz/.local/bin/curlncm
@@ -39,14 +39,14 @@ shift $((OPTIND-1))
download_dir="${1:-"$PWD"}"
[ -d "$download_dir" ] || mkdir -p "$download_dir"
-if [ -n "$ids" ]; then
+if [ "$ids" ]; then
# temporary solution, can improve by auto curl names
data="$(echo "$ids" | tr ',' '\n' | awk '{printf("%s\t%s\n",$0,"songname")}')"
else
- if [ -n "$rid" ]; then
+ if [ "$rid" ]; then
data="$(curl -s -G --data-urlencode id="$rid" -d limit="$dj_max" 'https://music.163.com/djradio' | grep 'songlist\|tt f-thide' | sed -e 's/.*songlist-\(.*\)" class.*/\1/g' -e 's/.*title="\(.*\)".*/\1/g' | paste -sd '\t\n' | sort | tr '/' '_')"
# can only curl featured 50 songs for the artist, can improve
- elif [ -n "$aid" ]; then
+ elif [ "$aid" ]; then
data="$(curl -s -G --data-urlencode id="$aid" 'https://music.163.com/artist' | grep '\[{.*}\]' | sed -e 's/.*>\[{/\[{/' -e 's/}\]<.*/}\]/' | jq -r '.[]|[.id,.name]|@tsv' | sort | tr '/' '_')"
fi
# awk code not print separator at beginning and end steal from:
diff --git a/home/xyz/.local/bin/dirnameall b/home/xyz/.local/bin/dirnameall
index d2d78a5b..befd3478 100755
--- a/home/xyz/.local/bin/dirnameall
+++ b/home/xyz/.local/bin/dirnameall
@@ -1,7 +1,7 @@
#!/bin/sh
while read -r line; do
- if [ -n "$paths" ]; then
+ if [ "$paths" ]; then
paths="$paths
$line"
else
@@ -11,7 +11,7 @@ done
dirs="$paths"
while [ "$dirs" != '.' ]; do
- [ -n "$dirs" ] && paths="$paths
+ [ "$dirs" ] && paths="$paths
$dirs"
dirs="$(echo "$dirs" | tr '\n' '\0' | xargs -0 dirname | awk '!a[$0]++')"
done