Added filtering by locations to the streaming API.
authorSam Kaufman <emrysk@gmail.com>
Wed, 16 Jun 2010 06:26:14 +0000 (14:26 +0800)
committerJoshua Roesslein <jroesslein@gmail.com>
Sat, 18 Sep 2010 03:14:13 +0000 (11:14 +0800)
tweepy/streaming.py

index 261fb11e447b66942cbec9526ee721d5e05028e4..30f5faa1c348472085d6bf25db72c2d3a444b4f7 100644 (file)
@@ -180,7 +180,7 @@ class Stream(object):
             self.url += '&count=%s' % count
         self._start(async)
 
-    def filter(self, follow=None, track=None, async=False):
+    def filter(self, follow=None, track=None, async=False, locations=None):
         params = {}
         self.headers['Content-type'] = "application/x-www-form-urlencoded"
         if self.running:
@@ -190,6 +190,9 @@ class Stream(object):
             params['follow'] = ','.join(map(str, follow))
         if track:
             params['track'] = ','.join(map(str, track))
+        if locations and len(locations) > 0:
+            assert len(locations) % 4 == 0
+            params['locations'] = ','.join(map(str, locations))
         self.body = urllib.urlencode(params)
         self._start(async)