예제 #1
0
def cmd_account_send_verification(client, args):
    """
    Sends an email to the user to verify that their email is valid to upload to
    gallery. Must be logged in as the user to send
    """
    verification_email = client.send_verification_email(args.username)
    generate_output({'verification_email': verification_email})
예제 #2
0
파일: cli_api.py 프로젝트: Saturn/imgur-cli
def cmd_account_send_verification(client, args):
    """
    Sends an email to the user to verify that their email is valid to upload to
    gallery. Must be logged in as the user to send
    """
    verification_email = client.send_verification_email(args.username)
    generate_output({'verification_email': verification_email})
예제 #3
0
def cmd_image_favorite(client, args):
    """
    Favorite an image with a given ID. The user is required to be logged in to
    favorite the image
    """
    favorite_image = client.favorite_image(args.image_id)
    generate_output({'favorite_image': favorite_image})
예제 #4
0
파일: cli_api.py 프로젝트: Saturn/imgur-cli
def cmd_image_favorite(client, args):
    """
    Favorite an image with a given ID. The user is required to be logged in to
    favorite the image
    """
    favorite_image = client.favorite_image(args.image_id)
    generate_output({'favorite_image': favorite_image})
예제 #5
0
def cmd_album_favorite(client, args):
    """
    Favorite an album with a given ID. The user is required to be logged in to
    favorite the album
    """
    favorite_album = client.album_favorite(args.album_id)
    generate_output({'favorite_album': favorite_album})
예제 #6
0
파일: cli_api.py 프로젝트: Saturn/imgur-cli
def cmd_notification_id(client, args):
    """Returns the data about a specific notification"""
    notification = client.get_notification(args.notification_id)
    notification = notification.__dict__
    if 'comment' in notification['content']:
        notification['content'] = format_comment_tree(notification['content'])
    generate_output({'notification': notification})
예제 #7
0
def cmd_gallery_tag(client, args):
    """View images for a gallery tag"""
    gallery_tag = client.gallery_tag(args.tag, args.sort, args.page,
                                     args.window)
    data = gallery_tag.__dict__
    data['items'] = [item.__dict__ for item in data['items']]
    generate_output({'gallery_tag': data})
예제 #8
0
파일: cli_api.py 프로젝트: Saturn/imgur-cli
def cmd_gallery_item_vote(client, args):
    """
    Vote for an item in the gallery, 'up' or 'down' vote. Send the same value
    again to undo a vote
    """
    gallery_item_vote = client.gallery_item_vote(args.item_id, args.vote)
    generate_output({'gallery_item_vote': gallery_item_vote})
예제 #9
0
파일: cli_api.py 프로젝트: Saturn/imgur-cli
def cmd_gallery_remove(client, args):
    """
    Remove an item from the gallery. You must be logged in as the owner of the
    item to do this action
    """
    gallery_remove = client.remove_from_gallery(args.item_id)
    generate_output({'gallery_remove': gallery_remove})
예제 #10
0
def cmd_gallery_remove(client, args):
    """
    Remove an item from the gallery. You must be logged in as the owner of the
    item to do this action
    """
    gallery_remove = client.remove_from_gallery(args.item_id)
    generate_output({'gallery_remove': gallery_remove})
예제 #11
0
def cmd_notification_id(client, args):
    """Returns the data about a specific notification"""
    notification = client.get_notification(args.notification_id)
    notification = notification.__dict__
    if 'comment' in notification['content']:
        notification['content'] = format_comment_tree(notification['content'])
    generate_output({'notification': notification})
예제 #12
0
def cmd_gallery_item_vote(client, args):
    """
    Vote for an item in the gallery, 'up' or 'down' vote. Send the same value
    again to undo a vote
    """
    gallery_item_vote = client.gallery_item_vote(args.item_id, args.vote)
    generate_output({'gallery_item_vote': gallery_item_vote})
예제 #13
0
파일: cli_api.py 프로젝트: Saturn/imgur-cli
def cmd_album_favorite(client, args):
    """
    Favorite an album with a given ID. The user is required to be logged in to
    favorite the album
    """
    favorite_album = client.album_favorite(args.album_id)
    generate_output({'favorite_album': favorite_album})
