]> git.armaanb.net Git - bin.git/commitdiff
tweet-cgi: convert to CGI script from tweet-grab
authorArmaan Bhojwani <me@armaanb.net>
Sun, 30 May 2021 17:30:13 +0000 (13:30 -0400)
committerArmaan Bhojwani <me@armaanb.net>
Sun, 30 May 2021 17:31:51 +0000 (13:31 -0400)
tweet-cgi [new file with mode: 0755]
tweet-grab [deleted file]

diff --git a/tweet-cgi b/tweet-cgi
new file mode 100755 (executable)
index 0000000..d63f8f3
--- /dev/null
+++ b/tweet-cgi
@@ -0,0 +1,12 @@
+#!/usr/bin/env sh
+# Grabs a tweet form a user and display it. Avoids using the twitter
+# API by scrapping a nitter instance, which can easily be scraped,
+# unlike the intentionally crippled twitter.com. Powers
+# https://ishaan.bhojwani.org
+
+INSTANCE=${INSTANCE:-https://nitter.fdn.fr}
+USER=${USER:-keshinko}
+
+printf "Content-type: text/plain\n\n"
+curl -s "$INSTANCE/$USER" | grep tweet-content | head -n 1 \
+               | sed -e 's/<[^>]*>//g' -e 's/^[ \t]*\(.*$\)/\1/'
diff --git a/tweet-grab b/tweet-grab
deleted file mode 100755 (executable)
index b711bb1..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/usr/bin/env sh
-# Grabs tweets and writes them to a file. Avoids using the twitter API by
-# scrapping nitter.net (or any other nitter instance) which can easily be
-# scraped, unlike the intentionally crippled twitter.com. See the output of
-# this script at https://ishaan.bhojwani.org
-
-FILE=/root/tweets/index.html
-LOGFILE=/root/tweets/cron.log
-INSTANCE=https://nitter.fdn.fr
-
-curl $INSTANCE/keshinko | grep tweet-content | head -n 1 \
-               | sed -e 's/<[^>]*>//g' -e 's/^[ \t]*\(.*$\)/\1/' > $FILE
-date -R > $LOGFILE