diff --git a/toot/api.py b/toot/api.py index cb05c85..cf15bf5 100644 --- a/toot/api.py +++ b/toot/api.py @@ -31,7 +31,7 @@ def find_account(app, user, account_name): normalized_name = username response = search(app, user, account_name, type="accounts", resolve=True) - for account in response["accounts"]: + for account in response.json()["accounts"]: if account["acct"].lower() == normalized_name: return account @@ -458,7 +458,7 @@ def search(app, user, query, resolve=False, type=None): "type": type }) - return http.get(app, user, "/api/v2/search", params).json() + return http.get(app, user, "/api/v2/search", params) def follow(app, user, account): diff --git a/toot/commands.py b/toot/commands.py index 503147f..0fd8307 100644 --- a/toot/commands.py +++ b/toot/commands.py @@ -367,7 +367,10 @@ def upload(app, user, args): def search(app, user, args): response = api.search(app, user, args.query, args.resolve) - print_search_results(response) + if args.json: + print(response.text) + else: + print_search_results(response.json()) def _do_upload(app, user, file, description, thumbnail):