extract_fields_statuses.sh 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. #!/bin/sh
  2. # Extract fields from statuses
  3. json=$(cat)
  4. for i in $ids; do
  5. # Required fields
  6. status_id=$(echo "$json" | jj "#[id=$i].id")
  7. status_date=$(echo "$json" | jj "#[id=$i].created_at")
  8. # Fields
  9. content=$(echo "$json" | jj "#[id=$i].content" | "$main_basedir"/utils/html_to_txt_render)
  10. status_media_attachments=$(echo "$json" | jj -l "#[id=$i].media_attachments.#.url" | tr -d '"\v')
  11. reblog=$(echo "$json" | jj -l "#[id=$i].reblog.id")
  12. chmod 711 "$main_basedir"/all_statuses/$instance/$status_id
  13. if [ -n "$content" ]; then
  14. echo "$content" > "$main_basedir"/all_statuses/$instance/$status_id/content
  15. fi
  16. if [ -n "$status_media_attachments" ]; then
  17. echo "$status_media_attachments" > "$main_basedir"/all_statuses/$instance/$status_id/media_attachments.m3u8
  18. fi
  19. if [ -n "$reblog" ]; then
  20. echo "$reblog" > "$main_basedir"/all_statuses/$instance/$status_id/reblog.id
  21. fi
  22. chmod 600 "$main_basedir"/all_statuses/$instance/$status_id/*
  23. touch -d "$status_date" "$main_basedir"/all_statuses/$instance/$status_id/*
  24. done
  25. export ids
  26. echo "$json" | "$main_basedir"/utils/statuses2files_group.sh