예제 #14
0
def cmd_account_albums(client, args):
    """
    Get all the albums associated with the account. Must be logged in as the user
    to see secret and hidden albums
    """
    account_albums = client.get_account_albums(args.username, args.page)
    data = [item.__dict__ for item in account_albums]
    generate_output({'account_albums': data}, args.output_file)
예제 #15
0
파일: cli_api.py 프로젝트: Saturn/imgur-cli
def cmd_account_settings(client, args):
    """
    Returns the account settings, only accessible if you're logged
    in as the user
    """
    account_settings = client.get_account_settings(args.username)
    data = account_settings.__dict__
    generate_output({'account_settings': data})
예제 #16
0
파일: cli_api.py 프로젝트: Saturn/imgur-cli
def cmd_account_favorites(client, args):
    """
    Returns the users favorited images, only accessible if you're logged
    in as the user
    """
    account_favorites = client.get_account_favorites(args.username)
    data = [item.__dict__ for item in account_favorites]
    generate_output({'account_favorites': data}, args.output_file)
예제 #17
0
파일: cli_api.py 프로젝트: Saturn/imgur-cli
def cmd_album_remove_images(client, args):
    """
    Remove images for an album from a given comma separated list of image ids.
    For anonymous albums, {album} should be the deletehash that is returned
    at creation
    """
    remove_images = client.album_remove_images(args.album_id, args.ids)
    generate_output({'remove_images': remove_images})
예제 #18
0
파일: cli_api.py 프로젝트: Saturn/imgur-cli
def cmd_album_set_images(client, args):
    """
    Sets the images for an album, removes all other images and only uses the images
    in this request. For anonymous albums, {album} should be the deletehash that
    is returned at creation
    """
    set_images = client.album_set_images(args.album_id, args.ids)
    generate_output({'set_images': set_images})
예제 #19
0
파일: cli_api.py 프로젝트: Saturn/imgur-cli
def cmd_album_delete(client, args):
    """
    Delete an album with a given ID. You are required to be logged in as the user
    to delete the album. For anonymous albums, {album} should be the deletehash
    that is returned at creation
    """
    delete_album = client.album_delete(args.album_id)
    generate_output({'delete_album': delete_album})
예제 #20
0
파일: cli_api.py 프로젝트: Saturn/imgur-cli
def cmd_album_update(client, args):
    """
    Update the information of an album. For anonymous albums, {album} should be the
    deletehash that is returned at creation
    """
    fields = data_fields(args, client.allowed_album_fields)
    album = client.update_album(args.album_id, fields)
    generate_output({'album': album})
예제 #21
0
파일: cli_api.py 프로젝트: Saturn/imgur-cli
def cmd_account_user(client, args):
    """
    Request standard user information. If you need the username for the account
    that is logged in, it is returned in the request for an access token
    """
    account_user = client.get_account(args.username)
    data = account_user.__dict__
    generate_output({'account_user': data})
예제 #22
0
파일: cli_api.py 프로젝트: Saturn/imgur-cli
def cmd_image_delete(client, args):
    """
    Deletes an image. For an anonymous image, {id} must be the image's deletehash.
    If the image belongs to your account then passing the ID of the image is
    sufficient
    """
    image_to_delete = client.delete_image(args.image_id)
    generate_output({'deleted': image_to_delete})
예제 #23
0
파일: cli_api.py 프로젝트: Saturn/imgur-cli
def cmd_image_upload(client, args):
    """Upload a new image"""
    config = data_fields(args, client.allowed_image_fields)
    if args.type == 'file':
        image = client.upload_from_path(args.image, config)
    else:
        image = client.upload_from_url(args.image, config)
    generate_output({'image': image})
예제 #24
0
파일: cli_api.py 프로젝트: Saturn/imgur-cli
def cmd_account_albums(client, args):
    """
    Get all the albums associated with the account. Must be logged in as the user
    to see secret and hidden albums
    """
    account_albums = client.get_account_albums(args.username, args.page)
    data = [item.__dict__ for item in account_albums]
    generate_output({'account_albums': data}, args.output_file)
