完善视频复刻

This commit is contained in:
Azmat@qq.com
2026-08-27 15:56:44 +08:00
parent 3fbc2f2dab
commit d2b786a3cf
10 changed files with 722 additions and 164 deletions
+19 -3
View File
@@ -59,6 +59,15 @@ def get_or_create_team_group(team) -> AssetReviewGroup:
return grp
def _volcano_asset_type(asset: Asset) -> str:
"""火山 CreateAsset 的 AssetType:视频必须传 Video,不能默认 Image。"""
if asset.asset_type == Asset.Type.VIDEO:
return "Video"
if asset.asset_type == Asset.Type.AUDIO:
return "Audio"
return "Image"
def submit_asset_for_review(asset: Asset, *, force: bool = False) -> bool:
"""真人资产送审:建组(若无)→ 传素材 → 标 processing。出错只记日志,不抛。
返回是否真正进入审核(True=已标 processing;False=未送审/未配置/失败),
@@ -70,12 +79,19 @@ def submit_asset_for_review(asset: Asset, *, force: bool = False) -> bool:
return False
if not force and asset.category not in Asset.REVIEW_CATEGORIES:
return False
if asset.review_remote_id and asset.review_status in ("active", "processing"):
return True
url = _asset_url(asset)
if not url:
return False
try:
grp = get_or_create_team_group(asset.team)
remote_id = assets_client.create_asset(group_id=grp.remote_group_id, image_url=url, name=(asset.name or "person")[:64])
remote_id = assets_client.create_asset(
group_id=grp.remote_group_id,
image_url=url,
name=(asset.name or "person")[:64],
asset_type=_volcano_asset_type(asset),
)
if not remote_id:
# 火山没回 Id:不要标 processing(否则 remote_id 为空、poll 永远早退、卡死黄),留空可重试
logger.warning("create_asset 返回空 id,asset %s 暂不送审(可重试)", asset.id)
@@ -128,11 +144,11 @@ def _unsubmitted_review_qs(*, team=None):
def _processing_review_qs(*, team=None):
# 不限 REVIEW_CATEGORIES:force 送审的上传视频/临时图也是 processing,worker 得盯到绿/红
qs = Asset.objects.filter(
category__in=Asset.REVIEW_CATEGORIES,
review_status="processing",
is_deleted=False,
)
).exclude(review_remote_id="")
if team is not None:
qs = qs.filter(team=team)
return qs