added: ~bare bones~ view thread

This commit is contained in:
localhost_frssoft 2022-04-13 02:15:25 +03:00
parent 53aef502c9
commit eb2b5846eb
1 changed files with 59 additions and 1 deletions

View File

@ -66,6 +66,58 @@ auth_api_get_token()
jj -p -i .auth.json -v "$token" "$(echo $instance | sed 's/\./\\\./g')" -o .auth.json
}
thread_api_statuses()
{
default_curl_opt "$instance_point/statuses/$1/context"
}
thread_menu()
{
sub_menu_lvl=2
jsonthread=$(thread_api_statuses $1)
ancestors=$(echo $jsonthread | jj ancestors)
descendants=$(echo $jsonthread | jj descendants)
if [ '[]' != "$ancestors" ] && [ '[]' != "$descendants" ]; then
jsonthread=$(echo "$ancestors""$descendants")
elif [ '[]' != "$ancestors" ]; then
jsonthread="$ancestors"
else
jsonthread="$descendants"
fi
indexator=$(expr $(echo $jsonthread | jj \#) - 1)
counter=0
while [ $sub_menu_lvl -eq 2 ]; do
clear
echo '[Thread]'
while [ ! $indexator -eq $counter ]; do
status=$(echo $jsonthread | jj $counter)
uri=$(echo $status | jj uri)
id_status=$(echo $status | jj id)
dateutc=$(echo $status | jj created_at)
reply_to_id=$(echo $status | jj in_reply_to_id)
echo "$(date -d $dateutc "$format_time") <$id_status> $uri"
if [ -n "$reply_to_id" ]; then
echo "Reply to: $reply_to_id"
fi
echo $status | jj content | sed -e "s/<br[^>]*>/\n/g
; s/<p[^>]*>/\n/g ; s/<[^>]*>//g
; s/&gt;*/>/g ; s/&lt;*/</g ; s/&quot;/\"/g ; s/&#39;/'/g"
attachments=$(echo $status | jj -l media_attachments.#.remote_url | sed 's/"//g')
if [ -n "$attachments" ]; then
echo "#EXTINF:-1, $uri" >> attachments.m3u8
echo "$attachments" >> attachments.m3u8
fi
counter=$(expr $counter + 1)
echo '_____'
done
menuthread=$(echo 'Back' | fzy)
case "$menuthread" in
"Back")
sub_menu_lvl=1 ;;
esac
done
}
timeline_api()
{
default_curl_opt "$instance_point/$timeline?limit=$max_statuses&max_id=$1" | tee preload
@ -104,7 +156,7 @@ timeline_menu()
indexator=$(expr $indexator - 1)
echo '_____'
done
menu=$(echo 'Prev\nNext\nShare\nMain menu' | fzy)
menu=$(echo 'Prev\nNext\nShare\nThread\nMain menu' | fzy)
case $menu in
"Prev")
indexator=$(expr $max_statuses - 1)
@ -133,6 +185,12 @@ timeline_menu()
fi
done
;;
"Thread")
indexator=$(expr $max_statuses - 1)
echo 'Input id'
read status_id
thread_menu $status_id
;;
"Main menu")
sub_menu_lvl=0 ;;
esac