Initial commit (moved files from gitorious.org to here)
[pumpscripts.git] / pumpfollowing.sh
blobff55c6f5fc889bf800f6094a4329077169417f3c
1 # (c) 2014 Laura Arjona Reina (larjona@larjona.net)
2 # This script is in Public Domain
3 # Use at your own risk
5 #!/bin/bash
7 ## EDIT OPTIONS ##
8 PF_I=0
9 PF_TOTALMESSAGES=810
10 PF_COUNT=1
11 PF_SERVER=pumprock.net
12 PF_USER=poetas
13 PF_COOKIE= 'XXXXYYYYZZZ'
14 PF_WORKINGDIR=/home/username/backups/pumpfollowing
15 PF_DTE=$(date +%Y%m%d)
17 ## END EDIT OPTIONS ##
19 cd $PF_WORKINGDIR
20 touch $PF_SERVER_$PF_USER_following_$PF_DTE.txt
21 mkdir $PF_DTE
22 cd $PF_DTE
25 while [ $i -le $PF_TOTALMESSAGES ]
27 echo "wgetting $PF_COUNT items beginning with number $i..."
28 echo $PF_COOKIE
29 wget -O "$PF_I.json" --no-cookies --header 'cookie: connect.sid=XXXXYYYYZZZZ' "https://$PF_SERVER/api/user/$PF_USER/following?count=$PF_COUNT&offset=$PF_I"
31 echo "extracting name of account for txt listing"
32 cat $PF_I.json | tr ',' '\n' | grep acct -m 1 >> $PF_SERVER_$PF_USER_following_$PF_DTE.txt
34 PF_I=`expr $PF_I + $PF_COUNT`
35 echo $PF_I
36 #sleep 3
37 done
39 cd ..
40 tar zcf ../$PF_SERVER_$PF_USER_following_$PF_DTE.tar.gz $PF_DTE/
41 rm $PF_DTE/*.json
42 rm $PF_DTE/*.txt
43 rmdir $PF_DTE
45 exit 0