diff --git a/TOOLS.md b/TOOLS.md index 20af716..b911ec0 100644 --- a/TOOLS.md +++ b/TOOLS.md @@ -47,6 +47,7 @@ Helper script: `~/bin/derstandard` ```bash derstandard items [max] # Title + URL pairs (tab-separated) derstandard article # Full article content for a specific URL +derstandard articles ,,... # Fetch multiple articles (comma-separated) derstandard urls [max] # Article URLs only (default: 50) derstandard titles [max] # Article titles only derstandard raw [max] # Full RSS XML @@ -57,7 +58,7 @@ derstandard raw [max] # Full RSS XML **Workflow for news briefing:** 1. `derstandard items` → pick interesting titles -2. `derstandard article ` → get full content for selected articles +2. `derstandard articles ,,...` → get full content for selected articles ## Forgejo Git Access diff --git a/bin/derstandard b/bin/derstandard index 0731d2f..eb63404 100755 --- a/bin/derstandard +++ b/bin/derstandard @@ -13,11 +13,12 @@ usage() { Usage: derstandard [args] Commands: - items [max] Title + URL pairs for selection (default: 50) - article Fetch full article content for a specific URL - urls [max] Article URLs only - titles [max] Article titles only - raw [max] Full RSS XML + items [max] Title + URL pairs for selection (default: 50) + article Fetch single article content + articles Fetch multiple articles (comma-separated) + urls [max] Article URLs only + titles [max] Article titles only + raw [max] Full RSS XML EOF } @@ -27,7 +28,7 @@ fetch_feed() { $CURL "${FIVEFILTERS_URL}/makefulltextfeed.php?url=${encoded_url}&max=${max}&links=preserve&exc=" } -fetch_article() { +fetch_single_article() { local url="$1" local encoded_url=$(printf '%s' "$url" | sed 's/:/%3A/g; s/\//%2F/g; s/\?/%3F/g; s/&/%26/g; s/=/%3D/g') $CURL "${FIVEFILTERS_URL}/makefulltextfeed.php?url=${encoded_url}&max=1&links=preserve&exc=" | \ @@ -50,7 +51,19 @@ case "${1:-}" in ;; article) [ -z "${2:-}" ] && { echo "Usage: derstandard article "; exit 1; } - fetch_article "$2" + fetch_single_article "$2" + ;; + articles) + [ -z "${2:-}" ] && { echo "Usage: derstandard articles "; exit 1; } + IFS=',' read -ra URLS <<< "$2" + for url in "${URLS[@]}"; do + # Extract title from URL slug + title=$(echo "$url" | grep -oP '/\d+/\K[^?]+' | tr '-' ' ' | sed 's/.*/\u&/') + echo "=== ${title} ===" + fetch_single_article "$url" + echo "" + echo "" + done ;; urls) fetch_feed "${2:-50}" | grep -oP '\K[^<]+' | grep "derstandard.at/story"