From 978a8e5c7c5e98f7023213d6f8ae230fabf51e3e Mon Sep 17 00:00:00 2001 From: Balakrishnan Balasubramanian Date: Sun, 29 Jun 2025 14:25:55 -0400 Subject: [PATCH] cleanup and add README --- README.md | 43 +++++++++++++++++++++++++++++++++++++++++++ run.sh | 19 ++++++++++--------- 2 files changed, 53 insertions(+), 9 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..dfa5a9e --- /dev/null +++ b/README.md @@ -0,0 +1,43 @@ +### Miniflux old feed fetcher + +Some news sites pay-wall articles for some time such that they are only +available to subscribers. After the pay-wall period, they are then freely +available to all. This script is for [lwn][0]. + +1. Gets all articles before last Thursday that were pay-walled. Title starts + with `[$] ...` for pay-walled articles +2. Downloads full content +3. Updates title replacing `$` with `✓`, i.e Now it reads `[✓] ...` +4. Marks those articles as unread + +### Dependencies + +* [yq][1] +* [miller][2] + +### Usage + +1. Update miniflux url and feed id +2. export MINIFLUX_TOKEN environment variable +3. Run `./run.sh` + +```sh +❯ ./run.sh +Considering articles between w2: 2025-06-08T13:47:04-04:00 and w1: 2025-06-19T00:00:00-04:00 +processing entry: 3068 title: [$] Finding locking bugs with Smatch +Downloding content. entry: 3068 title: [$] Finding locking bugs with Smatch +Updating title. entry: 3068 title: [$] Finding locking bugs with Smatch +Marking as unread. entry: 3068 title: [$] Finding locking bugs with Smatch +processing entry: 3061 title: [$] Improving iov_iter +Downloding content. entry: 3061 title: [$] Improving iov_iter +Updating title. entry: 3061 title: [$] Improving iov_iter +Marking as unread. entry: 3061 title: [$] Improving iov_iter +processing entry: 3060 title: [$] An end to uniprocessor configurations +Downloding content. entry: 3060 title: [$] An end to uniprocessor configurations +Updating title. entry: 3060 title: [$] An end to uniprocessor configurations +Marking as unread. entry: 3060 title: [$] An end to uniprocessor configurations +``` + +[0]: https://lwn.net +[1]: https://github.com/mikefarah/yq +[2]: https://github.com/johnkerl/miller diff --git a/run.sh b/run.sh index 0a7c088..5377c1d 100755 --- a/run.sh +++ b/run.sh @@ -9,18 +9,17 @@ process() { local eid="$1" local title="$2" - echo "processing entry: $eid title: $title" - - title=${title//$/✓} - + echo "Downloding content. entry: $eid title: $title" curl --fail -o /dev/null -s "$MURL/v1/entries/$eid/fetch-content" \ --url-query update_content=true \ -H "X-Auth-Token: $MINIFLUX_TOKEN" + echo "Updating title. entry: $eid title: $title" curl --fail -o /dev/null -s -X PUT "$MURL/v1/entries/$eid" \ - --json "$(printf '{"title":"%s"}' "$title")" \ + --json "$(printf '{"title":"%s"}' "${title/$/✓}")" \ -H "X-Auth-Token: $MINIFLUX_TOKEN" + echo "Marking as unread. entry: $eid title: $title" curl --fail -s -X PUT "$MURL/v1/entries" \ --json "$(printf '{"entry_ids":[%s],"status":"unread"}' "$eid")" \ -H "X-Auth-Token: $MINIFLUX_TOKEN" @@ -31,7 +30,7 @@ main() { local w1 w2 - if [ "$(date +%u)" = 4 ]; then + if [ "$(date +%A)" = Thursday ]; then w1=$(date --iso-8601=s -d 'last thursday') else w1=$(date --iso-8601=s -d 'last thursday -1 week') @@ -39,18 +38,20 @@ main() { w2=$(date --iso-8601=s -d '3 weeks ago') - echo "w1: $w1 w2: $w2" + echo "Considering articles between w2: $w2 and w1: $w1 " - curl -s --fail -D headers.out "$MURL/v1/feeds/$FID/entries" \ + curl -s --fail "$MURL/v1/feeds/$FID/entries" \ --url-query limit=50 \ --url-query order=id \ --url-query direction=desc \ -H "X-Auth-Token: $MINIFLUX_TOKEN" | yq '.entries[]' | - mlr --l2p --ho \ + mlr --l2n \ filter '$title =~ "\[\$\]"' \ 'then' filter -s w1="$w1" -s w2="$w2" '$published_at > @w2 && $published_at < @w1' \ 'then' cut -of id,title | while read -r eid title; do + + echo "processing entry: $eid title: $title" process "$eid" "$title" done