Exemplo n.º 1
0
Arquivo: test.py Projeto: Nexamic/yeet
 def imgurify(self, image):
     with open('credentials.json') as f:
         credentials = json.load(f)
     imgur = ImgurClient(credentials["Imgur"]["Authorization"],
                         credentials["Imgur"]["Secret"])
     text_obj = image.decode('UTF-8')
     resp = imgur.upload(text_obj)
     return resp
Exemplo n.º 2
0
def upload(fd, camera, date_taken):
    client = ImgurClient(CLIENT_ID, CLIENT_SECRET)
    config = {
        'title': 'New Spurs Stadium Camera {}'.format(camera),
        'description': 'New Tottenham Hotspur stadium build camera {} at {}'.format(
            camera, date_taken
        )
    }
    return client.upload(fd, config=config)['link']
Exemplo n.º 3
0
def upload_photo(image_path):
    client_id = os.environ.get("client_id")
    client_secret = os.environ.get("client_secret")
    access_token = os.environ.get("access_token")
    refresh_token = os.environ.get("refresh_token")
    client = ImgurClient(client_id, client_secret, access_token, refresh_token)
    album = None # can also enter an album ID here
    config = {
        'album': album,
    }
    print("Uploading image... ")
    with open(image_path, 'rb') as fd:
            image = client.upload(fd, config=None, anon=True)
            print("Done") 
            return image['link'] 

# if __name__ == "__main__":
#     find_param = {'q' : '生日'}
#     string = ['鞋子', '卡片', '手錶']
#     oldpath = crawler(string, find_param)
#     path = upload_photo(oldpath)
#     print(path)