pleroma-cli/utils/statuses2files.sh

30 lines
1,002 B
Bash
Raw Normal View History

#!/bin/sh
# convert statuses as files and dirs
json="$(cat)"
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
ids=$(echo "$ids" | sed -E "s/.?$i.?//g")
2022-08-05 16:09:45 +00:00
continue
2022-08-07 10:11:44 +00:00
elif [ -n "$(7z e -so $main_basedir/archives/$instance.7z $i | cat)" ]; then
ids=$(echo "$ids" | sed -E "s/.?$i.?//g")
continue
elif [ -d "$main_basedir"/all_statuses/$instance/$i ]; then
ids=$(echo "$ids" | sed -E "s/.?$i.?//g")
continue
fi
status_date=$(echo "$json" | jj "#[id=$1].created_at")
mkdir -m 711 -p "$main_basedir"/all_statuses/$instance/$i
touch -d "$status_date" "$main_basedir"/all_statuses/$instance/$i
echo "$json" | jj -p "#[id=$i]" > "$main_basedir"/all_statuses/$instance/$i/$i.json
done
2022-08-05 16:09:45 +00:00
export ids
echo "$json" | "$main_basedir"/utils/extract_fields_statuses.sh