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"
"pipx:mkb79/audible-cli" = "master"
"cargo:refile-m4b" = "latest"
fd = "latest"
fzf = "latest"
python = "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/)
- [audible-cli](https://github.com/mkb79/audible-cli) (recommended installation instuctions below)
- [fd](https://github.com/sharkdp/fd)
- [fzf](https://github.com/junegunn/fzf)
- [jq](https://jqlang.github.io/jq/)
- [ffmpeg](https://ffmpeg.org)

View file

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