why did I make this
This commit is contained in:
commit
b701f5d6ac
11
Makefile
Normal file
11
Makefile
Normal file
|
@ -0,0 +1,11 @@
|
|||
cookie: dril.dat
|
||||
fortune dril
|
||||
|
||||
dril.html:
|
||||
wget -O $@ https://cooltweets.herokuapp.com/dril/old
|
||||
|
||||
dril: dril.html
|
||||
./mkfortunes.sh > dril
|
||||
|
||||
dril.dat: dril
|
||||
strfile dril
|
4
README.md
Normal file
4
README.md
Normal file
|
@ -0,0 +1,4 @@
|
|||
dril tweet source: https://cooltweets.herokuapp.com/dril/old
|
||||
|
||||
Use this cursed thing by running `fortune dril` (or `make`) in this dir.
|
||||
To add new posts, remove `dril.html` and re-run `make`.
|
22
mkfortunes.sh
Executable file
22
mkfortunes.sh
Executable file
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
lines=$(cat dril.html |\
|
||||
# war crimes
|
||||
grep "<div class='text'>" | sed -e "s%<div class='text'>\(.*\)</div>%\1%" |\
|
||||
# remove links
|
||||
grep -vE 'https?://' |\
|
||||
# remove RTs and replies (but not inline @'s)
|
||||
grep -v -e '^RT @' -e '^@' |\
|
||||
# unescape html entities
|
||||
sed -e 's/\&/\&/g' -e 's/</</g' -e 's/>/>/g'
|
||||
)
|
||||
total=$(echo -n "$lines" | wc -l)
|
||||
at=1
|
||||
while read tweet; do
|
||||
echo $tweet | sed 's%<br />%\n%g'
|
||||
echo " -- dril"
|
||||
echo %
|
||||
|
||||
(( at++ ))
|
||||
>&2 echo -ne "\rProcessed: $at / $total"
|
||||
done <<< "$lines"
|
Loading…
Reference in a new issue