1
0
mirror of https://github.com/ihabunek/toot synced 2024-12-22 23:08:17 +01:00

Add --json option to search command

This commit is contained in:
Ivan Habunek 2023-11-21 11:53:10 +01:00
parent 0c37716de1
commit ae7a36b8d8
No known key found for this signature in database
GPG Key ID: F5F0623FF5EBCB3D
2 changed files with 6 additions and 3 deletions

View File

@ -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):

View File

@ -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):