fix: better detection of files for each step
This commit is contained in:
parent
b8d5e6b922
commit
e22f229f37
3 changed files with 41 additions and 21 deletions
|
@ -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"
|
||||||
|
|
|
@ -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)
|
||||||
|
|
48
justfile
48
justfile
|
@ -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
|
||||||
|
do
|
||||||
|
O=M4B/$(basename $F .aax).m4b
|
||||||
ffmpeg \
|
ffmpeg \
|
||||||
-y \
|
-y \
|
||||||
-activation_bytes $(jq .activation_bytes ~/.audible/audible.json | tr '\"' ' ') \
|
-activation_bytes $(jq .activation_bytes ~/.audible/audible.json | tr '\"' ' ') \
|
||||||
-i $F \
|
-i $F \
|
||||||
-codec copy \
|
-codec copy \
|
||||||
$O && \
|
$O
|
||||||
rm $F ; \
|
rm $F
|
||||||
done || true
|
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}" ];
|
||||||
|
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}"
|
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:
|
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
|
||||||
|
|
Loading…
Reference in a new issue