Add scripts
This commit is contained in:
parent
25b13c230f
commit
1d1f866e66
3 changed files with 44 additions and 1 deletions
|
@ -1,3 +1,6 @@
|
|||
# useful-scripts
|
||||
|
||||
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/)
|
18
getStarred.sh
Executable file
18
getStarred.sh
Executable file
|
@ -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."
|
22
unstar.sh
Executable file
22
unstar.sh
Executable file
|
@ -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."
|
Loading…
Reference in a new issue