Statuses separated by instance; some fixes

This commit is contained in:
localhost_frssoft 2022-08-05 17:09:52 +03:00
parent f66721780c
commit 39e7196839
3 changed files with 11 additions and 18 deletions

View file

@ -439,8 +439,8 @@ statuses_render()
if [ "$reversed_statuses" = 'true' ]; then if [ "$reversed_statuses" = 'true' ]; then
ids_massive=$(echo "$ids_massive" | tr ' ' '\n' | tac | tr '\n' ' ') ids_massive=$(echo "$ids_massive" | tr ' ' '\n' | tac | tr '\n' ' ')
fi fi
export instance
echo "$jsonmassive" | ./utils/statuses2files.sh echo "$jsonmassive" | ./utils/statuses2files.sh
./utils/extract_text_content.sh
for i in $ids_massive; do for i in $ids_massive; do
status=$(echo "$jsonmassive" | jj "#[id=$i]") status=$(echo "$jsonmassive" | jj "#[id=$i]")
reblog=$(echo "$status" | jj reblog.id) reblog=$(echo "$status" | jj reblog.id)

View file

@ -1,12 +0,0 @@
#!/bin/sh
# Extract some content from statuses
for i in "$main_basedir"/statuses/*/*.json; do
content=$(jj -i $i content | "$main_basedir"/utils/html_to_txt_render)
status_id=$(jj -i $i 'id')
status_date=$(jj -i $i 'created_at')
touch -d "$status_date" "$main_basedir"/statuses/$status_id
jj -i $i content | "$main_basedir"/utils/html_to_txt_render > "$main_basedir"/statuses/$status_id/content
chmod 600 "$main_basedir"/statuses/$status_id/content
done

View file

@ -3,12 +3,17 @@
# convert statuses as files and dirs # convert statuses as files and dirs
json="$(cat)" json="$(cat)"
ids=$(echo "$json" | jj -l '#.id' | sed 's/"//g') ids=$(echo "$json" | jj -l '#.id' | sed 's/"//g')
if [ ! -d "$main_basedir/statuses/$instance" ]; then
mkdir -p "$main_basedir/statuses/$instance"
fi
for i in $ids; do for i in $ids; do
if [ -f "$main_basedir"/statuses/$i.json ]; then if [ -f "$main_basedir"/statuses/$instance/$i.json ]; then
continue continue
fi fi
mkdir -m 711 -p "$main_basedir"/statuses/$i mkdir -m 711 -p "$main_basedir"/statuses/$instance/$i
echo "$json" | jj -p "#[id=$i]" > "$main_basedir"/statuses/$i/$i.json echo "$json" | jj -p "#[id=$i]" > "$main_basedir"/statuses/$instance/$i/$i.json
chmod 600 "$main_basedir"/statuses/$i/$i.json chmod 600 "$main_basedir"/statuses/$instance/$i/$i.json
done done
"$main_basedir"/utils/extract_text_content.sh "$main_basedir"/utils/extract_fields_statuses.sh