gen_includes.sh 586 B

123456789101112131415161718192021222324252627282930
  1. #!/bin/bash
  2. # This required jq and wget
  3. DAY=$((60 * 60 * 24))
  4. # Remove instances.json when it's older then 1 day
  5. if [ -f "instances.json" ]; then
  6. NOW=$(date "+%s")
  7. THEN=$(date -r "instances.json" "+%s")
  8. DELTA=$((NOW - THEN))
  9. if [ $DELTA -gt $DAY ]; then
  10. echo "YES"
  11. rm "instances.json"
  12. fi
  13. fi
  14. # Get new instances.json
  15. if [ ! -f "instances.json" ]; then
  16. wget "https://api.invidious.io/instances.json"
  17. fi
  18. # Process
  19. while IFS= read -r line
  20. do
  21. URL="${line:1:-1}"
  22. echo "// @include https://$URL/*"
  23. done <<< $(jq ".[][0]" instances.json | grep -v ".onion\|.i2p")