From 40141e0c0b6875e5ad388050f480a346371b85b8 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 2 Dec 2024 19:43:22 +0000 Subject: [PATCH] feat: only show recent additions to library by default --- README.md | 13 +++++++++++++ justfile | 23 ++++++++++++++++++----- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 5cc09ce..d0ad917 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,9 @@ just fetch-library This will create a new file `library-{date}.txt`, that contains a list of everything available in your account. +On subsequent runs (on a different day!) it will create a file `library-recent.txt` that contains any new additions to your +library since the previous run. + ### Select, download and convert The recommended workflow is to run the default recipe which will present you with a searchable list of your library. @@ -99,6 +102,16 @@ From here you can select items to download by pressing `TAB` (for selecting mutl ```shell just +# or +just select-download-recent +``` + +This will use the `library-recent.txt` file, showing only new additions to your library. + +To select from your full library: + +```shell +just select-download-full ``` Once you have made your selection, the `.aax` and/or `.aaxc/.voucher` files will be downloaded, via a `./TEMP/` directory, diff --git a/justfile b/justfile index b2f3ab5..e06cfb6 100644 --- a/justfile +++ b/justfile @@ -1,4 +1,4 @@ -default: select-download convert refile +default: select-download-recent convert refile @tree M4B/ doctor: @@ -17,9 +17,15 @@ _doc_require_exec exec: echo "- OKAY : {{ exec }} => ${EXEC}" fi -select-download: +select-download-recent: + just select-download library-recent.txt + +select-download-full: + just select-download $(just latest-library) + +select-download library: #!/usr/bin/env bash - SELECTION=$(cat $(just latest-library) | sort -k 2 | fzf -e -m) + SELECTION=$(cat {{library}} | sort -k 2 | fzf -e -m) ASINS="" while IFS= read -r LINE ; do echo "$LINE" @@ -30,10 +36,17 @@ select-download: just _download-asin $ASINS fetch-library: - audible library list > library-$(date +%Y-%m-%d).txt + #!/usr/bin/env bash + set -e + PREVIOUS=$(just latest-library) + audible library list | sort > library-$(date +%Y-%m-%d).txt + CURRENT=$(just latest-library) + comm -23 $CURRENT $PREVIOUS > library-recent.txt + echo "New additions:" + cat library-recent.txt @latest-library: - ls library-*.txt | tail -n 1 + ls library-*.txt | grep -v recent | tail -n 1 _require_dir *dirs: mkdir {{ dirs }} 2>/dev/null || true