forked from dustin/twitty-twister
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Twitter: add list_timeline and example
Signed-off-by: Bogdano Arendartchuk <debogdano@gmail.com>
- Loading branch information
Showing
2 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/usr/bin/env python | ||
""" | ||
Copyright (c) 2008 Dustin Sallings <dustin@spy.net> | ||
Copyright (c) 2009 Bogdano Arendartchuk <debogdano@gmail.com> | ||
""" | ||
|
||
import os | ||
import sys | ||
|
||
sys.path.append(os.path.join(sys.path[0], '..', 'twittytwister')) | ||
sys.path.append('twittytwister') | ||
|
||
from twisted.internet import reactor, protocol, defer, task | ||
|
||
import twitter | ||
|
||
fetchCount = 0 | ||
|
||
@defer.deferredGenerator | ||
def getSome(tw, list_user, list_name): | ||
global fetchCount | ||
fetchCount = 0 | ||
|
||
def gotEntry(msg): | ||
global fetchCount | ||
fetchCount += 1 | ||
sys.stdout.write(msg.text.encode("utf8") + "\n") | ||
|
||
page = 1 | ||
while True: | ||
fetchCount = 0 | ||
sys.stderr.write("Fetching page %d for %s/%s\n" % (page, list_user, | ||
list_name)) | ||
d = tw.list_timeline(gotEntry, list_user, list_name, | ||
{'count': '200', 'page': str(page)}) | ||
page += 1 | ||
wfd = defer.waitForDeferred(d) | ||
yield wfd | ||
wfd.getResult() | ||
|
||
if fetchCount == 0: | ||
reactor.stop() | ||
|
||
user = sys.argv[1] | ||
list_user = sys.argv[3] | ||
list_name = sys.argv[4] | ||
|
||
tw = twitter.Twitter(sys.argv[1], sys.argv[2]) | ||
|
||
defer.maybeDeferred(getSome, tw, list_user, list_name) | ||
|
||
reactor.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters