SHOW:
|
|
- or go back to the newest paste.
| 1 | #!/bin/bash | |
| 2 | ||
| 3 | now=$(date +"%Y_%m_%d_-_%H_%M_%S" ) # Just setting the date and time | |
| 4 | ||
| 5 | echo "Now pointing the BFTG-9000 at $1" | |
| 6 | gzip -d ~/dox/twitter/timelines/$1.gz 2> /dev/null | |
| 7 | usewithtor /usr/local/bin/twitter-archiver -o -f -s ~/dox/twitter/timelines $1 | |
| 8 | gzip ~/dox/twitter/timelines/$1 2> /dev/null | |
| 9 | ||
| 10 | if [ -f ~/dox/twitter/timelines/$1.gz ] || [ -f ~/dox/twitter/timelines/$1 ]; then | |
| 11 | ||
| 12 | echo "Direct hit! Area damage coming in 3... 2... 1..." | |
| 13 | ||
| 14 | # This section pulls the mentions out of the chosen timeline, places them in a | |
| 15 | # file, formats them so that all the names are lowercase, sorts for uniqueness, | |
| 16 | # and finally removes the @ symbols. It also generates a simple report which | |
| 17 | # shows how many times the target mentioned each account, sorted from most to | |
| 18 | # least number of mentions. | |
| 19 | ||
| 20 | gunzip ~/dox/twitter/timelines/$1.gz 2> /dev/null | |
| 21 | grep -Eo ' @[A-Za-z0-9_]+' ~/dox/twitter/timelines/$1 > ~/dox/twitter/mentions/$1-raw | |
| 22 | tr '[:upper:]' '[:lower:]' < ~/dox/twitter/mentions/$1-raw >> ~/dox/twitter/mentions/$1-alpha | |
| 23 | sort ~/dox/twitter/mentions/$1-alpha | uniq -c > ~/dox/twitter/mentions/$1-mc-alpha | |
| 24 | awk '{print $2,$1}' ~/dox/twitter/mentions/$1-mc-alpha > ~/dox/twitter/mentions/$1-mc-beta
| |
| 25 | sort -grk 2 ~/dox/twitter/mentions/$1-mc-beta > ~/dox/twitter/mentions/$1_mentions_count.txt | |
| 26 | sort -u ~/dox/twitter/mentions/$1-alpha > ~/dox/twitter/mentions/$1.full.txt | |
| 27 | totalMentions=$(wc -l ~/dox/twitter/mentions/$1.full.txt | awk '{print $1}')
| |
| 28 | sort -u ~/dox/twitter/mentions/$1.full.txt > ~/dox/twitter/mentions/$1-beta | |
| 29 | sed -i 's/ @//g' ~/dox/twitter/mentions/$1-beta | |
| 30 | echo "BOOM! Now for the dust to settle..." | |
| 31 | ||
| 32 | # This section pulverizes the data left over from the previous section to | |
| 33 | # create a shell script which will crawl the accounts you don't already | |
| 34 | # have saved. | |
| 35 | ||
| 36 | ls ~/dox/twitter/timelines/ | sort -u > ~/dox/twitter/ls.txt | |
| 37 | sed -i 's/\.gz//'g ~/dox/twitter/ls.txt | |
| 38 | comm -13 ~/dox/twitter/ls.txt ~/dox/twitter/mentions/$1-beta > ~/dox/twitter/mentions/$1-rc 2> /dev/null | |
| 39 | uniqueMentions=$(wc -l ~/dox/twitter/mentions/$1-rc | awk '{print $1}')
| |
| 40 | sed -i -e 's/^/~\/twit.sh /' ~/dox/twitter/mentions/$1-rc | |
| 41 | echo '#!/bin/bash' | cat - ~/dox/twitter/mentions/$1-rc > ~/dox/twitter/mentions/$1-rc.temp | |
| 42 | mv ~/dox/twitter/mentions/$1-rc.temp ~/dox/twitter/mentions_scripts/$1.sh | |
| 43 | #sed '0~11 s/$/\nsleep 900/g' < ~/dox/twitter/mentions/$1-rc > ~/dox/twitter/mentions_scripts/$1.sh # Seems to not be required anymore | |
| 44 | chmod +x ~/dox/twitter/mentions_scripts/$1.sh | |
| 45 | echo "OUCH! Nothing left but their shoes. You have to crawl $uniqueMentions out of $totalMentions accounts. $1 status: demolished, will not recover, etc." | |
| 46 | #rm -rf ~/dox/twitter/mentions/$1-* | |
| 47 | gzip ~/dox/twitter/timelines/$1 2> /dev/null | |
| 48 | echo "Timeline: ~/dox/twitter/timelines/$1" | |
| 49 | echo "Mentions script: ~/dox/twitter/mentions_scripts/$1.sh" | |
| 50 | echo "Time analysis: ~/dox/twitter/times/$1_$now.txt" | |
| 51 | ||
| 52 | else | |
| 53 | ||
| 54 | echo "Oh, fail." | |
| 55 | ||
| 56 | fi | |
| 57 | ||
| 58 | if [ -f ~/dox/twitter/timelines/$1 ]; then | |
| 59 | ||
| 60 | # The section will pull the timestamps from the last 200 tweets, then sort by | |
| 61 | # hour, and tell us how many times the target tweeted during each hour. | |
| 62 | ||
| 63 | echo "###########################################################################" > ~/dox/twitter/times/$1_$now.txt | |
| 64 | echo "# Hours/tweets for $1's last 200 tweets" >> ~/dox/twitter/times/$1_$now.txt | |
| 65 | echo "###########################################################################" >> ~/dox/twitter/times/$1_$now.txt | |
| 66 | ||
| 67 | tail -n 200 ~/dox/twitter/timelines/$1 > ~/dox/twitter/times/$1-tail | |
| 68 | awk '{print $3}' ~/dox/twitter/times/$1-tail > ~/dox/twitter/times/$1-tail-raw
| |
| 69 | sed -i 's/:/ /g' ~/dox/twitter/times/$1-tail-raw | |
| 70 | awk '{print $1}' ~/dox/twitter/times/$1-tail-raw > ~/dox/twitter/times/$1-tail-beta
| |
| 71 | sort ~/dox/twitter/times/$1-tail-beta | uniq -c | awk '{print $2,$1}' >> ~/dox/twitter/times/$1_$now.txt
| |
| 72 | ||
| 73 | # This section does the same as the previous section, except it acts upon | |
| 74 | # the entire collected timeline. | |
| 75 | ||
| 76 | echo "###########################################################################" >> ~/dox/twitter/times/$1_$now.txt | |
| 77 | echo "# Hours/tweets for all of $1's stored tweets" >> ~/dox/twitter/times/$1_$now.txt | |
| 78 | echo "###########################################################################" >> ~/dox/twitter/times/$1_$now.txt | |
| 79 | ||
| 80 | awk '{print $3}' ~/dox/twitter/timelines/$1 > ~/dox/twitter/times/$1-raw
| |
| 81 | sed -i 's/:/ /g' ~/dox/twitter/times/$1-raw | |
| 82 | awk '{print $1}' ~/dox/twitter/times/$1-raw > ~/dox/twitter/times/$1-beta
| |
| 83 | sort ~/dox/twitter/times/$1-beta | uniq -c | awk '{print $2,$1}' >> ~/dox/twitter/times/$1_$now.txt
| |
| 84 | rm -rf ~/dox/twitter/times/$1-* | |
| 85 | fi |