예제 #25
0
def cmd_album_remove_images(client, args):
    """
    Remove images for an album from a given comma separated list of image ids.
    For anonymous albums, {album} should be the deletehash that is returned
    at creation
    """
    remove_images = client.album_remove_images(args.album_id, args.ids)
    generate_output({'remove_images': remove_images})
예제 #26
0
def cmd_account_favorites(client, args):
    """
    Returns the users favorited images, only accessible if you're logged
    in as the user
    """
    account_favorites = client.get_account_favorites(args.username)
    data = [item.__dict__ for item in account_favorites]
    generate_output({'account_favorites': data}, args.output_file)
예제 #27
0
def cmd_account_settings(client, args):
    """
    Returns the account settings, only accessible if you're logged
    in as the user
    """
    account_settings = client.get_account_settings(args.username)
    data = account_settings.__dict__
    generate_output({'account_settings': data})
예제 #28
0
def cmd_album_set_images(client, args):
    """
    Sets the images for an album, removes all other images and only uses the images
    in this request. For anonymous albums, {album} should be the deletehash that
    is returned at creation
    """
    set_images = client.album_set_images(args.album_id, args.ids)
    generate_output({'set_images': set_images})
예제 #29
0
def cmd_album_update(client, args):
    """
    Update the information of an album. For anonymous albums, {album} should be the
    deletehash that is returned at creation
    """
    fields = data_fields(args, client.allowed_album_fields)
    album = client.update_album(args.album_id, fields)
    generate_output({'album': album})
예제 #30
0
def cmd_album_delete(client, args):
    """
    Delete an album with a given ID. You are required to be logged in as the user
    to delete the album. For anonymous albums, {album} should be the deletehash
    that is returned at creation
    """
    delete_album = client.album_delete(args.album_id)
    generate_output({'delete_album': delete_album})
예제 #31
0
def cmd_account_user(client, args):
    """
    Request standard user information. If you need the username for the account
    that is logged in, it is returned in the request for an access token
    """
    account_user = client.get_account(args.username)
    data = account_user.__dict__
    generate_output({'account_user': data})
예제 #32
0
def cmd_image_upload(client, args):
    """Upload a new image"""
    config = data_fields(args, client.allowed_image_fields)
    if args.type == 'file':
        image = client.upload_from_path(args.image, config)
    else:
        image = client.upload_from_url(args.image, config)
    generate_output({'image': image})
예제 #33
0
def cmd_image_delete(client, args):
    """
    Deletes an image. For an anonymous image, {id} must be the image's deletehash.
    If the image belongs to your account then passing the ID of the image is
    sufficient
    """
    image_to_delete = client.delete_image(args.image_id)
    generate_output({'deleted': image_to_delete})
예제 #34
0
def cmd_conversation_id(client, args):
    """Get information about a specific conversation. Includes messages"""
    conversation = client.get_conversation(args.conversation_id, args.page,
                                           args.offset)
    data = conversation.__dict__
    try:
        data['messages'] = [item.__dict__ for item in data['messages']]
    except KeyError:
        pass
    generate_output({'conversation': data})
예제 #35
0
파일: cli_api.py 프로젝트: Saturn/imgur-cli
def cmd_conversation_id(client, args):
    """Get information about a specific conversation. Includes messages"""
    conversation = client.get_conversation(args.conversation_id,
                                           args.page, args.offset)
    data = conversation.__dict__
    try:
        data['messages'] = [item.__dict__ for item in data['messages']]
    except KeyError:
        pass
    generate_output({'conversation': data})
예제 #36
0
파일: cli_api.py 프로젝트: Saturn/imgur-cli
def cmd_notification_mark(client, args):
    """
    Marks a notification  or multiple notifications as viewed, this way it no
    longer shows up in the basic notification request
    """
    # Converted to list because in current implemented in imgurpython, client method
    # expected a comma separated list of ids
    ids = args.ids.split(',')
    notifications_marked_as_viewed = client.mark_notifications_as_read(args.ids)
    generate_output({'notifications_marked_as_viewed':
                     notifications_marked_as_viewed})
