From: vunhat_minh Date: Wed, 27 Aug 2014 04:11:58 +0000 (+0900) Subject: improve search query X-Git-Url: https://vcs.fsf.org/?p=rainbowstream.git;a=commitdiff_plain;h=954b31016c5bf5c633e9a8793a2659e1a74024b3 improve search query --- diff --git a/docs/conf.py b/docs/conf.py index 367ae8f..ade949a 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -48,9 +48,9 @@ copyright = u'2014, Vu Nhat Minh' # built documents. # # The short X.Y version. -version = '0.9.0' +version = '0.9.1' # The full version, including alpha/beta/rc tags. -release = '0.9.0' +release = '0.9.1' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/docs/index.rst b/docs/index.rst index 28592b2..a11e7da 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -319,6 +319,8 @@ You also can view or set a new value of every config key by ``config`` command ( - ``PREFIX``: display string of prompt. +- ``SEARCH_TYPE``: search type in 'search' command ('mixed','recent','popular'). + - ``SEARCH_MAX_RECORD``: max tweets can display on 'search' command. - ``HOME_TWEET_NUM``: default tweets to display on 'home' command. diff --git a/rainbowstream/colorset/config b/rainbowstream/colorset/config index d85d658..e0a3ba5 100644 --- a/rainbowstream/colorset/config +++ b/rainbowstream/colorset/config @@ -11,7 +11,9 @@ "HIDE_PROMPT" : true, // Prefix "PREFIX" : "", - // 'search': max search record + // 'search': search type ('mixed','recent','popular') + "SEARCH_TYPE" : "mixed", + // 'search': search max result, number over 100 will fallback to 100 "SEARCH_MAX_RECORD" : 5, // 'home': default number of home's tweets "HOME_TWEET_NUM" : 5, diff --git a/rainbowstream/rainbow.py b/rainbowstream/rainbow.py index f58d59c..de908e6 100644 --- a/rainbowstream/rainbow.py +++ b/rainbowstream/rainbow.py @@ -249,13 +249,24 @@ def search(): Search """ t = Twitter(auth=authen()) - g['stuff'] = g['stuff'].strip() - rel = t.search.tweets(q=g['stuff'])['statuses'] + # Setup query + query = g['stuff'].strip() + type = c['SEARCH_TYPE'] + if type not in ['mixed', 'recent', 'popular']: + type = 'mixed' + max_record = c['SEARCH_MAX_RECORD'] + count = min(max_record, 100) + # Perform search + rel = t.search.tweets( + q=query, + type=type, + count=count + )['statuses'] + # Return results if rel: printNicely('Newest tweets:') - for i in reversed(xrange(c['SEARCH_MAX_RECORD'])): - draw(t=rel[i], - keyword=g['stuff']) + for i in reversed(xrange(count)): + draw(t=rel[i], keyword=query) printNicely('') else: printNicely(magenta('I\'m afraid there is no result')) diff --git a/setup.py b/setup.py index da18822..6337cfe 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ import os import os.path # Bumped version -version = '0.9.0' +version = '0.9.1' # Require install_requires = [