Merge pull request #20 from bnrubin/master
authorOrakaro <nhatminh_179@hotmail.com>
Sun, 20 Jul 2014 10:11:33 +0000 (19:11 +0900)
committerOrakaro <nhatminh_179@hotmail.com>
Sun, 20 Jul 2014 10:11:33 +0000 (19:11 +0900)
Unescape HTML entities & grab full retweet text

rainbowstream/draw.py
rainbowstream/py3patch.py

index 96d2657..f23e4ca 100644 (file)
@@ -20,6 +20,11 @@ db = RainbowDB()
 g = {}
 
 
+def unescape(s):
+    p = HTMLParser()
+    return p.unescape(s)
+
+
 def init_cycle():
     """
     Init the cycle
@@ -156,6 +161,15 @@ def draw(t, iot=False, keyword=None, check_semaphore=False, fil=[], ig=[]):
     date = date - datetime.timedelta(seconds=time.timezone)
     clock = date.strftime('%Y/%m/%d %H:%M:%S')
 
+    # Pull extended retweet text
+    try:
+        text = 'RT @{0}: {1}'.format(t['retweeted_status']['user']['screen_name'],
+                                     t['retweeted_status']['text'])
+    except:
+        pass
+
+    text = unescape(text)
+
     # Get expanded url
     try:
         expanded_url = []
@@ -267,7 +281,7 @@ def print_message(m):
     """
     sender_screen_name = '@' + m['sender_screen_name']
     sender_name = m['sender']['name']
-    text = m['text']
+    text = unescape(m['text'])
     recipient_screen_name = '@' + m['recipient_screen_name']
     recipient_name = m['recipient']['name']
     mid = m['id']
@@ -453,4 +467,4 @@ def print_list(group):
 
 
 # Start the color cycle
-start_cycle()
\ No newline at end of file
+start_cycle()
index 05fe7ff..6042984 100644 (file)
@@ -9,6 +9,13 @@ try:
 except:
     from io import StringIO, BytesIO
 
+# HTMLParser module
+
+try:
+    from HTMLParser import HTMLParser
+except:
+    from html.parser import HTMLParser
+
 # raw_input and map functiion behaviour
 if sys.version[0] == "3":
     raw_input = input