예제 #37
0
def cmd_album_create(client, args):
    """
    Create a new album. Optional parameter of ids is an array of image ids to
    add to the album; you have to be logged in as the user for adding the image ids.

    This method is available without authenticating an account, and may be used
    merely by sending "Authorization: Client-ID {client_id}" in the request headers.
    Doing so will create an anonymous album which is not tied to an account
    """
    fields = data_fields(args, client.allowed_album_fields)
    album = client.create_album(fields)
    generate_output({'album': album})
예제 #38
0
파일: cli_api.py 프로젝트: Saturn/imgur-cli
def cmd_album_create(client, args):
    """
    Create a new album. Optional parameter of ids is an array of image ids to
    add to the album; you have to be logged in as the user for adding the image ids.

    This method is available without authenticating an account, and may be used
    merely by sending "Authorization: Client-ID {client_id}" in the request headers.
    Doing so will create an anonymous album which is not tied to an account
    """
    fields = data_fields(args, client.allowed_album_fields)
    album = client.create_album(fields)
    generate_output({'album': album})
예제 #39
0
파일: cli_api.py 프로젝트: Saturn/imgur-cli
def cmd_notification_all(client, args):
    """Get all notifications for the user that's currently logged in"""
    notifications_all = client.get_notifications(args.new)
    notifications_all['messages'] = [message.__dict__ for message in
                                     notifications_all['messages']]
    formatted_replies = []
    for reply in notifications_all['replies']:
        formatted_reply = reply.__dict__
        formatted_reply['content'] = format_comment_tree(formatted_reply['content'])
        formatted_replies.append(formatted_reply)
    notifications_all['replies'] = formatted_replies
    generate_output({'notifications_all': notifications_all}, args.output_file)
예제 #40
0
def cmd_notification_mark(client, args):
    """
    Marks a notification  or multiple notifications as viewed, this way it no
    longer shows up in the basic notification request
    """
    # Converted to list because in current implemented in imgurpython, client method
    # expected a comma separated list of ids
    ids = args.ids.split(',')
    notifications_marked_as_viewed = client.mark_notifications_as_read(
        args.ids)
    generate_output(
        {'notifications_marked_as_viewed': notifications_marked_as_viewed})
예제 #41
0
def cmd_notification_all(client, args):
    """Get all notifications for the user that's currently logged in"""
    notifications_all = client.get_notifications(args.new)
    notifications_all['messages'] = [
        message.__dict__ for message in notifications_all['messages']
    ]
    formatted_replies = []
    for reply in notifications_all['replies']:
        formatted_reply = reply.__dict__
        formatted_reply['content'] = format_comment_tree(
            formatted_reply['content'])
        formatted_replies.append(formatted_reply)
    notifications_all['replies'] = formatted_replies
    generate_output({'notifications_all': notifications_all}, args.output_file)
예제 #42
0
파일: cli_api.py 프로젝트: Saturn/imgur-cli
def cmd_gallery_random(client, args):
    """View a random set of gallery items"""
    gallery_random = client.gallery_random(args.page)
    data = [item.__dict__ for item in gallery_random]
    generate_output({'gallery_random': data}, args.output_file)
예제 #43
0
파일: cli_api.py 프로젝트: Saturn/imgur-cli
def cmd_memegen_default_memes(client, args):
    """Get the list of default memes"""
    default_memes = client.default_memes()
    data = [item.__dict__ for item in default_memes]
    generate_output({'default_memes': args.output_file})
예제 #44
0
파일: cli_api.py 프로젝트: Saturn/imgur-cli
def cmd_gallery_create_comment(client, args):
    create_comment = client.gallery_comment(args.item_id, args.comment)
    generate_output({'create_comment': create_comment})
예제 #45
0
def cmd_image_id(client, args):
    """Get information about an image"""
    image = client.get_image(args.image_id)
    data = image.__dict__
    generate_output({'image': data})
