Ejemplo n.º 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})
Ejemplo n.º 2
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})
Ejemplo n.º 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})
Ejemplo n.º 4
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})
Ejemplo n.º 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})
Ejemplo n.º 6
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})
Ejemplo n.º 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})
Ejemplo n.º 8
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})
Ejemplo n.º 9
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})
Ejemplo n.º 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})
Ejemplo n.º 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})
Ejemplo n.º 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})
Ejemplo n.º 13
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})
Ejemplo n.º 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)
Ejemplo n.º 15
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})
Ejemplo n.º 16
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)
Ejemplo n.º 17
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})
Ejemplo n.º 18
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})
Ejemplo n.º 19
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})
Ejemplo n.º 20
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})
Ejemplo n.º 21
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})
Ejemplo n.º 22
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})
Ejemplo n.º 23
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})
Ejemplo n.º 24
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)
Ejemplo n.º 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})
Ejemplo n.º 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)
Ejemplo n.º 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})
Ejemplo n.º 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})
Ejemplo n.º 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})
Ejemplo n.º 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})
Ejemplo n.º 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})
Ejemplo n.º 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})
Ejemplo n.º 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})
Ejemplo n.º 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})
Ejemplo n.º 35
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})
Ejemplo n.º 36
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})
Ejemplo n.º 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})
Ejemplo n.º 38
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})
Ejemplo n.º 39
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)
Ejemplo n.º 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})
Ejemplo n.º 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)
Ejemplo n.º 42
0
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)
Ejemplo n.º 43
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})
Ejemplo n.º 44
0
def cmd_gallery_create_comment(client, args):
    create_comment = client.gallery_comment(args.item_id, args.comment)
    generate_output({'create_comment': create_comment})
Ejemplo n.º 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})
Ejemplo n.º 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})
Ejemplo n.º 47
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})
Ejemplo n.º 48
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})
Ejemplo n.º 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})
Ejemplo n.º 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)
Ejemplo n.º 51
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})
Ejemplo n.º 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})
Ejemplo n.º 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})
Ejemplo n.º 54
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})
Ejemplo n.º 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})
Ejemplo n.º 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})
Ejemplo n.º 57
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)
Ejemplo n.º 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})
Ejemplo n.º 59
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})
Ejemplo n.º 60
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})