覆盖文生 3D、图生 3D、多视图、批量生成,以及重拓扑、绑定、动画、智能分割、 纹理、PBR、智能 UV、部件补全、格式导出与下载。 代码组织:一个功能一个模块(tripo/features/),入口薄壳 tripocli.py。
76 lines
2.4 KiB
Python
76 lines
2.4 KiB
Python
"""账户信息:积分余额、身份、免费额度。
|
|
|
|
tripocli balance | tripocli whoami | tripocli quota
|
|
"""
|
|
|
|
import time
|
|
|
|
from ..auth import decode_jwt_payload
|
|
|
|
|
|
def _balance(ctx):
|
|
data = ctx.client.payment_profile() or {}
|
|
wallet = data.get("wallet", {})
|
|
member = data.get("member", {})
|
|
ctx.out.data(
|
|
data,
|
|
human=lambda: (
|
|
ctx.out.line(f"剩余积分 : {wallet.get('total_credit', 0)}"),
|
|
ctx.out.line(f"即将过期 : {wallet.get('expiring_credit', 0)} (到期 {wallet.get('expiring_date', '无')})"),
|
|
ctx.out.line(f"会员等级 : {member.get('type', 'free')} (有效至 {member.get('valid_until', '无')})"),
|
|
),
|
|
)
|
|
return data
|
|
|
|
|
|
def _whoami(ctx):
|
|
client = ctx.client
|
|
info = {
|
|
"user_id": None,
|
|
"token_expires_at": None,
|
|
"account": client.account_name,
|
|
"token_source": client.token_source or ("account" if client.cookie else None),
|
|
}
|
|
payload = decode_jwt_payload(client.token or "")
|
|
info["user_id"] = payload.get("sub")
|
|
if payload.get("exp"):
|
|
info["token_expires_at"] = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(payload["exp"]))
|
|
|
|
profile = ctx.client.payment_profile() or {}
|
|
info["member"] = profile.get("member", {})
|
|
info["wallet"] = profile.get("wallet", {})
|
|
|
|
ctx.out.data(
|
|
info,
|
|
human=lambda: (
|
|
ctx.out.line(f"用户 ID : {info.get('user_id')}"),
|
|
ctx.out.line(f"Token 到期 : {info.get('token_expires_at')} ({info['token_source']})"),
|
|
ctx.out.line(f"积分余额 : {info.get('wallet', {}).get('total_credit', 0)}"),
|
|
),
|
|
)
|
|
return info
|
|
|
|
|
|
def _quota(ctx):
|
|
data = ctx.client.quota() or {}
|
|
quotas = data.get("quota", {})
|
|
|
|
def human():
|
|
for group, items in quotas.items():
|
|
for name, value in items.items():
|
|
ctx.out.line(f"{group}/{name}: 剩余 {value.get('remaining', 0)} / 共 {value.get('total_count', 0)}")
|
|
|
|
ctx.out.data(data, human=human)
|
|
return data
|
|
|
|
|
|
def register(subparsers):
|
|
parser = subparsers.add_parser("balance", help="查询积分余额与会员状态")
|
|
parser.set_defaults(func=_balance)
|
|
|
|
parser = subparsers.add_parser("whoami", help="查询当前身份与 token 有效期")
|
|
parser.set_defaults(func=_whoami)
|
|
|
|
parser = subparsers.add_parser("quota", help="查询特权/试用免费额度")
|
|
parser.set_defaults(func=_quota)
|