Browse files

added link_cache from last set of displayed tweets and shell script t…

…o open in default browser
  • Loading branch information...
1 parent fb6ae50 commit 396987b80184bc60a5f1b084106f8050a86dbd32 Hilary Mason committed Aug 12, 2010
Showing with 25 additions and 0 deletions.
  1. +3 −0 ol
  2. +22 −0 t.py
View
3 ol
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+cat link_cache | xargs open
View
22 t.py
@@ -72,13 +72,35 @@ def load_tweets(self, num, sort='time',mark_read=True):
if t['user'] in self.settings['whitelist_users']:
t['_display'] = True
+
+ # cache any links in these tweets so I can get to them easily
+ self.extract_links(tweets)
return tweets
+ def extract_links(self, tweets):
+ """
+ extract_links: pull links out of tweets and cache in a text file
+ """
+ re_http = re.compile("(http|https):\/\/(([a-z0-9\-]+\.)*([a-z]{2,5}))\/\w+")
+ links = []
+ for t in tweets:
+ r = re_http.search(t['text'])
+ if r:
+ links.append(r.group(0))
+
+ if links:
+ f = open(self.settings['link_cache_filename'], 'w')
+ for link in links:
+ f.write('%s\n' % link)
+ f.close()
+
+
def load_settings(self):
settings = {}
settings['topic_thresholds'] = {'default': .6, 'betaworks': 1.0, 'narcissism': .25 }
+ settings['link_cache_filename'] = 'link_cache'
f = open('whitelist_users', 'r')
settings['whitelist_users'] = [user.strip() for user in f.readlines()]

0 comments on commit 396987b

Please sign in to comment.