修改頻道音訊審核設定
介面描述
1、<p>更新频道音频审核设置</p>
2、(timestamp, appId, channelId)参与sign签名,并和sign一起通过url传递,请求体参数不参与签名,通过post请求体传递【请设置请求头contentType:application/json】
3、接口支持https协议
4、按账号开通版本校验:audioModerationFunctionEnable 为 Y(金融版)或 AI(大模型版)即视为已开通;未开通(N、空或其他值)返回错误码 1041。请求体为合并结构,金融版提交金融版字段、大模型版提交大模型版字段,由服务端按账号版本校验【详见[校验规则](__PLV_KEEP_0__)】
介面URL
http://api.polyv.net/live/v4/channel/audio-moderation/update
請求方式
POST
介面限制
1、介面同時支援HTTP、HTTPS,建議使用HTTPS以確保介面安全,介面呼叫有頻率限制,詳細請查看
請求參數描述
| 參數名 | 必選 | 類型 | 說明 |
|---|---|---|---|
| appId | true | String | 帳號appId【詳見取得金鑰】 |
| channelId | true | String | 頻道ID |
| sign | true | String | 簽名,為32位大寫的MD5值,產生簽名的appSecret金鑰作為通訊資料安全的關鍵資訊,嚴禁儲存在用戶端直接使用,所有API都必須透過客戶自己伺服器中轉呼叫POLYV伺服器取得回應資料【詳見簽名產生規則】 |
| timestamp | true | String | 當前13位毫秒級時間戳,3分鐘內有效 |
請求體參數描述
| 參數名 | 必選 | 類型 | 說明 |
|---|---|---|---|
| badwordEnabled | true | String | 應用嚴禁詞開關,Y/N |
| customRule | false | String | 自訂審核規則(大模型版),最長2000字,llmAuditEnabled=Y 時生效 |
| illegalNotify | false | Object | 違規提醒配置【詳見IllegalNotify參數描述】 |
| llmAuditEnabled | false | String | 大模型審核開關,Y/N(大模型版) |
| moderationEnabled | true | String | 審核開關 Y:開啟 N:關閉 |
| moderationStrategy | false | String | 審核策略(金融版必填) easy:寬鬆審核策略 normal:一般審核策略 strict:嚴格審核策略 |
IllegalNotify參數描述
| 參數名 | 必選 | 類型 | 說明 |
|---|---|---|---|
| assistantEnabled | false | String | 助理提醒 Y:開啟 N:關閉 |
| monitorEnabled | false | String | 監播提醒 Y:開啟 N:關閉 |
| notifyLevel | false | String | 接收提醒等級(大模型版) all:所有風險項目 medium_plus:中風險及以上 high_only:僅高風險項目 |
| notifyUrl | false | String | 對外提醒URL(大模型版);為空表示關閉對外提醒,有值時違規事件會推送到該URL |
| platformEnabled | false | String | 平台通知 Y:開啟 N:關閉 |
| talentEnabled | false | String | 主播提醒 Y:開啟 N:關閉 |
校驗規則
1、帳號版本由 audioModerationFunctionEnable 判斷:Y=金融版、AI=大模型版;未開通(N、空或其他值)回傳錯誤碼 1041。 2、金融版:moderationStrategy 必填且合法(easy/normal/strict),未傳或非法回傳錯誤碼 30130。 3、大模型版:moderationEnabled=Y 時,llmAuditEnabled 與 badwordEnabled 至少一個為 Y,否則回傳錯誤碼 30131;moderationStrategy 可不傳,服務端落預設值 easy(不參與大模型版審核)。 4、llmAuditEnabled=Y 時,customRule 作為大模型審核規則儲存並參與審核;llmAuditEnabled=N 時 customRule 可保留但不參與審核。 5、notifyUrl 為空表示關閉對外提醒;notifyUrl 有值時按 notifyLevel 判斷需要推送的風險等級(notifyLevel 換算為 notifyScore 落庫:all=0、medium_plus=50、high_only=80)。 6、moderationEnabled=N 時,系統仍儲存子開關配置,但音訊審核不生效。
範例
http://api.polyv.net/live/v4/channel/audio-moderation/update?appId=gga9dadhzm&sign=4D6E18824022FB69A10142E788E2F184&channelId=3775168×tamp=1678088144335
請求體json參數:
金融版請求範例:
{
"moderationEnabled": "Y",
"moderationStrategy": "normal",
"badwordEnabled": "N",
"illegalNotify": {
"monitorEnabled": "Y",
"talentEnabled": "Y",
"assistantEnabled": "Y",
"platformEnabled": "Y"
}
}
大模型版請求範例:
{
"moderationEnabled": "Y",
"llmAuditEnabled": "Y",
"customRule": "禁止主播引导观众添加微信、QQ等社交账号进行私下交易;禁止主播在直播中提及其他竞品平台名称;禁止主播使用攻击性语言。",
"badwordEnabled": "Y",
"illegalNotify": {
"monitorEnabled": "Y",
"talentEnabled": "N",
"assistantEnabled": "Y",
"platformEnabled": "N",
"notifyUrl": "https://example.com/audio-moderation/callback",
"notifyLevel": "medium_plus"
}
}
回應參數描述
| 參數名 | 類型 | 說明 |
|---|---|---|
| code | Integer | 狀態碼,與 http 狀態碼相同,用於確定基本的回應狀態 |
| data | Boolean | 成功回應的資料 |
| error | Object | 狀態碼非200時的錯誤資訊【詳見Error參數描述】 |
| requestId | String | 請求ID,每次請求產生的唯一 UUID,僅可用於排查、除錯,不應該和業務掛鉤 |
| status | String | 回應結果,由業務決定,成功回傳success,失敗回傳error |
| success | Boolean | 是否成功回應 |
Error參數描述
| 參數名 | 類型 | 說明 |
|---|---|---|
| code | Integer | 錯誤代碼,用於確定具體的錯誤原因 |
| desc | String | 錯誤描述,與 error.code 對應 |
Java請求範例
快速接入基礎代碼請下載相關依賴原始碼, 點擊下載原始碼 ,下載後加入到自己的原始碼工程中即可。測試用例中的HttpUtil.java 和 LiveSignUtil.java 都包含在下載檔案中。
強烈建議您使用直播Java SDK完成API的功能對接,直播Java SDK 對API呼叫邏輯、異常處理、資料簽名、HTTP請求執行緒池進行了統一封裝和最佳化。
private static final Logger log = LoggerFactory.getLogger(getClass());
/**
* 更新频道音频审核设置
* @throws IOException
* @throws NoSuchAlgorithmException
*/
@Test
public void audioModerationUpdateTest() throws IOException, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String appId = super.appId;
String appSecret = super.appSecret;
String timestamp = String.valueOf(System.currentTimeMillis());
//业务参数
String url = "http://api.polyv.net/live/v4/channel/audio-moderation/update";
String channelId = "";
String badwordEnabled = "";
String illegalNotify = "";
String moderationEnabled = "";
String moderationStrategy = "";
String assistantEnabled = "";
String monitorEnabled = "";
String platformEnabled = "";
String talentEnabled = "";
//http 调用逻辑
Map<String, String> requestMap = new HashMap<>();
requestMap.put("appId", appId);
requestMap.put("timestamp", timestamp);
Map<String, Object> jsonMap = new HashMap<>();
jsonMap.put("channelId", channelId);
jsonMap.put("badwordEnabled", badwordEnabled);
jsonMap.put("illegalNotify", illegalNotify);
jsonMap.put("moderationEnabled", moderationEnabled);
jsonMap.put("moderationStrategy", moderationStrategy);
jsonMap.put("assistantEnabled", assistantEnabled);
jsonMap.put("monitorEnabled", monitorEnabled);
jsonMap.put("platformEnabled", platformEnabled);
jsonMap.put("talentEnabled", talentEnabled);
requestMap.put("sign", LiveSignUtil.getSign(requestMap, appSecret));
url = HttpUtil.appendUrl(url, requestMap);
String response = HttpUtil.postJsonBody(url, JSON.toJSONString(jsonMap), null);
log.info("测试更新频道音频审核设置成功:{}", response);
//do somethings
}
回應範例
系統全域錯誤說明詳見全域錯誤說明
成功範例
{
"code": 200,
"status": "success",
"requestId": "414afeb28f1c4f0ca17e1c3c1e39d247.13959.16780881532635057",
"data": true,
"success": true
}
異常範例
{
"code": 400,
"status": "error",
"requestId": "d310b70bc329403f87f77f9203d50f89.128.16360831552223589",
"error": {
"code": 20001,
"desc": "application not found."
},
"success": false
}
業務錯誤碼說明
| 錯誤碼 | 說明 |
|---|---|
| 1041 | 帳號未開啟音訊審核功能(audioModerationFunctionEnable 為 N、空或其他值) |
| 30130 | 審核策略不能為空(金融版 moderationStrategy 未傳或非法) |
| 30131 | 請至少開啟大模型審核或應用嚴禁詞(大模型版 moderationEnabled=Y 時 llmAuditEnabled 與 badwordEnabled 均未開啟) |
