package com.heyu.api.alibaba.handle.common.text;

import com.aliyun.ocr20191230.models.RecognizeVideoCharacterRequest;
import com.aliyun.ocr20191230.models.RecognizeVideoCharacterResponse;
import com.aliyun.teautil.models.RuntimeOptions;
import com.heyu.api.data.annotation.CustomPath;
import com.heyu.api.data.utils.StringUtils;
import com.heyu.api.alibaba.AlibabaBaseHandle;
import com.heyu.api.alibaba.request.common.text.ARecognizeVideoCharacterRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


/**
 * https://next.api.aliyun.com/api/ocr/2019-12-30/RecognizeVideoCharacter
 * <p>
 * 视频文字识别
 */
@Component
@Slf4j
@CustomPath("videoCharacter")
public class ARecognizeVideoCharacterHandle extends AlibabaBaseHandle<ARecognizeVideoCharacterRequest, RecognizeVideoCharacterResponse> {

    @Autowired
    private com.aliyun.ocr20191230.Client client;

    @Override
    public String check(ARecognizeVideoCharacterRequest aRecognizeVideoCharacterRequest) {

        return checkUrlBase64(aRecognizeVideoCharacterRequest);
    }


    @Override
    public RecognizeVideoCharacterResponse run(ARecognizeVideoCharacterRequest aRecognizeVideoCharacterRequest, RuntimeOptions runtime) throws Exception {
        RecognizeVideoCharacterRequest request = new RecognizeVideoCharacterRequest();
        request.setVideoURL(aRecognizeVideoCharacterRequest.getImageUrl());
        // 复制代码运行请自行打印 API 的返回值
        return client.recognizeVideoCharacterWithOptions(request, runtime);
    }
}
