#!/bin/rc # rss: print new links in rss/twitter feeds rfork e feeds=$home/lib/rss dir=/tmp/rss tmp=$dir/rss.$pid fn name{ switch($1){ case http* #echo $1 | sed 's!.*://([^/]+).*!\1!' echo $1 | sed 's!/!%2F!g' case * echo $1 } } fn urls{ sed -n 's!.*(http[^<]+).*!\1!p' } fn tids{ sed -n 's!.*data-id="([0-9]+)".*!\1!p' } fn links{ switch($1){ case http* hget $1 | urls case * hget https://mobile.twitter.com/$1 | tids | sed -n 's!^([0-9]+)$!https://twitter.com/'$1'/status/\1!p' } } if(~ $#* 0){ *=`{cat $feeds >[2]/dev/null} if(~ $#* 0){ echo no feeds >[1=2] exit } } mkdir -p $dir for(i){ f=$dir/`{name $i} echo $i' '$f >[1=2] if(test -e $f){ cp -x $f $tmp if(links $i >$f){ comm -23 <{sort $f} <{sort $tmp} rm $tmp } if not mv $tmp $f } if not if(! links $i >$f) rm $f }