projects
/
rainbowstream.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
check search result size and show min(len(result), count).
[rainbowstream.git]
/
rainbowstream
/
rainbow.py
diff --git
a/rainbowstream/rainbow.py
b/rainbowstream/rainbow.py
index a499f957bf519875b062352368eb7a1724af299f..2056c32c1528b43c34984b4b0045bcf9f6687a44 100644
(file)
--- a/
rainbowstream/rainbow.py
+++ b/
rainbowstream/rainbow.py
@@
-330,7
+330,9
@@
def home():
num = c['HOME_TWEET_NUM']
if g['stuff'].isdigit():
num = int(g['stuff'])
num = c['HOME_TWEET_NUM']
if g['stuff'].isdigit():
num = int(g['stuff'])
- for tweet in reversed(t.statuses.home_timeline(count=num)):
+ kwargs = {'count': num}
+ kwargs = add_tweetmode_parameter(kwargs)
+ for tweet in reversed(t.statuses.home_timeline(**kwargs)):
draw(t=tweet)
printNicely('')
draw(t=tweet)
printNicely('')
@@
-355,7
+357,9
@@
def mentions():
num = c['HOME_TWEET_NUM']
if g['stuff'].isdigit():
num = int(g['stuff'])
num = c['HOME_TWEET_NUM']
if g['stuff'].isdigit():
num = int(g['stuff'])
- for tweet in reversed(t.statuses.mentions_timeline(count=num)):
+ kwargs = {'count': num}
+ kwargs = add_tweetmode_parameter(kwargs)
+ for tweet in reversed(t.statuses.mentions_timeline(**kwargs)):
draw(t=tweet)
printNicely('')
draw(t=tweet)
printNicely('')
@@
-398,8
+402,9
@@
def view():
num = int(g['stuff'].split()[1])
except:
num = c['HOME_TWEET_NUM']
num = int(g['stuff'].split()[1])
except:
num = c['HOME_TWEET_NUM']
- for tweet in reversed(
- t.statuses.user_timeline(count=num, screen_name=user[1:])):
+ kwargs = {'count': num, 'screen_name': user[1:]}
+ kwargs = add_tweetmode_parameter(kwargs)
+ for tweet in reversed(t.statuses.user_timeline(**kwargs)):
draw(t=tweet)
printNicely('')
else:
draw(t=tweet)
printNicely('')
else:
@@
-415,8
+420,10
@@
def view_my_tweets():
num = int(g['stuff'])
except:
num = c['HOME_TWEET_NUM']
num = int(g['stuff'])
except:
num = c['HOME_TWEET_NUM']
+ kwargs = {'count': num, 'screen_name': g['original_name']}
+ kwargs = add_tweetmode_parameter(kwargs)
for tweet in reversed(
for tweet in reversed(
- t.statuses.user_timeline(
count=num, screen_name=g['original_name']
)):
+ t.statuses.user_timeline(
**kwargs
)):
draw(t=tweet)
printNicely('')
draw(t=tweet)
printNicely('')
@@
-436,16
+443,18
@@
def search():
type = 'mixed'
max_record = c['SEARCH_MAX_RECORD']
count = min(max_record, 100)
type = 'mixed'
max_record = c['SEARCH_MAX_RECORD']
count = min(max_record, 100)
+ kwargs = {
+ 'q': query,
+ 'type': type,
+ 'count': count,
+ }
+ kwargs = add_tweetmode_parameter(kwargs)
# Perform search
# Perform search
- rel = t.search.tweets(
- q=query,
- type=type,
- count=count
- )['statuses']
+ rel = t.search.tweets(**kwargs)['statuses']
# Return results
if rel:
printNicely('Newest tweets:')
# Return results
if rel:
printNicely('Newest tweets:')
- for i in reversed(xrange(
count
)):
+ for i in reversed(xrange(
min(len(rel), count)
)):
draw(t=rel[i], keyword=query)
printNicely('')
else:
draw(t=rel[i], keyword=query)
printNicely('')
else:
@@
-535,7
+544,9
@@
def quote():
printNicely(red('Sorry I can\'t understand.'))
return
tid = c['tweet_dict'][id]
printNicely(red('Sorry I can\'t understand.'))
return
tid = c['tweet_dict'][id]
- tweet = t.statuses.show(id=tid)
+ kwargs = {'id': tid}
+ kwargs = add_tweetmode_parameter(kwargs)
+ tweet = t.statuses.show(**kwargs)
# Get formater
formater = format_quote(tweet)
if not formater:
# Get formater
formater = format_quote(tweet)
if not formater:
@@
-569,7
+580,9
@@
def allretweet():
except:
num = c['RETWEETS_SHOW_NUM']
# Get result and display
except:
num = c['RETWEETS_SHOW_NUM']
# Get result and display
- rt_ary = t.statuses.retweets(id=tid, count=num)
+ kwargs = {'id': tid, 'count': num}
+ kwargs = add_tweetmode_parameter(kwargs)
+ rt_ary = t.statuses.retweets(**kwargs)
if not rt_ary:
printNicely(magenta('This tweet has no retweet.'))
return
if not rt_ary:
printNicely(magenta('This tweet has no retweet.'))
return
@@
-589,14
+602,17
@@
def conversation():
printNicely(red('Sorry I can\'t understand.'))
return
tid = c['tweet_dict'][id]
printNicely(red('Sorry I can\'t understand.'))
return
tid = c['tweet_dict'][id]
- tweet = t.statuses.show(id=tid)
+ kwargs = {'id': tid}
+ kwargs = add_tweetmode_parameter(kwargs)
+ tweet = t.statuses.show(**kwargs)
limit = c['CONVERSATION_MAX']
thread_ref = []
thread_ref.append(tweet)
prev_tid = tweet['in_reply_to_status_id']
while prev_tid and limit:
limit -= 1
limit = c['CONVERSATION_MAX']
thread_ref = []
thread_ref.append(tweet)
prev_tid = tweet['in_reply_to_status_id']
while prev_tid and limit:
limit -= 1
- tweet = t.statuses.show(id=prev_tid)
+ kwargs['id'] = prev_tid
+ tweet = t.statuses.show(**kwargs)
prev_tid = tweet['in_reply_to_status_id']
thread_ref.append(tweet)
prev_tid = tweet['in_reply_to_status_id']
thread_ref.append(tweet)
@@
-663,7
+679,9
@@
def favorite():
tid = c['tweet_dict'][id]
t.favorites.create(_id=tid, include_entities=False)
printNicely(green('Favorited.'))
tid = c['tweet_dict'][id]
t.favorites.create(_id=tid, include_entities=False)
printNicely(green('Favorited.'))
- draw(t.statuses.show(id=tid))
+ kwargs = {'id': tid}
+ kwargs = add_tweetmode_parameter(kwargs)
+ draw(t.statuses.show(**kwargs))
printNicely('')
printNicely('')
@@
-680,7
+698,9
@@
def unfavorite():
tid = c['tweet_dict'][id]
t.favorites.destroy(_id=tid)
printNicely(green('Okay it\'s unfavorited.'))
tid = c['tweet_dict'][id]
t.favorites.destroy(_id=tid)
printNicely(green('Okay it\'s unfavorited.'))
- draw(t.statuses.show(id=tid))
+ kwargs = {'id': tid}
+ kwargs = add_tweetmode_parameter(kwargs)
+ draw(t.statuses.show(**kwargs))
printNicely('')
printNicely('')
@@
-695,7
+715,9
@@
def share():
except:
printNicely(red('Tweet id is not valid.'))
return
except:
printNicely(red('Tweet id is not valid.'))
return
- tweet = t.statuses.show(id=tid)
+ kwargs = {'id': tid}
+ kwargs = add_tweetmode_parameter(kwargs)
+ tweet = t.statuses.show(**kwargs)
url = 'https://twitter.com/' + \
tweet['user']['screen_name'] + '/status/' + str(tid)
import platform
url = 'https://twitter.com/' + \
tweet['user']['screen_name'] + '/status/' + str(tid)
import platform