mirror of
http://gitea.phreedom.club/localhost_frssoft/pleroma-cli
synced 2024-11-23 00:01:26 +00:00
Compare commits
3 commits
49ebf083e1
...
9b9f27b2ff
Author | SHA1 | Date | |
---|---|---|---|
localhost_frssoft | 9b9f27b2ff | ||
localhost_frssoft | 4b3a079365 | ||
localhost_frssoft | 02fb276232 |
17
README.md
17
README.md
|
@ -18,6 +18,17 @@
|
|||
| |... |--- ...
|
||||
|...
|
||||
```
|
||||
|
||||
## Группировка по timelines
|
||||
```
|
||||
[timelines]
|
||||
|
|
||||
|-[instance]
|
||||
| |--------[home]--[status_id]--...files
|
||||
| |--------[local]--[status_id]--...files
|
||||
| ...
|
||||
...
|
||||
```
|
||||
На данный момент статусы теперь линкуются из папки all_statuses/$instance, где содержатся не сгруппированные посты
|
||||
Время файлов внутри папки с постом ([status_id]) соответствует времени поста
|
||||
|
||||
|
@ -26,9 +37,13 @@
|
|||
|
||||
### Режим мониторинга файлов и автообновление ленты (пока только home)
|
||||
```
|
||||
daemon_mode=yes ./pleroma-cli.sh
|
||||
daemon_mode=yes instance=example ./pleroma-cli.sh
|
||||
```
|
||||
|
||||
# Отправка постов
|
||||
Чтобы отправить пост, нужно в папке all_statuses/$instance создать файл message и записать туда пост, затем создать файл create там же
|
||||
(Для добавления вложений нужно создать папку attachments и положить туда файлы для отправки)
|
||||
|
||||
### Частичное взаимодействие с постами:
|
||||
Чтобы добавить в избранное или бустануть пост нужно в папке с постом создать файл favourite и\или share
|
||||
```
|
||||
|
|
227
pleroma-cli.sh
227
pleroma-cli.sh
|
@ -1,6 +1,8 @@
|
|||
#!/bin/sh
|
||||
|
||||
instance=$(jj -i config.json instance)
|
||||
if [ -z "$instance" ]; then
|
||||
instance=$(jj -i config.json instance)
|
||||
fi
|
||||
alias default_auth_browser=links
|
||||
|
||||
export main_basedir=$(dirname $0)
|
||||
|
@ -434,125 +436,6 @@ status_api_one()
|
|||
default_curl_opt "$instance_point/statuses/$1"
|
||||
}
|
||||
|
||||
statuses_render()
|
||||
{
|
||||
if [ "$reversed_statuses" = 'true' ]; then
|
||||
ids_massive=$(echo "$ids_massive" | tr ' ' '\n' | tac | tr '\n' ' ')
|
||||
fi
|
||||
export instance
|
||||
echo "$jsonmassive" | ./utils/statuses2files.sh
|
||||
for i in $ids_massive; do
|
||||
status=$(echo "$jsonmassive" | jj "#[id=$i]")
|
||||
reblog=$(echo "$status" | jj reblog.id)
|
||||
if [ "$hide_reblogs" = 'true' ] && [ -n "$reblog" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
sensitive=$(echo "$status" | jj sensitive)
|
||||
sensitive_reblog=$(echo "$status" | jj reblog.sensitive)
|
||||
|
||||
if [ -n "$reblog" ]; then
|
||||
if [ "$enabled_nsfw" = 'false' ] && [ "$sensitive_reblog" = 'true' ]; then
|
||||
continue
|
||||
fi
|
||||
if [ "$nsfw_only" = 'true' ] && [ "$sensitive_reblog" = 'false' ]; then
|
||||
continue
|
||||
fi
|
||||
else
|
||||
if [ "$enabled_nsfw" = 'false' ] && [ "$sensitive" = 'true' ]; then
|
||||
continue
|
||||
fi
|
||||
if [ "$nsfw_only" = 'true' ] && [ "$sensitive" = 'false' ]; then
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
|
||||
whoacct=$(echo "$status" | jj account.acct)
|
||||
reblogacct=$(echo "$status" | jj reblog.account.acct)
|
||||
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)
|
||||
visibility_status=$(echo "$status" | jj visibility)
|
||||
s_f_menu='\nShare\nShare and favorite'
|
||||
edit_del_menu=
|
||||
if [ "$whoacct" = "$me_acct" ]; then
|
||||
edit_del_menu='\nEdit\nDelete'
|
||||
fi
|
||||
if [ "$visibility_status" = "private" ] || [ "$visibility_status" = "direct" ]; then
|
||||
s_f_menu=
|
||||
fi
|
||||
echo "| $(date -d "$dateutc" "$format_time") $visibility_status $whoacct"
|
||||
echo "| <$id_status> $uri"
|
||||
if [ -n "$reply_to_id" ]; then
|
||||
echo "| Reply to: $reply_to_id"
|
||||
fi
|
||||
if [ -n "$reblog" ]; then
|
||||
echo "| $boost_symbol $reblog $reblogacct"
|
||||
id_status="$reblog"
|
||||
fi
|
||||
spoiler_text=$(echo "$status" | jj spoiler_text)
|
||||
if [ -n "$spoiler_text" ]; then
|
||||
echo "#[$spoiler_text]"
|
||||
fi
|
||||
if [ "$sensitive" = 'true' -o "$sensitive_reblog" = 'true' ]; then
|
||||
echo '[NSFW]'
|
||||
fi
|
||||
status_content=$(echo "$status" | jj -r content | delqse | html_to_txt_render)
|
||||
pgp_crypted=$(echo "$status_content" | find_pgp_message)
|
||||
if [ -n "$pgp_crypted" ]; then
|
||||
menu_pgp='\nDecrypt GPG'
|
||||
fi
|
||||
echo "$status_content"
|
||||
attachments=$(echo "$status" | jj -l 'media_attachments.#.remote_url' | delq)
|
||||
menuattachments=
|
||||
if [ -n "$attachments" ]; then
|
||||
echo "#EXTINF:-1, $uri" >> attachments.m3u8
|
||||
echo '[Attachments:]'
|
||||
menuattachments='\nMedia'
|
||||
echo "$attachments" | tee -a attachments.m3u8
|
||||
fi
|
||||
poll=$(echo "$status" | jj poll.id)
|
||||
if [ -n "$poll" ]; then
|
||||
echo '[Poll:]'
|
||||
echo "$(echo "$status" | jj -l 'poll.options.#.title')"
|
||||
fi
|
||||
|
||||
echo "$statuses_separator"
|
||||
if [ "$per_status_mode" = 'true' ]; then
|
||||
next=0
|
||||
force_stop=0
|
||||
while [ "$next" -eq 0 ]; do
|
||||
per_status_menu=$(echo "Next$menuattachments"$menu_pgp"\nFavorite$s_f_menu\nBookmark\nReply$edit_del_menu\nBack" | fzy)
|
||||
case "$per_status_menu" in
|
||||
"Next")
|
||||
next=1
|
||||
clear
|
||||
;;
|
||||
"Decrypt GPG") echo "$pgp_crypted" | gpg -d ;;
|
||||
"Media")
|
||||
for one_media in $attachments; do
|
||||
$default_media_player "$one_media"
|
||||
done
|
||||
;;
|
||||
"Share and favorite") share_and_favorite_mode "$id_status" ;;
|
||||
"Share") share_api_status "$id_status" ;;
|
||||
"Favorite") favorite_api_status "$id_status" ;;
|
||||
"Bookmark") bookmark_api_status "$id_status" ;;
|
||||
"Reply") reply_mode "$id_status" ;;
|
||||
"Edit") reply_mode "$id_status" '1' ;;
|
||||
"Delete") delete_api_status "$id_status" ;;
|
||||
"Back")
|
||||
next=1
|
||||
force_stop=1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
if [ "$force_stop" -eq 1 ]; then break; fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
statuses_view_menu()
|
||||
{
|
||||
sub_menu_lvl=2
|
||||
|
@ -592,42 +475,6 @@ statuses_view_menu()
|
|||
done
|
||||
}
|
||||
|
||||
thread_open()
|
||||
{
|
||||
echo 'Input id'
|
||||
read status_id
|
||||
thread_menu "$status_id"
|
||||
}
|
||||
|
||||
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
|
||||
while [ $sub_menu_lvl -eq 2 ]; do
|
||||
clear
|
||||
echo '[Thread]'
|
||||
ids_massive=$(echo "$jsonthread" | jj -l \#.id | delq)
|
||||
jsonmassive=$jsonthread
|
||||
statuses_render
|
||||
menuthread=$(echo 'Back\nReply\nShare\nFavorite\nShare and favorite' | fzy)
|
||||
case "$menuthread" in
|
||||
"Back") sub_menu_lvl=1 ;;
|
||||
"Reply") reply_mode ;;
|
||||
"Share") share_mode ;;
|
||||
"Favorite") favourite_mode ;;
|
||||
"Share and favorite") share_and_favorite_mode ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
timeline_api()
|
||||
{
|
||||
|
@ -656,45 +503,6 @@ search_api_statuses()
|
|||
timeline='search' timeline_menu
|
||||
}
|
||||
|
||||
timeline_menu()
|
||||
{
|
||||
json=$(timeline_api)
|
||||
sub_menu_lvl=1
|
||||
echo '#EXTM3U' > attachments.m3u8
|
||||
if [ "$per_status_mode" = 'true' ]; then
|
||||
menuentryes='Prev\nNext\nMain menu'
|
||||
else
|
||||
menuentryes='Prev\nNext\nReply\nShare\nFavorite\nShare and favorite\nThread\nMain menu'
|
||||
fi
|
||||
while [ $sub_menu_lvl -eq 1 ]; do
|
||||
ids_massive=$(echo "$json" | jj -l \#.id | delq)
|
||||
jsonmassive=$json
|
||||
statuses_render
|
||||
menu=$(echo "$menuentryes" | fzy)
|
||||
case $menu in
|
||||
"Prev")
|
||||
indexator=$(expr $(echo "$json" | jj \#) - 1)
|
||||
echo '#EXTM3U' > attachments.m3u8
|
||||
clear
|
||||
offset=$(echo "$json" | jj "$indexator".id)
|
||||
json=$(timeline_api "$offset")
|
||||
;;
|
||||
"Next")
|
||||
echo '#EXTM3U' > attachments.m3u8
|
||||
clear
|
||||
offset=$(echo "$json" | jj 0.id)
|
||||
json=$(timeline_api '' "$offset")
|
||||
;;
|
||||
"Reply") reply_mode ;;
|
||||
"Share") share_mode ;;
|
||||
"Favorite") favourite_mode ;;
|
||||
"Share and favorite") share_and_favorite_mode ;;
|
||||
"Thread") thread_open ;;
|
||||
"Main menu") sub_menu_lvl=0 ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
reply_mode()
|
||||
{
|
||||
if [ -n "$1" ]; then
|
||||
|
@ -983,10 +791,14 @@ statuses_auto_update()
|
|||
{
|
||||
while true; do
|
||||
echo "Updating statuses..."
|
||||
timeline='home'
|
||||
export instance
|
||||
timeline_api | ./utils/statuses2files.sh
|
||||
echo "Waiting..."
|
||||
for i in home local direct; do
|
||||
echo "checking timeline $i"
|
||||
timeline="$i"
|
||||
export instance timeline
|
||||
timeline_api | ./utils/statuses2files.sh
|
||||
sleep 3
|
||||
done
|
||||
echo "Sleeping..."
|
||||
sleep 30
|
||||
done
|
||||
}
|
||||
|
@ -1028,6 +840,23 @@ if [ "$daemon_mode" = 'yes' ]; then
|
|||
;;
|
||||
esac
|
||||
fi
|
||||
write_status_action=$(/bin/ls $main_basedir/all_statuses/$instance/create 2>/dev/null)
|
||||
if [ -n "$write_status_action" ]; then
|
||||
dir_write_status=$(dirname "$write_status_action")
|
||||
if [ -d "$dir_status/attachments" ]; then
|
||||
attach_id=''
|
||||
echo "Uploading attachments..."
|
||||
for attach in "$dir_write_status"/attachments/*; do
|
||||
attach_id=$(upload_api_media "@$attach" | jj id)
|
||||
attach_id="${attach_id},"
|
||||
echo $attach_id
|
||||
done
|
||||
mediaattach=$(echo $attach_id | sed 's/,$//g')
|
||||
echo $mediaattach
|
||||
fi
|
||||
write_api_status $dir_write_status/message
|
||||
rm $write_status_action
|
||||
fi
|
||||
done
|
||||
done
|
||||
fi
|
||||
|
|
|
@ -31,4 +31,4 @@ for i in $ids; do
|
|||
done
|
||||
|
||||
export ids
|
||||
echo "$json" | "$main_basedir"/utils/statuses2files_acct.sh
|
||||
echo "$json" | "$main_basedir"/utils/statuses2files_group.sh
|
||||
|
|
|
@ -6,6 +6,7 @@ ids=$(echo "$json" | jj -l '#.id' | sed 's/"//g')
|
|||
|
||||
mkdir -p "$main_basedir/all_statuses/$instance"
|
||||
mkdir -p "$main_basedir/statuses/$instance"
|
||||
mkdir -p "$main_basedir/timelines/$instance/$timeline"
|
||||
|
||||
for i in $ids; do
|
||||
if [ -f "$main_basedir"/all_statuses/$instance/$i/$i.json ]; then
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Move statuses to acct dirs
|
||||
|
||||
json=$(cat)
|
||||
|
||||
for i in $ids; do
|
||||
status_id=$i
|
||||
acct=$(echo "$json" | jj "#[id=$i].account.acct")
|
||||
mkdir -m 711 -p "$main_basedir"/statuses/$instance/$acct
|
||||
if [ -n "$status_id" ]; then
|
||||
ln -s -r "$main_basedir"/all_statuses/$instance/$status_id "$main_basedir"/statuses/$instance/$acct/$status_id
|
||||
touch --reference "$main_basedir"/all_statuses/$instance/$status_id "$main_basedir"/statuses/$instance/$acct/$status_id
|
||||
fi
|
||||
done
|
||||
|
19
utils/statuses2files_group.sh
Executable file
19
utils/statuses2files_group.sh
Executable file
|
@ -0,0 +1,19 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Group statuses by acct and timelines dirs
|
||||
|
||||
json=$(cat)
|
||||
|
||||
for i in $ids; do
|
||||
status_id=$i
|
||||
acct=$(echo "$json" | jj "#[id=$i].account.acct")
|
||||
mkdir -m 711 -p "$main_basedir"/statuses/$instance/$acct
|
||||
if [ -n "$status_id" ]; then
|
||||
ln -s -r "$main_basedir"/all_statuses/$instance/$status_id "$main_basedir"/statuses/$instance/$acct/$status_id
|
||||
touch --reference "$main_basedir"/all_statuses/$instance/$status_id "$main_basedir"/statuses/$instance/$acct/$status_id
|
||||
|
||||
ln -s -r "$main_basedir"/all_statuses/$instance/$status_id "$main_basedir"/timelines/$instance/$timeline/$status_id
|
||||
touch --reference "$main_basedir"/all_statuses/$instance/$status_id "$main_basedir"/timelines/$instance/$timeline/$status_id
|
||||
fi
|
||||
done
|
||||
|
Loading…
Reference in a new issue