您的位置:首页 > 教育 > 培训 > 中央人民政府网我要留言_深圳市建设有限公司_个人博客网站搭建_天津百度搜索排名优化

中央人民政府网我要留言_深圳市建设有限公司_个人博客网站搭建_天津百度搜索排名优化

2024/10/6 8:28:42 来源:https://blog.csdn.net/qq_37870369/article/details/142425037  浏览:    关键词:中央人民政府网我要留言_深圳市建设有限公司_个人博客网站搭建_天津百度搜索排名优化
中央人民政府网我要留言_深圳市建设有限公司_个人博客网站搭建_天津百度搜索排名优化

思路

  1. 将分享的链接转义成可以正常链接。
  2. 通过链接去找到对应的视频链接。
  3. 在通过返回的html。解析里面视频的资源链接在playAddr字段里面。
  4. 拿到链接后转义urlPath即可获取到资源信息。
  5. 下载视频。
  6. 科大讯飞语音转文本。
  7. 处理json保存到本地。

部分代码

获取抖音链接:

            String url = "6.43 复制打开抖音,看看【白浪源烟薯种植基地的作品】一旦找对了原产地,就很难在换其他家了,在我们家买过... https://v.douyin.com/ikagBCYn/ I@V.Lw mqe:/ 05/30  ";//过滤链接,获取http连接地址url = decodeHttpUrl(url);log.info("过滤后的链接地址:{}", url);//发起请求HttpResponse responseHref = HttpRequest.get(url).header("User-Agent", USER_AGENT).execute();String strUrlHref = responseHref.body();log.info("html地址:{}", strUrlHref);// 正则表达式用于匹配"video/"后面跟随的一系列数字Pattern pattern = Pattern.compile(regex);Matcher matcherUrlHref = pattern.matcher(strUrlHref);String videoId = null;

科大讯飞:

    private static String upload(String filePath) throws SignatureException, FileNotFoundException {HashMap<String, Object> map = new HashMap<>(16);File audio = new File(filePath);String fileName = audio.getName();long fileSize = audio.length();map.put("appId", appid);map.put("fileSize", fileSize);map.put("fileName", fileName);map.put("duration", "200");LfasrSignature lfasrSignature = new LfasrSignature(appid, keySecret);map.put("signa", lfasrSignature.getSigna());map.put("ts", lfasrSignature.getTs());String paramString = HttpUtil.parseMapToPathParam(map);log.info("upload paramString:" + paramString);String url = HOST + "/v2/api/upload" + "?" + paramString;log.info("upload_url:" + url);String response = HttpUtil.iflyrecUpload(url, new FileInputStream(audio));log.info("upload response:" + response);return response;}private static String getResult(String orderId, String writerFileNameAndPath) throws SignatureException, InterruptedException, IOException {HashMap<String, Object> map = new HashMap<>(16);map.put("orderId", orderId);LfasrSignature lfasrSignature = new LfasrSignature(appid, keySecret);map.put("signa", lfasrSignature.getSigna());map.put("ts", lfasrSignature.getTs());map.put("appId", appid);map.put("resultType", "transfer,predict");String paramString = HttpUtil.parseMapToPathParam(map);String url = HOST + "/v2/api/getResult" + "?" + paramString;log.info("\nget_result_url:" + url);while (true) {String response = HttpUtil.iflyrecGet(url);JsonParse jsonParse = gson.fromJson(response, JsonParse.class);if (jsonParse.content.orderInfo.status == 4 || jsonParse.content.orderInfo.status == -1) {log.info("转换响应完成:" + response);write(response, writerFileNameAndPath);return response;} else {log.info("进行中...,状态为:" + jsonParse.content.orderInfo.status);//建议使用回调的方式查询结果,查询接口有请求频率限制Thread.sleep(7000);}}}

需要的后台私信我。

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com