예제 #46
0
def cmd_gallery_comment_count(client, args):
    """The number of comments on an item in the gallery"""
    gallery_comment_count = client.gallery_comment_count(args.item_id)
    generate_output({'gallery_comment_count': gallery_comment_count})
예제 #47
0
파일: cli_api.py 프로젝트: Saturn/imgur-cli
def cmd_gallery_report(client, args):
    """Report an item in the gallery"""
    report_gallery_item = client.report_gallery_item(args.item_id)
    generate_output({'report_gallery_item': report_gallery_item})
예제 #48
0
파일: cli_api.py 프로젝트: Saturn/imgur-cli
def cmd_gallery_comment_ids(client, args):
    """List all of the IDs for the comments on an item in the gallery"""
    gallery_comment_ids = client.gallery_comment_ids(args.item_id)
    generate_output({'gallery_comment_ids': gallery_comment_ids})
예제 #49
0
def cmd_gallery_create_comment(client, args):
    create_comment = client.gallery_comment(args.item_id, args.comment)
    generate_output({'create_comment': create_comment})
예제 #50
0
def cmd_gallery_comments(client, args):
    """Get comments on an item in the gallery"""
    gallery_comments = client.gallery_item_comments(args.item_id, args.sort)
    data = format_comment_tree(gallery_comments)
    generate_output({'gallery_comments': data}, args.output_file)
예제 #51
0
파일: cli_api.py 프로젝트: Saturn/imgur-cli
def cmd_gallery_publish(client, args):
    """Share an Album or Image to the Imgur Gallery"""
    publish_to_imgur = client.share_on_imgur(args.item_id, args.title, args.terms)
    generate_output({'publish_to_imgur': publish_to_imgur})
예제 #52
0
def cmd_gallery_report(client, args):
    """Report an item in the gallery"""
    report_gallery_item = client.report_gallery_item(args.item_id)
    generate_output({'report_gallery_item': report_gallery_item})
예제 #53
0
def cmd_gallery_item(client, args):
    """View item in a gallery"""
    gallery_item = client.gallery_item(args.item_id)
    data = gallery_item.__dict__
    generate_output({'gallery_item': data})
예제 #54
0
파일: cli_api.py 프로젝트: Saturn/imgur-cli
def cmd_gallery_item(client, args):
    """View item in a gallery"""
    gallery_item = client.gallery_item(args.item_id)
    data = gallery_item.__dict__
    generate_output({'gallery_item': data})
예제 #55
0
def cmd_gallery_publish(client, args):
    """Share an Album or Image to the Imgur Gallery"""
    publish_to_imgur = client.share_on_imgur(args.item_id, args.title,
                                             args.terms)
    generate_output({'publish_to_imgur': publish_to_imgur})
예제 #56
0
def cmd_memegen_default_memes(client, args):
    """Get the list of default memes"""
    default_memes = client.default_memes()
    data = [item.__dict__ for item in default_memes]
    generate_output({'default_memes': args.output_file})
예제 #57
0
파일: cli_api.py 프로젝트: Saturn/imgur-cli
def cmd_gallery_comments(client, args):
    """Get comments on an item in the gallery"""
    gallery_comments = client.gallery_item_comments(args.item_id, args.sort)
    data = format_comment_tree(gallery_comments)
    generate_output({'gallery_comments': data}, args.output_file)
예제 #58
0
def cmd_gallery_comment_ids(client, args):
    """List all of the IDs for the comments on an item in the gallery"""
    gallery_comment_ids = client.gallery_comment_ids(args.item_id)
    generate_output({'gallery_comment_ids': gallery_comment_ids})
예제 #59
0
파일: cli_api.py 프로젝트: Saturn/imgur-cli
def cmd_gallery_comment_count(client, args):
    """The number of comments on an item in the gallery"""
    gallery_comment_count = client.gallery_comment_count(args.item_id)
    generate_output({'gallery_comment_count': gallery_comment_count})
예제 #60
0
파일: cli_api.py 프로젝트: Saturn/imgur-cli
def cmd_image_id(client, args):
    """Get information about an image"""
    image = client.get_image(args.image_id)
    data = image.__dict__
    generate_output({'image': data})