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 96d26577dd063df7ddd1f94b2f4acd23f6434dc2..f23e4cacd70d8ab9558573289590a924673e3a8e 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 05fe7ff469cba4ce2fc2307143dfba37000e2465..604298411069fd7f6c0a678f09928c24c38ba004 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