stream config
authorVu Nhat Minh <vunhat_minh@dwango.co.jp>
Wed, 2 Jul 2014 08:26:15 +0000 (17:26 +0900)
committerVu Nhat Minh <vunhat_minh@dwango.co.jp>
Wed, 2 Jul 2014 08:26:15 +0000 (17:26 +0900)
rainbowstream/colorset/default.json
rainbowstream/config.py
rainbowstream/rainbow.py

index 7d7aad7dab2f4298e6373ad2a755c8f209bc245d..bb9ff1c57ede83273d8bbb33626f69bd72b400e1 100644 (file)
     // Image config
     "IMAGE_SHIFT" : "10",
     "IMAGE_MAX_HEIGHT" : "40",
+    // Stream config
+    "USER_DOMAIN" : "userstream.twitter.com",
+    "PUBLIC_DOMAIN" : "stream.twitter.com",
+    "SITE_DOMAIN" : "sitestream.twitter.com",
 
     // Color config
     "TWEET" : {
index 55fea3cbaa11c7753e2c781f19ab06f22b38148c..e2937ca329dceeeab2e4b6e7fc6fbf89aaa89f19 100644 (file)
@@ -1,6 +1,8 @@
 import json
+import re
 import os
 import os.path
+from twitter.util import printNicely
 
 # Regular expression for comments
 comment_re = re.compile(
@@ -22,6 +24,12 @@ def load_config(filepath):
     except:
         pass
 
+DOMAIN = USER_DOMAIN
+
+# Image config
+IMAGE_SHIFT = 10
+IMAGE_MAX_HEIGHT = 40
+
 # Load colorset
 default_config = 'rainbowstream/colorset/default.json'
 rainbow_config = os.environ.get('HOME', os.environ.get('USERPROFILE','')) + os.sep + '.rainbow_config.json'
index bc791b405401bfa506d8668e75f859bed79942ca..e6488f08e8d383a8989ec583b5932ad5809a928d 100644 (file)
@@ -1074,23 +1074,27 @@ def stream(domain, args, name='Rainbow Stream'):
             tweet_iter = stream.statuses.sample()
 
     # Iterate over the stream.
-    for tweet in tweet_iter:
-        if tweet is None:
-            printNicely("-- None --")
-        elif tweet is Timeout:
-            printNicely("-- Timeout --")
-        elif tweet is HeartbeatTimeout:
-            printNicely("-- Heartbeat Timeout --")
-        elif tweet is Hangup:
-            printNicely("-- Hangup --")
-        elif tweet.get('text'):
-            draw(
-                t=tweet,
-                iot=args.image_on_term,
-                keyword=args.track_keywords,
-                fil=args.filter,
-                ig=args.ignore,
-            )
+    try:
+        for tweet in tweet_iter:
+            if tweet is None:
+                printNicely("-- None --")
+            elif tweet is Timeout:
+                printNicely("-- Timeout --")
+            elif tweet is HeartbeatTimeout:
+                printNicely("-- Heartbeat Timeout --")
+            elif tweet is Hangup:
+                printNicely("-- Hangup --")
+            elif tweet.get('text'):
+                draw(
+                    t=tweet,
+                    iot=args.image_on_term,
+                    keyword=args.track_keywords,
+                    fil=args.filter,
+                    ig=args.ignore,
+                )
+    except:
+        printNicely(magenta("I'm afraid we have problem with twitter'S maximum connection."))
+        printNicely(magenta("Let's try again later."))
 
 
 def fly():