This script was written in 2009, when I encountered some problems with twitterfeed.com.
Nowadays, if you want to updates a microblog account from a xml feed, I suggest you use Feed2mb instead.
This script was written in 2009, when I encountered some problems with twitterfeed.com.
Nowadays, if you want to updates a microblog account from a xml feed, I suggest you use Feed2mb instead.
#!/usr/bin/env rc | |
### This script publish status to one microblog from another microblog. | |
# | |
# This script can read any microblog which provides rss feed, and write | |
# to any microblog using the corresponding api. (Currently only support | |
# identi.ca. But adding support to other microblog is very easy.) | |
# For the first time, you should manually download the feed and | |
# specify the date in $workDir/date: | |
# grep -m 1 '<dc:date>' feed > date | |
# Copyright: (c) 2009 Jakukyo Friel <weakish@gmail.com> | |
# License: GPL v2 | |
# config | |
feedAddr=http://example.com/example.rss | |
feedTitle='your twitter' | |
workDir=$home.microBridge | |
auth=username:password | |
# config area ends | |
# seek the line number of the first match | |
# pattern --> line number | |
fn seekln { | |
grep -m 1 -n $* - | cut -f 1 -d : - | |
} | |
# post to identi.ca | |
fn postdent { | |
curl https://identi.ca/api/statuses/update.xml \ | |
-u $auth \ | |
-d status'='$^* | |
} | |
# prepare feed | |
cd $workDir | |
curl $feedAddr > feed | |
# check status | |
endOfNewItem=`{expr `{cat feed | seekln `(cat date)} - 7} | |
# record new status | |
grep -m 1 '<dc:date>' feed > date | |
# split the rss feed | |
cat feed | | |
sed -n 1,`(echo $endOfNewItem)^p | | |
sed -e '/<title>'$feedTitle'<\/title>/d' | | |
sed -n '/<title>/p' | | |
split - -l 1 | |
for (i in `(ls -r x*)) { | |
cat $i | sed -e 's/<title>//' | sed -e 's/<\/title>//' > output.txt | |
postdent `(cat output.txt) | |
sleep 5 | |
} | |
# clean up | |
rm x?? |