#!/usr/bin/env python3
import sys
import requests
import os
# 配置信息(根据你的图床修改)
CONFIG = {
"api_url": "https://tc.cuirx.me/api/v1/upload",
"token": "1|8Fh6gNbdAaQM8QtCX8yKc74JgLfB7OxqrYvxtn4S", # Bearer Token
"album_id": None, # 可选相册ID
"strategy": "default" # 存储策略
}
def upload_image(image_path):
headers = {
"Authorization": f"Bearer {CONFIG['token']}"
}
files = {
'file': (os.path.basename(image_path),
open(image_path, 'rb').read())
}
data = {
"album_id": CONFIG['album_id'],
"strategy": CONFIG['strategy']
}
try:
response = requests.post(
CONFIG['api_url'],
headers=headers,
files=files,
data=data
)
result = response.json()
if response.status_code == 200 and result.get("status"):
return result["data"]["links"]["url"]
else:
return f"Error: {result.get('message', 'Unknown error')}"
except Exception as e:
return f"Exception: {str(e)}"
if __name__ == '__main__':
if len(sys.argv) < 2:
print("Usage: python lskypro_uploader.py <image_path>")
sys.exit(1)
image_path = sys.argv[1]
result = upload_image(image_path)
print(result)