- twitter is https only now
authorYves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
Wed, 05 Oct 2011 13:39:57 +0200
changeset 290 2ddd11ec2da2
parent 289 a5eff8f2b81d
child 291 db1e6bfaa54e
child 305 436a31d11f1d
- twitter is https only now - add a way to pass an alternate twitter url
script/lib/tweetstream/tweetstream/streamclasses.py
script/stream/recorder_tweetstream.py
--- a/script/lib/tweetstream/tweetstream/streamclasses.py	Thu Sep 22 12:37:53 2011 +0200
+++ b/script/lib/tweetstream/tweetstream/streamclasses.py	Wed Oct 05 13:39:57 2011 +0200
@@ -180,11 +180,11 @@
 
 
 class SampleStream(BaseStream):
-    url = "http://stream.twitter.com/1/statuses/sample.json"
+    url = "https://stream.twitter.com/1/statuses/sample.json"
 
 
 class FilterStream(BaseStream):
-    url = "http://stream.twitter.com/1/statuses/filter.json"
+    url = "https://stream.twitter.com/1/statuses/filter.json"
 
     def __init__(self, auth, follow=None, locations=None,
                  track=None, catchup=None, url=None, as_text=False):
--- a/script/stream/recorder_tweetstream.py	Thu Sep 22 12:37:53 2011 +0200
+++ b/script/stream/recorder_tweetstream.py	Wed Oct 05 13:39:57 2011 +0200
@@ -1,7 +1,7 @@
 from getpass import getpass
 from iri_tweet import models, utils
 from iri_tweet.models import TweetSource, TweetLog, ProcessEvent
-from multiprocessing import (Queue as mQueue, JoinableQueue, Process, Event,
+from multiprocessing import (Queue as mQueue, JoinableQueue, Process, Event, 
     get_logger)
 from optparse import OptionParser
 from sqlalchemy.exc import OperationalError
@@ -187,7 +187,7 @@
         track_list = [k for k in track_list.split(',')]
 
         self.logger.debug("SourceProcess : before connecting to stream " + repr(track_list))                        
-        stream = ReconnectingTweetStream(self.auth, track_list, reconnects=self.reconnects, as_text=True)
+        stream = ReconnectingTweetStream(self.auth, track_list, reconnects=self.reconnects, as_text=True, url=self.options.url)
         self.logger.debug("SourceProcess : after connecting to stream")
         stream.muststop = lambda: self.stop_event.is_set()
         
@@ -343,6 +343,9 @@
                       help="Duration of recording in seconds", metavar="DURATION", default= -1, type='int')
     parser.add_option("-N", "--nb-process", dest="process_nb",
                       help="number of process.\nIf 0, only the lefovers of the database are processed.\nIf 1, no postprocessing is done on the tweets.", metavar="PROCESS_NB", default=2, type='int')
+    parser.add_option("--url", dest="url",
+                      help="The twitter url to connect to.", metavar="URL", default=tweetstream.FilterStream.url)
+
 
     utils.set_logging_options(parser)