X-Git-Url: https://jfr.im/git/z_archive/twitter.git/blobdiff_plain/84c699d25345997979af67b97c6cfccd851945ed..40db782dcb9584b10a3307a5841c7e62780d60e4:/twitter/cmdline.py diff --git a/twitter/cmdline.py b/twitter/cmdline.py index f586e4a..f238d6c 100644 --- a/twitter/cmdline.py +++ b/twitter/cmdline.py @@ -15,7 +15,6 @@ ACTIONS: tweets from that list mylist get list of your lists; give a list name to get tweets from that list - public get latest public tweets pyprompt start a Python prompt for interacting with the twitter object directly replies get latest replies to you @@ -132,8 +131,9 @@ def parse_args(args, options): 'datestamp', 'no-ssl', 'force-ansi'] short_opts = "e:p:f:h?rR:c:l:td" opts, extra_args = getopt(args, short_opts, long_opts) - extra_args = [arg.decode(locale.getpreferredencoding()) - for arg in extra_args] + if extra_args and hasattr(extra_args[0], 'decode'): + extra_args = [arg.decode(locale.getpreferredencoding()) + for arg in extra_args] for opt, arg in opts: if opt in ('-f', '--format'): @@ -463,7 +463,7 @@ class ListsAction(StatusAction): screen_name = options['extra_args'][0] if not options['extra_args'][1:]: - lists = twitter.user.lists(user=screen_name)['lists'] + lists = twitter.lists.list(screen_name=screen_name) if not lists: printNicely("This user has no lists.") for list in lists: @@ -484,15 +484,11 @@ class MyListsAction(ListsAction): class FriendsAction(StatusAction): def getStatuses(self, twitter, options): - return reversed(twitter.statuses.friends_timeline(count=options["length"])) - -class PublicAction(StatusAction): - def getStatuses(self, twitter, options): - return reversed(twitter.statuses.public_timeline(count=options["length"])) + return reversed(twitter.statuses.home_timeline(count=options["length"])) class RepliesAction(StatusAction): def getStatuses(self, twitter, options): - return reversed(twitter.statuses.replies(count=options["length"])) + return reversed(twitter.statuses.mentions_timeline(count=options["length"])) class FollowAction(AdminAction): def getUser(self, twitter, user): @@ -615,7 +611,6 @@ actions = { 'mylist' : MyListsAction, 'help' : HelpAction, 'leave' : LeaveAction, - 'public' : PublicAction, 'pyprompt' : PythonPromptAction, 'replies' : RepliesAction, 'search' : SearchAction, @@ -660,11 +655,11 @@ def main(args=sys.argv[1:]): if v: options[k] = v if options['refresh'] and options['action'] not in ( - 'friends', 'public', 'replies'): - print("You can only refresh the friends, public, or replies actions.", file=sys.stderr) + 'friends', 'replies'): + print("You can only refresh the friends or replies actions.", file=sys.stderr) print("Use 'twitter -h' for help.", file=sys.stderr) return 1 - + oauth_filename = os.path.expanduser(options['oauth_filename']) if (options['action'] == 'authorize' @@ -672,7 +667,7 @@ def main(args=sys.argv[1:]): oauth_dance( "the Command-Line Tool", CONSUMER_KEY, CONSUMER_SECRET, options['oauth_filename']) - + global ansiFormatter ansiFormatter = ansi.AnsiCmd(options["force-ansi"]) @@ -682,7 +677,7 @@ def main(args=sys.argv[1:]): auth=OAuth( oauth_token, oauth_token_secret, CONSUMER_KEY, CONSUMER_SECRET), secure=options['secure'], - api_version='1', + api_version='1.1', domain='api.twitter.com') try: