12345678910111213141516171819202122232425262728293031323334353637 |
- #!/bin/sh
- # convert statuses as files and dirs
- json="$(cat)"
- ids=$(echo "$json" | jj -l '#.id' | sed 's/"//g')
- notload_reblogs=$(jj -i "$main_basedir"/config.json notload_reblogs)
- 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")
- continue
- elif [ -n "$(unzip -p $main_basedir/archives/$instance.zip "**/$i.json")" ]; 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")
- reblog_id=$(echo "$json" | jj "#[id=$1].reblog.id")
- if [ "$notload_reblogs" = 'true' ] && [ -n "$reblog_id" ]; then
- ids=$(echo "$ids" | sed -E "s/.?$i.?//g")
- continue
- fi
- 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
- export ids
- echo "$json" | "$main_basedir"/utils/extract_fields_statuses.sh
|