tutorialseri.sh 866 B

1234567891011121314151617181920212223
  1. #!/bin/bash
  2. tmpdir="/tmp/wikihow"
  3. wikihow="www.wikihow.it"
  4. MASTODON_TOKEN=""
  5. if (( $RANDOM % 2 ))
  6. then
  7. wikihow="www.wikihow.com"
  8. fi
  9. randurl="https://$wikihow/Special:Randomizer"
  10. mkdir "$tmpdir"
  11. title=$(curl --silent -L "$randurl" | grep "<title" | cut -d ">" -f 2 | cut -d "<" -f 1 | cut -d ':' -f 1 | sed 's/ \- wikiHow//')
  12. echo $title > "$tmpdir/title"
  13. for i in $(seq 1 4)
  14. do
  15. image=$(curl --silent -L "$randurl" | grep "<noscript><img alt" | sed 's/src/\nsrc/' | grep http | cut -d '"' -f 2 | sort | uniq | shuf | head -n 1)
  16. wget -O "$tmpdir/$i.jpg" "$image"
  17. done
  18. magick montage -title "$(cat "$tmpdir/title")" -geometry 300x300+0+0 $(ls $tmpdir/*.jpg) "$tmpdir/out.png"
  19. toot -t="$MASTODON_TOKEN" -i="$tmpdir/out.png" $(cat "$tmpdir/title") "#howto #diy" "$(cat $tmpdir/title | sed 's/ /\n/g' | sed 's/^/#/' | shuf | tail -n1)"
  20. rm -rf "$tmpdir"