1
0
mirror of https://github.com/ihabunek/toot.git synced 2024-11-03 04:17:21 -05:00

Enable attaching multiple media files

fixes #67
This commit is contained in:
Ivan Habunek 2019-08-01 12:56:21 +02:00
parent 42247f94ba
commit a771ca3aa7
No known key found for this signature in database
GPG Key ID: CDBD63C43A30BB95
3 changed files with 11 additions and 5 deletions

View File

@ -7,6 +7,7 @@ Changelog
* Add `toot notifications` to show notifications (thanks @dlax) * Add `toot notifications` to show notifications (thanks @dlax)
* Add posting and replying to curses interface (thanks @Skehmatics) * Add posting and replying to curses interface (thanks @Skehmatics)
* Add `--language` option to `toot post` * Add `--language` option to `toot post`
* Enable attaching upto 4 files via `--media` option on `toot post`
**0.21.0 (2019-02-15)** **0.21.0 (2019-02-15)**

View File

@ -76,15 +76,18 @@ def curses(app, user, args):
def post(app, user, args): def post(app, user, args):
if args.media and len(args.media) > 4:
raise ConsoleError("Cannot attach more than 4 files.")
if args.media: if args.media:
media = _do_upload(app, user, args.media) media = [_do_upload(app, user, file) for file in args.media]
media_ids = [media['id']] media_ids = [m["id"] for m in media]
else: else:
media = None media = None
media_ids = None media_ids = None
if media and not args.text: if media and not args.text:
args.text = media['text_url'] args.text = "\n".join(m['text_url'] for m in media)
if not args.text: if not args.text:
print_out("Write or paste your toot. Press <yellow>{}</yellow> to post it.".format(EOF_KEY)) print_out("Write or paste your toot. Press <yellow>{}</yellow> to post it.".format(EOF_KEY))

View File

@ -271,8 +271,10 @@ POST_COMMANDS = [
"nargs": "?", "nargs": "?",
}), }),
(["-m", "--media"], { (["-m", "--media"], {
"type": FileType('rb'), "action": "append",
"help": "path to the media file to attach" "type": FileType("rb"),
"help": "path to the media file to attach (specify multiple "
"times to attach up to 4 files)"
}), }),
(["-v", "--visibility"], { (["-v", "--visibility"], {
"type": visibility, "type": visibility,