fix: better detection of files for each step

This commit is contained in:
Paul Campbell 2024-11-03 09:19:33 +00:00
parent b8d5e6b922
commit e22f229f37
3 changed files with 41 additions and 21 deletions

View file

@ -3,6 +3,7 @@ ffmpeg = "latest"
jq = "latest" jq = "latest"
"pipx:mkb79/audible-cli" = "master" "pipx:mkb79/audible-cli" = "master"
"cargo:refile-m4b" = "latest" "cargo:refile-m4b" = "latest"
fd = "latest"
fzf = "latest" fzf = "latest"
python = "latest" python = "latest"
pipx = "latest" pipx = "latest"

View file

@ -10,6 +10,7 @@ Mise will be used to install the other dependencies. If you don't want to use `m
- [just](https://just.systems/) - [just](https://just.systems/)
- [audible-cli](https://github.com/mkb79/audible-cli) (recommended installation instuctions below) - [audible-cli](https://github.com/mkb79/audible-cli) (recommended installation instuctions below)
- [fd](https://github.com/sharkdp/fd)
- [fzf](https://github.com/junegunn/fzf) - [fzf](https://github.com/junegunn/fzf)
- [jq](https://jqlang.github.io/jq/) - [jq](https://jqlang.github.io/jq/)
- [ffmpeg](https://ffmpeg.org) - [ffmpeg](https://ffmpeg.org)

View file

@ -54,27 +54,35 @@ post-download:
convert: convert-aax convert-aaxc convert: convert-aax convert-aaxc
convert-aax: convert-aax:
#!/usr/bin/env bash
just _require_dir M4B just _require_dir M4B
[ -f AAX/*.aax ] && for F in AAX/*.aax ; \ if [ $(fd --glob 'AAX/*.aax' | wc -l) -gt 0 ]
do \ then
O=M4B/$(basename $F .aax).m4b ; \ for F in AAX/*.aax
ffmpeg \ do
-y \ O=M4B/$(basename $F .aax).m4b
-activation_bytes $(jq .activation_bytes ~/.audible/audible.json | tr '\"' ' ') \ ffmpeg \
-i $F \ -y \
-codec copy \ -activation_bytes $(jq .activation_bytes ~/.audible/audible.json | tr '\"' ' ') \
$O && \ -i $F \
rm $F ; \ -codec copy \
done || true $O
rm $F
done
fi
convert-aaxc: convert-aaxc:
#!/usr/bin/env bash
just _require_dir M4B just _require_dir M4B
[ -f AAXC/*.aaxc ] && for AAXC in AAXC/*.aaxc ; \ if [ $(fd --glob 'AAXC/*.aaxc' | wc -l) -gt 0 ]
do \ then
VOUCHER="${AAXC%.aaxc}.voucher" ; \ for AAXC in AAXC/*.aaxc
M4B="M4B/$(basename ${AAXC%.aaxc}).m4b" ; \ do
just _convert-one-aaxc $AAXC $VOUCHER $M4B ; \ VOUCHER="${AAXC%.aaxc}.voucher"
done || true M4B="M4B/$(basename ${AAXC%.aaxc}).m4b"
just _convert-one-aaxc $AAXC $VOUCHER $M4B
done
fi
_convert-one-aaxc aaxc_file voucher_file m4b_file: _convert-one-aaxc aaxc_file voucher_file m4b_file:
#!/usr/bin/env bash #!/usr/bin/env bash
@ -94,10 +102,20 @@ refile:
refile-m4b M4B refile-m4b M4B
archive: archive:
[ -d "${AUDIOBOOK_ARCHIVE}" ] || (echo "ERROR: No archive specified" ; exit 1) #!/usr/bin/env bash
[ -f M4B/* ] || (echo "WARN: Nothing to be archived" ; exit 1) if [ -d M4B ] && [ -n "${AUDIOBOOK_ARCHIVE}" ] && [ -d "${AUDIOBOOK_ARCHIVE}" ];
cd M4B && cp -v -R * "${AUDIOBOOK_ARCHIVE}" then
just _clean M4B if [ $(fd . M4B | wc -l) -eq 0 ]
then
echo "WARN: Nothing to be archived"
exit 1
fi
cd M4B && cp -v -R * "${AUDIOBOOK_ARCHIVE}"
just _clean M4B/*
else
echo "ERROR: No archive specified or no M4B directory"
exit 1
fi
clean: clean:
for target in TEMP/* AAX/* AAXC/* M4B/* ; do just _clean $target ; done for target in TEMP/* AAX/* AAXC/* M4B/* ; do just _clean $target ; done