Browse Source

tutorialadd

encrypt 3 years ago
commit
f4280be056
1 changed files with 23 additions and 0 deletions
  1. 23 0
      tutorialseri/tutorialseri.sh

+ 23 - 0
tutorialseri/tutorialseri.sh

@@ -0,0 +1,23 @@
+#!/bin/bash
+tmpdir="/tmp/wikihow"
+wikihow="www.wikihow.it"
+MASTODON_TOKEN=""
+if (( $RANDOM % 2 ))
+then
+    wikihow="www.wikihow.com"
+fi
+randurl="https://$wikihow/Special:Randomizer"
+mkdir "$tmpdir"
+title=$(curl --silent -L "$randurl" | grep "<title" |  cut -d ">" -f 2 | cut -d "<" -f 1 | cut -d ':' -f 1 | sed 's/ \- wikiHow//')
+echo $title > "$tmpdir/title"
+
+for i in $(seq 1 4)
+do
+    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)
+    wget -O "$tmpdir/$i.jpg" "$image"
+done
+
+magick montage -title "$(cat "$tmpdir/title")" -geometry 300x300+0+0  $(ls $tmpdir/*.jpg)  "$tmpdir/out.png"
+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)"
+
+rm -rf "$tmpdir"