v1.1.0
- fixed "delete after encoding", wasn't actually deleting after encoding - added basic update checker (curl)
This commit is contained in:
parent
7b3d0a2438
commit
4fed3500b3
29
flacconv
29
flacconv
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
|
||||
# flacconv 1.0.1 // use https://github.com/yoshiyoshyosh/flacconv for issues
|
||||
# flacconv 1.1.0 // use https://github.com/yoshiyoshyosh/flacconv for issues
|
||||
|
||||
set -euf
|
||||
TAB="$(printf '\t')"
|
||||
|
@ -38,6 +38,20 @@ _tempdir() {
|
|||
set -u
|
||||
}
|
||||
|
||||
checkupdate() {
|
||||
errecho 'checking remote script...'
|
||||
remotesh="$(curl -s https://raw.githubusercontent.com/yoshiyoshyosh/flacconv/main/flacconv)"
|
||||
errecho 'checking local script...'
|
||||
localsh="$(cat "$0")"
|
||||
if [ "$remotesh" = "$localsh" ]; then
|
||||
errecho 'your script is updated to the latest version!'
|
||||
else
|
||||
errecho 'your script differs from remote!'
|
||||
errecho 'if this is unintentional, download the newest version from https://raw.githubusercontent.com/yoshiyoshyosh/flacconv/main/flacconv'
|
||||
fi
|
||||
exit 0
|
||||
}
|
||||
|
||||
metaflac() { command metaflac --no-utf8-convert "$@"; } # don't wanna fuck up any tags from locale shit
|
||||
|
||||
convwarn() { errecho "an error occured while encoding $infile, not deleting" && err=1 && DELETE= ; }
|
||||
|
@ -101,12 +115,15 @@ process_file() {
|
|||
fi
|
||||
[ "${pic:-}" ] && rm -f "$pic"
|
||||
[ -z "${err:-}" ] && echo "$infile successfully converted to $TYPE with bitrate/quality ${VLVL:-${BITRATE}k}"
|
||||
[ -z "$DELETE" ] && rm -f "$infile" || true
|
||||
[ -z "$DELETE" ] || rm -f "$infile"
|
||||
|
||||
#note: my version only
|
||||
[ "$TYPE" = "opus" ] && opustags -d ENCODER -d ENCODER_OPTIONS -i "${infile%.*}.opus"
|
||||
}
|
||||
|
||||
usage() {
|
||||
errecho \
|
||||
"usage: $BN [-hdp3] [-b BITRATE] [-v LEVEL] [-k KEYS] [-r KEYS] [-j THREADS] [--] [DIRECTORY...]
|
||||
"usage: $BN [-hudp3] [-b BITRATE] [-v LEVEL] [-k KEYS] [-r KEYS] [-j THREADS] [--] [DIRECTORY...]
|
||||
$BN recursively converts directories of flac files to opus/mp3
|
||||
DIRECTORY can be specified multiple times. if omitted, the current directory is used
|
||||
by default, this script outputs opus and bitrate 128k
|
||||
|
@ -114,6 +131,7 @@ if encoding to mp3, the only metadata that will be kept is the following:
|
|||
TITLE, ARTIST, ALBUM, ALBUMARTIST, DATE, GENRE, TRACKNUMBER, COMMENT, and the cover picture
|
||||
|
||||
-h show script help
|
||||
-u check for updates
|
||||
-i ignore script-stopping warnings
|
||||
-d delete original flac files after transcoding
|
||||
-3 switch output filetype to mp3
|
||||
|
@ -135,7 +153,7 @@ if encoding to mp3, the only metadata that will be kept is the following:
|
|||
if omitted, CPU core count will be used"
|
||||
}
|
||||
|
||||
DELETE=0
|
||||
DELETE=
|
||||
TYPE=opus
|
||||
BITRATE=128
|
||||
VLVL=
|
||||
|
@ -146,9 +164,10 @@ IGNOREWARNINGS=
|
|||
THREADS="$(getconf _NPROCESSORS_ONLN 2>/dev/null || getconf NPROCESSORS_ONLN)" # linux & freebsd compat I think
|
||||
_tempdir # set temp dir
|
||||
|
||||
while getopts :hd3peib:v:k:r:j: OPT; do
|
||||
while getopts :hud3peib:v:k:r:j: OPT; do
|
||||
case "$OPT" in
|
||||
h) usage && exit 0 ;;
|
||||
u) checkupdate ;;
|
||||
d) DELETE=1 ;;
|
||||
3) TYPE=mp3 ;;
|
||||
p) RMPIC=1 ;;
|
||||
|
|
Loading…
Reference in New Issue