From 1d1f866e66a4c67654aa31b6d7c23c6fc85c8707 Mon Sep 17 00:00:00 2001 From: Alex Hyett Date: Fri, 13 Sep 2024 11:22:16 +0100 Subject: [PATCH] Add scripts --- README.md | 5 ++++- getStarred.sh | 18 ++++++++++++++++++ unstar.sh | 22 ++++++++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100755 getStarred.sh create mode 100755 unstar.sh diff --git a/README.md b/README.md index 0306a76..50790eb 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ # useful-scripts -A collection of useful scripts that I use everyday \ No newline at end of file +A collection of useful scripts that I use everyday + +- getStarred.sh - Get starred articles from Miniflux and copy to clipboard. [Notes](https://www.alexhyett.com/notes/getting-starred-items-from-miniflux/) +- unstar.sh - Unstar all starred articles on Miniflux. [Notes](https://www.alexhyett.com/notes/getting-starred-items-from-miniflux/) \ No newline at end of file diff --git a/getStarred.sh b/getStarred.sh new file mode 100755 index 0000000..7f107db --- /dev/null +++ b/getStarred.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +# https://www.alexhyett.com/notes/getting-starred-items-from-miniflux/ + +# Define API endpoint and token +API_URL="" +AUTH_TOKEN="" + +# Fetch JSON response from the API +response=$(curl -s -H "X-Auth-Token: $AUTH_TOKEN" $API_URL/v1/entries?starred=true) + +# Parse JSON and format as markdown links with two new lines between results +markdown=$(echo "$response" | jq -r '.entries[] | "[\(.title)](\(.url))\n"') + +# Copy the result to the clipboard with additional newline separation +printf "%s\n\n" "$markdown" | pbcopy + +echo "Markdown links copied to clipboard." diff --git a/unstar.sh b/unstar.sh new file mode 100755 index 0000000..31d35c3 --- /dev/null +++ b/unstar.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# https://www.alexhyett.com/notes/getting-starred-items-from-miniflux/ + +# Define API endpoint and token + +API_URL="" +AUTH_TOKEN="" + +# Fetch JSON response from the API +response=$(curl -s -H "X-Auth-Token: $AUTH_TOKEN" $API_URL/v1/entries?starred=true) + +# Parse JSON to get entry IDs +entry_ids=$(echo "$response" | jq -r '.entries[].id') + +# Loop through each entry ID and send a PUT request to unstar it +for entry_id in $entry_ids; do + update_url="$API_URL/v1/entries/$entry_id/bookmark" + curl -s -o /dev/null -X PUT -H "Content-Type: application/json" -H "X-Auth-Token: $AUTH_TOKEN" $update_url +done + +echo "Unstarred all entries." \ No newline at end of file