Unescape HTML entities in tweets and messages
authorBenjamin Rubin <bnrubin@gmail.com>
Sun, 20 Jul 2014 00:00:58 +0000 (20:00 -0400)
committerBenjamin Rubin <bnrubin@gmail.com>
Sun, 20 Jul 2014 00:00:58 +0000 (20:00 -0400)
rainbowstream/draw.py
rainbowstream/py3patch.py

index 96d26577dd063df7ddd1f94b2f4acd23f6434dc2..66c2483b957e87f33c008e5e5b92457db14159be 100644 (file)
@@ -20,6 +20,11 @@ db = RainbowDB()
 g = {}
 
 
 g = {}
 
 
+def unescape(s):
+    p = HTMLParser()
+    return p.unescape(s)
+
+
 def init_cycle():
     """
     Init the cycle
 def init_cycle():
     """
     Init the cycle
@@ -147,7 +152,7 @@ def draw(t, iot=False, keyword=None, check_semaphore=False, fil=[], ig=[]):
     check_theme()
     # Retrieve tweet
     tid = t['id']
     check_theme()
     # Retrieve tweet
     tid = t['id']
-    text = t['text']
+    text = unescape(t['text'])
     screen_name = t['user']['screen_name']
     name = t['user']['name']
     created_at = t['created_at']
     screen_name = t['user']['screen_name']
     name = t['user']['name']
     created_at = t['created_at']
@@ -267,7 +272,7 @@ def print_message(m):
     """
     sender_screen_name = '@' + m['sender_screen_name']
     sender_name = m['sender']['name']
     """
     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']
     recipient_screen_name = '@' + m['recipient_screen_name']
     recipient_name = m['recipient']['name']
     mid = m['id']
@@ -453,4 +458,4 @@ def print_list(group):
 
 
 # Start the color cycle
 
 
 # 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
 
 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
 # raw_input and map functiion behaviour
 if sys.version[0] == "3":
     raw_input = input