Add several arguments: -b, -B, -t, and -l
This commit is contained in:
parent
c5e9a5bc93
commit
9fe6003f6c
61
fedi2html.sh
61
fedi2html.sh
|
@ -203,8 +203,12 @@ fetch_post() {
|
|||
fetch_user_posts() {
|
||||
local url="$1"
|
||||
local server="$(url_server "$url")"
|
||||
local status_url="$server/api/v1/accounts/$(url_user_id "$url")/statuses"
|
||||
status_url="${status_url}?exclude_reblogs=${EXCLUDE_REBLOGS}&limit=$MAX_POSTS"
|
||||
status_url="${status_url}&exclude_replies=${EXCLUDE_REPLIES}$TAG_FILTER"
|
||||
|
||||
curl --location --header 'Accept: application/json,application/activity+json' \
|
||||
"$server/api/v1/accounts/$(url_user_id "$url")/statuses?exclude_reblogs" \
|
||||
"$status_url" \
|
||||
| jq -c '.[]'
|
||||
}
|
||||
|
||||
|
@ -335,27 +339,39 @@ handle_post_url() {
|
|||
|
||||
|
||||
usage() {
|
||||
echo "usage: $(basename "$0") [-h] [-IR] POST_URL"
|
||||
echo "usage: $(basename "$0") [-h] [-IRc] POST_URL"
|
||||
echo " $(basename "$0") [-h] [-IRc] [-bBt] USER_URL"
|
||||
echo
|
||||
echo "$(basename "$0") does exactly what it says on the tin: It formats"
|
||||
echo "a fediverse post (and its replies) into simple-and-embeddable HTML."
|
||||
echo 'a fediverse post (and its replies) into simple-and-embeddable HTML.'
|
||||
echo
|
||||
echo "It works with posts from any server that supports Mastodon’s API,"
|
||||
echo "including Pleroma, Akkoma, Glitch, etc."
|
||||
echo 'It works with posts from any server that supports Mastodon’s API,'
|
||||
echo 'including Pleroma, Akkoma, Glitch, etc.'
|
||||
echo
|
||||
echo "Notably, it supports post-atachments and custom-emoji. Keep in mind"
|
||||
echo "that images are all fetched from remote sources. It is recommended,"
|
||||
echo "if privacy or total archival, is a concern, to use wget(1)’s --mirror"
|
||||
echo "(or something like it) to fetch even these foreign files."
|
||||
echo 'Notably, it supports post-atachments and custom-emoji. Keep in mind'
|
||||
echo 'that images are all fetched from remote sources. It is recommended,'
|
||||
echo 'if privacy or total archival, is a concern, to use wget(1)’s --mirror'
|
||||
echo '(or something like it) to fetch even these foreign files.'
|
||||
echo
|
||||
echo " -c only print the responses (children) of a post"
|
||||
echo " -h print this message and exit"
|
||||
echo " -I display posts in reverse-chronological order"
|
||||
echo " -R do not recursively display posts’ responses"
|
||||
echo ' -c only print the responses (children) of a post'
|
||||
echo ' -h print this message and exit'
|
||||
echo ' -I display posts in reverse-chronological order'
|
||||
echo ' -l output at maximum the specified amount of posts'
|
||||
echo ' -R do not recursively display posts’ responses'
|
||||
echo
|
||||
echo ' -b exclude reblogs/repeats from user feed'
|
||||
echo ' -B exclude top-level replies from user feed'
|
||||
echo ' -t filter posts from user feed by tag'
|
||||
}
|
||||
|
||||
|
||||
while getopts 'hcIR' arg; do
|
||||
TAG_FILTER=""
|
||||
EXCLUDE_REPLIES="false"
|
||||
EXCLUDE_REBLOGS="false"
|
||||
MAX_POSTS=20
|
||||
|
||||
|
||||
while getopts 'hcIRt:bm:B' arg; do
|
||||
case $arg in
|
||||
h)
|
||||
usage
|
||||
|
@ -370,6 +386,18 @@ while getopts 'hcIR' arg; do
|
|||
R)
|
||||
NO_RESPONSES="1"
|
||||
;;
|
||||
t)
|
||||
TAG_FILTER="&tagged=$OPTARG"
|
||||
;;
|
||||
b)
|
||||
EXCLUDE_REBLOGS="true"
|
||||
;;
|
||||
m)
|
||||
MAX_POSTS="$OPTARG"
|
||||
;;
|
||||
B)
|
||||
EXCLUDE_REPLIES="true"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
|
@ -383,17 +411,14 @@ if test -z "$URL"; then
|
|||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
USER_ID="$(url_user_id "$URL")"
|
||||
POST_ID="$(url_post_id "$URL")"
|
||||
if test -n "$POST_ID"; then
|
||||
echo "POST"
|
||||
handle_post_url "$URL"
|
||||
elif test -n "$USER_ID"; then
|
||||
handle_user_url "$URL"
|
||||
else
|
||||
echo "That URL is not recognized as a post or user URL." 1>&2
|
||||
echo 'That URL is not recognized as a post or user URL.' 1>&2
|
||||
exit 3
|
||||
fi
|
||||
|
||||
|
|
Ŝarĝante…
Reference in New Issue