Automagically remove trending hashtags in Tweetie

Posted

The Problem

Following a bunch of really funny people on Twitter helps get me through the day sometimes. Other times, tired hashtag memes like #oneletteroffmovies often go on for way too long. The longer it goes on, the less funny it is, yet more people want to get involved. While there’s really nothing wrong with that, it just gets old when all 175 of the folks you follow jump on the bandwagon.

The Solution

The latest version of Tweetie for Mac has a nice, sorta-undocumented feature that causes it to completely omit any tweets that contain specific terms that you specify. This is done on the command line thusly:

defaults write com.atebits.tweetie-mac filterTerms -array-add #hashtagabuse

Occasionally, hashtag memes pop up a few times a day, so typing that for each one that overtakes your tweet stream gets a little tedious. That’s why I wrote a bash script to pull the current trending topics list from Twitter and subsequently tell Tweetie to filter out any hashtags that appear on that list.

Here is that script.

#!/bin/bash
TRENDING_HASHTAGS=`curl -s http://search.twitter.com/trends.json | jsonpretty | sed -e 's/ *"name": "#\([^"]*\)",/#\1/g' | grep '^#'`

for i in $TRENDING_HASHTAGS
do
  LOCAL_MATCHES=`defaults read com.atebits.tweetie-mac filterTerms | grep -ci "\"$i\""`
  if [ "0" == "$LOCAL_MATCHES" ]
  then
    echo Adding filter for $i
    defaults write com.atebits.tweetie-mac filterTerms -array-add \"$i\"
  fi
done

You’ll see output if something is added to the filter list:

brian@moonbus:~/bin$ ./killhashtags
Adding filter for #FamousHoodQuotes
Adding filter for #MusicMonday
Adding filter for #mm
Adding filter for #worldsthinnestbooks
Adding filter for #goodtimes

Bash is quite flexible, so feel free to tweak to your liking in case you want to see #FF / #FollowFriday tweets, or any other hashtags that may trend regularly. If you’re as much of a hashtag abuse crusader as I am, you might put this into a cron job.

The Caveats

There does not appear to be any kind of AppleScript command to tell Tweetie to reload the filter list, so you must restart Tweetie for changes to the filter list to take effect.

Also, I have no idea if jsonpretty comes bundled with every Mac, or if it’s something that gets installed with Xcode. I have Xcode on all of my Macs, so I can’t verify if it comes standard. Worst case scenario is you download and compile it yourself (quite simple), or suggest a better sed/grep manipulation on line 2 so that jsonpretty is not necessary.

Comments

Nobody has posted any comments yet. Be the first!