using -n and -z for best practices
This commit is contained in:
parent
2ecadef2a9
commit
9c4f7e67b4
10
albumsetup
10
albumsetup
|
@ -106,12 +106,12 @@ trap 'clean' INT HUP QUIT EXIT
|
||||||
[ "$EXT" = "opus" ] && acopy="-c:a copy" # copy audio codec if opus since output codec is opus
|
[ "$EXT" = "opus" ] && acopy="-c:a copy" # copy audio codec if opus since output codec is opus
|
||||||
|
|
||||||
# INDIVIDUAL SONG #
|
# INDIVIDUAL SONG #
|
||||||
if [ "$SONG" ]; then
|
if [ -n "$SONG" ]; then
|
||||||
grabinfo "$SONG"
|
grabinfo "$SONG"
|
||||||
ffconv "$DEFAULT_PICTURE" "$SONG" "$OUTDIR/SONG ${ARTIST%%/*} - ${TITLE%%/*}.webm" # substitution mods are to not create directories
|
ffconv "$DEFAULT_PICTURE" "$SONG" "$OUTDIR/SONG ${ARTIST%%/*} - ${TITLE%%/*}.webm" # substitution mods are to not create directories
|
||||||
|
|
||||||
# CONTINUOUS VIDEO OF WHOLE ALBUM #
|
# CONTINUOUS VIDEO OF WHOLE ALBUM #
|
||||||
elif [ "$FULLALBUM" ]; then
|
elif [ -n "$FULLALBUM" ]; then
|
||||||
TOTALTIME=0 # keeping track of timestamps
|
TOTALTIME=0 # keeping track of timestamps
|
||||||
IFS="$NL"
|
IFS="$NL"
|
||||||
for f in $(fd -d 1 -e "$EXT"); do
|
for f in $(fd -d 1 -e "$EXT"); do
|
||||||
|
@ -145,7 +145,7 @@ else
|
||||||
[ ! -f "$PICTURE" ] && PICTURE="$(fd -e jpg -e png "^track$TRACKNUMBER")"
|
[ ! -f "$PICTURE" ] && PICTURE="$(fd -e jpg -e png "^track$TRACKNUMBER")"
|
||||||
[ ! -f "$PICTURE" ] && PICTURE="$DEFAULT_PICTURE"
|
[ ! -f "$PICTURE" ] && PICTURE="$DEFAULT_PICTURE"
|
||||||
errecho "Converting $f"
|
errecho "Converting $f"
|
||||||
[ ! "$NO_CONVERT" ] && ffconv "$PICTURE" "$f" "$OUTDIR/$TRACKNUMBER ${ARTIST%%/*} - ${TITLE%%/*}.webm"
|
[ -z "$NO_CONVERT" ] && ffconv "$PICTURE" "$f" "$OUTDIR/$TRACKNUMBER ${ARTIST%%/*} - ${TITLE%%/*}.webm"
|
||||||
[ -f "$tmpimg" ] && rm -f "$tmpimg"
|
[ -f "$tmpimg" ] && rm -f "$tmpimg"
|
||||||
done > "$OUTDIR/metadata.txt"
|
done > "$OUTDIR/metadata.txt"
|
||||||
[ ! -f "$OUTDIR/metadata.txt" ] && die "No files found!"
|
[ ! -f "$OUTDIR/metadata.txt" ] && die "No files found!"
|
||||||
|
@ -157,7 +157,7 @@ else
|
||||||
rm "$OUTDIR/metadata.txt.sorted"
|
rm "$OUTDIR/metadata.txt.sorted"
|
||||||
|
|
||||||
# Bandcamp check and info retrieval
|
# Bandcamp check and info retrieval
|
||||||
if [ "$BANDCAMP" ]; then
|
if [ -n "$BANDCAMP" ]; then
|
||||||
JSON="$(mktemp -t "ALBUMSETUP_JSON.XXXX")"
|
JSON="$(mktemp -t "ALBUMSETUP_JSON.XXXX")"
|
||||||
curl -L -s -o - "$BANDCAMP" | pup 'script[type="application/ld+json"]' 'text{}' > "$JSON"
|
curl -L -s -o - "$BANDCAMP" | pup 'script[type="application/ld+json"]' 'text{}' > "$JSON"
|
||||||
albumartist="$(jq -r '.byArtist.name' < "$JSON")"
|
albumartist="$(jq -r '.byArtist.name' < "$JSON")"
|
||||||
|
@ -169,7 +169,7 @@ else
|
||||||
printf '%s - %s\n\n' "$albumartist" "$ALBUM"
|
printf '%s - %s\n\n' "$albumartist" "$ALBUM"
|
||||||
cat "$OUTDIR/metadata.txt"
|
cat "$OUTDIR/metadata.txt"
|
||||||
printf '\nReleased %s\nDOWNLOAD: %s\n\n' "$date" "$BANDCAMP"
|
printf '\nReleased %s\nDOWNLOAD: %s\n\n' "$date" "$BANDCAMP"
|
||||||
[ "$desc" ] || [ "$creds" ] && printf '%s\n' 'Release notes:'
|
[ -n "$desc" ] || [ -n "$creds" ] && printf '%s\n' 'Release notes:'
|
||||||
printf '%s\n\n%s' "$desc" "$creds" | sed -e 's/</‹/g'
|
printf '%s\n\n%s' "$desc" "$creds" | sed -e 's/</‹/g'
|
||||||
} > "$OUTDIR/metadata2.txt"
|
} > "$OUTDIR/metadata2.txt"
|
||||||
mv "$OUTDIR/metadata2.txt" "$OUTDIR/metadata.txt"
|
mv "$OUTDIR/metadata2.txt" "$OUTDIR/metadata.txt"
|
||||||
|
|
|
@ -96,11 +96,11 @@ done
|
||||||
echo "$tmplog" > "$logdir/log"
|
echo "$tmplog" > "$logdir/log"
|
||||||
|
|
||||||
# formatting the description
|
# formatting the description
|
||||||
if [ "${uncontained_albums}" ] || [ "${uncontained_tracks}" ]; then
|
if [ -n "${uncontained_albums}" ] || [ -n "${uncontained_tracks}" ]; then
|
||||||
uncontained_albums="$NL<br><div><b>Uncontained Releases</b></div>$NL$uncontained_albums"
|
uncontained_albums="$NL<br><div><b>Uncontained Releases</b></div>$NL$uncontained_albums"
|
||||||
[ "$uncontained_tracks" ] && uncontained_tracks="$NL<br><div><u>SINGLES</u></div>$NL$uncontained_tracks"
|
[ -n "$uncontained_tracks" ] && uncontained_tracks="$NL<br><div><u>SINGLES</u></div>$NL$uncontained_tracks"
|
||||||
fi
|
fi
|
||||||
[ "$contained_tracks" ] && contained_tracks="$NL<br><div><u>SINGLES</u></div>$NL$contained_tracks"
|
[ -n "$contained_tracks" ] && contained_tracks="$NL<br><div><u>SINGLES</u></div>$NL$contained_tracks"
|
||||||
contained_albums="$NL<br><div><b>Contained Releases</b></div>$NL$contained_albums"
|
contained_albums="$NL<br><div><b>Contained Releases</b></div>$NL$contained_albums"
|
||||||
|
|
||||||
printf '%s%s%s%s%s%s' \
|
printf '%s%s%s%s%s%s' \
|
||||||
|
@ -112,7 +112,7 @@ if [ ! "$no_download" ]; then
|
||||||
printf '%s' 'CAT.ALL' > ./files/_rules.conf
|
printf '%s' 'CAT.ALL' > ./files/_rules.conf
|
||||||
# artist img
|
# artist img
|
||||||
img="$(pup 'img.band-photo' 'attr{src}' < "$FILE")"
|
img="$(pup 'img.band-photo' 'attr{src}' < "$FILE")"
|
||||||
if [ "$img" ]; then
|
if [ -n "$img" ]; then
|
||||||
ext="${img##*.}"
|
ext="${img##*.}"
|
||||||
curl -s -o ./files/artist."$ext" "${img%_*}_0.$ext"
|
curl -s -o ./files/artist."$ext" "${img%_*}_0.$ext"
|
||||||
fi
|
fi
|
||||||
|
|
2
n
2
n
|
@ -6,7 +6,7 @@ if [ "${NNNLVL:-0}" -ge 1 ]; then
|
||||||
echo "don't nest nnn!" && exit
|
echo "don't nest nnn!" && exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[ "${TMUX:-}" ] && exec nnn
|
[ -n "${TMUX:-}" ] && exec nnn
|
||||||
|
|
||||||
vars="NNN_BATTHEME=Dracula
|
vars="NNN_BATTHEME=Dracula
|
||||||
NNN_BATSTYLE=full
|
NNN_BATSTYLE=full
|
||||||
|
|
|
@ -7,8 +7,8 @@ CATBOX_USERHASH="" # catbox userhash
|
||||||
BASEIFS=$IFS
|
BASEIFS=$IFS
|
||||||
|
|
||||||
clean() {
|
clean() {
|
||||||
[ "$nsxiv_pid" ] && kill "$nsxiv_pid"
|
[ -n "$nsxiv_pid" ] && kill "$nsxiv_pid"
|
||||||
[ "$tmpfreeze" ] && rm -f "$tmpfreeze"
|
[ -f "$tmpfreeze" ] && rm -f "$tmpfreeze"
|
||||||
rm -f "$tmpfp"
|
rm -f "$tmpfp"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ choose() {
|
||||||
h1="$(md5sum "$tmpfp")"
|
h1="$(md5sum "$tmpfp")"
|
||||||
gimp -n "$tmpfp"
|
gimp -n "$tmpfp"
|
||||||
h2="$(md5sum "$tmpfp")"
|
h2="$(md5sum "$tmpfp")"
|
||||||
[ "$h1" != "$h2" ] && save # changed, save
|
[ -n "$h1" != "$h2" ] && save # changed, save
|
||||||
;;
|
;;
|
||||||
scan)
|
scan)
|
||||||
zdata="$(zbarimg -1 "$tmpfp")" || zdata="error: scan failed with exit code $?"
|
zdata="$(zbarimg -1 "$tmpfp")" || zdata="error: scan failed with exit code $?"
|
||||||
|
@ -55,7 +55,7 @@ choose() {
|
||||||
ss() {
|
ss() {
|
||||||
[ "$ssopts" = "-g" ] && ssopts="$(hacksaw -f "-i %i -g %g")"
|
[ "$ssopts" = "-g" ] && ssopts="$(hacksaw -f "-i %i -g %g")"
|
||||||
shotgun $ssopts "$tmpfp"
|
shotgun $ssopts "$tmpfp"
|
||||||
[ "$nsxiv_pid" ] && kill "$nsxiv_pid" && nsxiv_pid="" # unfreeze
|
[ -n "$nsxiv_pid" ] && kill "$nsxiv_pid" && nsxiv_pid="" # unfreeze
|
||||||
xclip -selection clipboard -t image/png < "$tmpfp" # copy screenshot
|
xclip -selection clipboard -t image/png < "$tmpfp" # copy screenshot
|
||||||
choose
|
choose
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ while getopts :hi:f:t: OPT; do
|
||||||
done
|
done
|
||||||
shift $((OPTIND - 1))
|
shift $((OPTIND - 1))
|
||||||
|
|
||||||
[ "$*" ] || set -- "$(cat /dev/stdin)"
|
[ -n "$*" ] || set -- "$(cat /dev/stdin)"
|
||||||
[ "$*" ] || usage
|
[ -n "$*" ] || usage
|
||||||
|
|
||||||
curl -s "${INSTANCE}/api/translate?engine=${ENGINE}&from=${FLANG}&to=${TLANG}&text=$(jq -rn --arg x "$*" '$x|@uri')" | jq -r '."translated-text"'
|
curl -s "${INSTANCE}/api/translate?engine=${ENGINE}&from=${FLANG}&to=${TLANG}&text=$(jq -rn --arg x "$*" '$x|@uri')" | jq -r '."translated-text"'
|
||||||
|
|
|
@ -28,7 +28,7 @@ MAX_TRIES=2
|
||||||
check() {
|
check() {
|
||||||
trap 'innerclean '"$2" INT HUP TERM
|
trap 'innerclean '"$2" INT HUP TERM
|
||||||
curl -s -o "$2" -L "https://twitch.tv/$1"
|
curl -s -o "$2" -L "https://twitch.tv/$1"
|
||||||
if [ "$(pup 'script[type="application/ld+json"]' < "$2")" ]; then
|
if [ -n "$(pup 'script[type="application/ld+json"]' < "$2")" ]; then
|
||||||
if [ ! -f "$DIR/$1" ]; then
|
if [ ! -f "$DIR/$1" ]; then
|
||||||
touch "$DIR/$1"
|
touch "$DIR/$1"
|
||||||
IMG="$(mktemp -t "twitch-notify-img.XXXX")"
|
IMG="$(mktemp -t "twitch-notify-img.XXXX")"
|
||||||
|
|
|
@ -11,6 +11,6 @@ for x in /var/cache/xbps/*.xbps; do
|
||||||
xbps-query "$(xbps-uhelper binpkgver "$x")" 1>/dev/null 2>&1
|
xbps-query "$(xbps-uhelper binpkgver "$x")" 1>/dev/null 2>&1
|
||||||
if [ $? -eq 2 ]; then
|
if [ $? -eq 2 ]; then
|
||||||
echo "${x%.*}"
|
echo "${x%.*}"
|
||||||
[ "$DEL" ] && rm "${x%.*}".*
|
[ -n "$DEL" ] && rm "${x%.*}".*
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in New Issue