Example #1
0
    def export(self, logs):
        client = ImgurClient(self.client_id,
                             self.client_secret,
                             refresh_token=self.refresh_token)

        image_ids = []
        for log in logs:
            image = client.upload_from_path(
                log.value,
                config={'description': log.timestamp.isoformat()},
                anon=False)

            image_ids.append(image['id'])

        client.album_add_images(self.album_id, image_ids)
Example #2
0
def UploadPhotoInAlbum(id, album):
    access_token, refresh_token, client_id, client_secret = Config.getImgurKeys(
    )
    client = ImgurClient(client_id, client_secret)
    client.set_user_auth(access_token, refresh_token)
    config = {
        'name': 'htht!',
        'title': 'hththt!',
        'description': 'this is a test'
    }
    return client.album_add_images(album, [id])
Example #3
0
def CreateAlbumAndUploadImages(albumName, albumDescription, images):
    access_token, refresh_token, client_id, client_secret = Config.getImgurKeys(
    )
    client = ImgurClient(client_id, client_secret)
    client.set_user_auth(access_token, refresh_token)
    fields = {}
    fields['title'] = albumName
    fields['description'] = albumDescription
    fields['privacy'] = 'public'
    x = client.create_album(fields)
    y = client.album_add_images(x['id'], images)
    return x
Example #4
0
def imgur_upload():
    client = ImgurClient(client_id, client_secret, access_token, refresh_token)

    albums = client.get_album_images("OKG9U3G")

    current_image_id = [image.id for image in albums]

    new_image_id = []
    for file in file_list:
        #        with open(os.devnull, "w") as f:
        #            subprocess.call(["ect", file], stdout=f)
        #        shutil.copy2(file, "/var/www/fgo.square.ovh/solomon-raid-stats/")
        id = client.upload_from_path(file, anon=False)["id"]
        new_image_id.append(id)
    print("{}: Uploaded to imgur".format(datetime.now()))

    for id in current_image_id:
        client.album_remove_images("OKG9U3G", id)

    for id in new_image_id:
        client.album_add_images("OKG9U3G", id)
    print("{}: Editted album".format(datetime.now()))
Example #5
0
    def add(self, client: ImgurClient, image_ids: list[int]) -> dict:
        """Add images to an album

        :param client: Imgur Client
        :type client: ImgurClient
        :param image_ids: list of image ids
        :type image_ids: list[int]
        :return: upload response
        :rtype: dict
        """
        logging.info(
            'Adding %d ids to album with deletehash "%s": %s',
            len(image_ids),
            self.deletehash,
            image_ids,
        )
        if not self.deletehash:
            logging.debug("Creating album to add imgs to.")
            self.create(client)
        return client.album_add_images(self.deletehash, image_ids)
Example #6
0
    'positive_album_id': '0XfM8',
    'negative_album_id': 'NX3p8'
}, {
    'album_id': '1EN5T',
    'positive_album_id': 'OthOo',
    'negative_album_id': 'jQIwZ'
}]


for album in albums:
    positive_images = []
    negative_images = []
    album_id = album['album_id']
    positive_album_id = album['positive_album_id']
    negative_album_id = album['negative_album_id']

    for image in client.get_album_images(album_id):
        webbrowser.open(image.link)
        answer = raw_input('Activity on picture? (y/n/s): ')
        if answer == 's':
            break
        elif answer == 'y':
            positive_images.append(image.id)
        else:
            negative_images.append(image.id)

    client.album_add_images(positive_album_id, positive_images)
    client.album_add_images(negative_album_id, negative_images)
    client.album_remove_images(album_id, positive_images)
    client.album_remove_images(album_id, negative_images)