From: Orakaro Date: Sat, 13 Sep 2014 15:22:35 +0000 (+0900) Subject: add feature switch to a list stream X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=ee4c94b18baa82ab5d978aa1909360417b43553d;p=rainbowstream.git add feature switch to a list stream --- diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..47b322c --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.4.1 diff --git a/docs/conf.py b/docs/conf.py index ad07f8a..d222fac 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 = '1.0.2' +version = '1.0.3' # The full version, including alpha/beta/rc tags. -release = '1.0.2' +release = '1.0.3' # 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 0c96d28..e652ecd 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -222,6 +222,8 @@ Here is full list of supported command: - ``switch mine`` will switch current stream to personal stream. ``-f`` and ``-d`` will work as well. +- ``switch list`` will switch to a Twitter list's stream. You will be asked for list name. + **Smart shell** - Put anything to terminal, the app will try to eval and display result as a python interactive shell. diff --git a/rainbowstream/rainbow.py b/rainbowstream/rainbow.py index dd7fffc..74e7c2b 100644 --- a/rainbowstream/rainbow.py +++ b/rainbowstream/rainbow.py @@ -841,10 +841,10 @@ def report(): def get_slug(): """ - Get Slug Decorator + Get slug """ # Get list name - list_name = raw_input(light_magenta('Give me the list\'s name: ')) + list_name = raw_input(light_magenta('Give me the list\'s name ("@owner/list_name"): ')) # Get list name and owner try: owner, slug = list_name.split('/') @@ -1166,13 +1166,47 @@ def switch(): g['original_name'])) th.daemon = True th.start() + # Stream base on list + elif target == 'list': + owner, slug = get_slug() + # Force python 2 not redraw readline buffer + g['cmd'] = '/'.join([owner,slug]) + printNicely(light_yellow('getting list members ...')) + # Get members + t = Twitter(auth=authen()) + members = [] + next_cursor = -1 + while next_cursor != 0: + m = t.lists.members( + slug=slug, + owner_screen_name=owner, + cursor=next_cursor, + include_entities=False) + for u in m['users']: + members.append('@' + u['screen_name']) + next_cursor = m['next_cursor'] + printNicely(light_yellow('... done.')) + # Build thread filter array + args.filter = members + # Kill old thread + g['stream_stop'] = True + # Start new thread + th = threading.Thread( + target=stream, + args=( + c['USER_DOMAIN'], + args, + slug)) + th.daemon = True + th.start() printNicely('') if args.filter: - printNicely(cyan('Only: ' + str(args.filter))) + printNicely(cyan('Include: ' + str(len(args.filter))) + ' people.') if args.ignore: - printNicely(red('Ignore: ' + str(args.ignore))) + printNicely(red('Ignore: ' + str(len(args.ignore))) + ' people.') printNicely('') - except: + except Exception: + debug_option() printNicely(red('Sorry I can\'t understand.')) @@ -1455,6 +1489,8 @@ def help_stream(): ' filter will decide nicks will be EXCLUDE.\n' usage += s * 2 + light_green('switch mine -d') + \ ' will use the config\'s ONLY_LIST and IGNORE_LIST.\n' + usage += s * 2 + light_green('switch list') + \ + ' will switch to a Twitter list\'s stream. You will be asked for list name\n' printNicely(usage) @@ -1702,7 +1738,7 @@ def listen(): d = dict(zip( cmdset, [ - ['public', 'mine'], # switch + ['public', 'mine', 'list'], # switch [], # trend [], # home [], # notification diff --git a/setup.py b/setup.py index 72076ae..e20ec03 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ import os import os.path # Bumped version -version = '1.0.2' +version = '1.0.3' # Require install_requires = [