Add batch article fetching: derstandard articles url1,url2,...
This commit is contained in:
parent
b603036509
commit
01aec23f1f
2 changed files with 22 additions and 8 deletions
|
|
@ -13,11 +13,12 @@ usage() {
|
|||
Usage: derstandard <command> [args]
|
||||
|
||||
Commands:
|
||||
items [max] Title + URL pairs for selection (default: 50)
|
||||
article <url> 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 <url> Fetch single article content
|
||||
articles <url1,url2,...> 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 <url>"; exit 1; }
|
||||
fetch_article "$2"
|
||||
fetch_single_article "$2"
|
||||
;;
|
||||
articles)
|
||||
[ -z "${2:-}" ] && { echo "Usage: derstandard articles <url1,url2,...>"; 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 '<link>\K[^<]+' | grep "derstandard.at/story"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue