您的位置:首页 > 财经 > 金融 > 找个网站你知道的_中国万网是做什么的_百度网盘电脑版下载_seo研究中心怎么了

找个网站你知道的_中国万网是做什么的_百度网盘电脑版下载_seo研究中心怎么了

2024/11/17 4:57:30 来源:https://blog.csdn.net/qq_53722480/article/details/142374582  浏览:    关键词:找个网站你知道的_中国万网是做什么的_百度网盘电脑版下载_seo研究中心怎么了
找个网站你知道的_中国万网是做什么的_百度网盘电脑版下载_seo研究中心怎么了

在此声明,本内容仅供个人学习、研究或娱乐之用,严禁任何形式的商业用途。若您发现本内容被用于商业目的,请立即删除,及时与小编联系,我们将删除原代码。

请根据上一篇文章使用该代码:SpringBoot 整合酷狗获取下载音乐(需要自己账户)-CSDN博客

1.KuGouUtil 工具类

    /*** mv搜索验签 (源码)*/public static String mvMd5SignSearch(String timestamp,KuGouHand hand) {String[] signatureList = {"NVPh5oo715z5DIWAeQlhMDsWXXQV4hwt","appid="+hand.getAppid(),"clienttime="+timestamp,"clientver=20000","dfid="+hand.getDfid(),"mid="+hand.getMid(),"mvid="+hand.getMvid(),"srcappid="+hand.getSrcappid(),"userid="+hand.getUserid(),"uuid="+hand.getUuid(),"NVPh5oo715z5DIWAeQlhMDsWXXQV4hwt"};StringBuilder stringBuilder = new StringBuilder();for (String s : signatureList) {stringBuilder.append(s);}String string = stringBuilder.toString();return getMD5(string);}/*** 获取Mv信息 (源码)*/public static List<KuGoMv> getKuGouMvList(Headers headers,long timestamp, KuGouHand hand) throws IOException {List<KuGoMv> kuGoMvList = new ArrayList<>();String sign = mvMd5SignSearch(String.valueOf(timestamp),hand);LinkedHashMap<String, String> param = new LinkedHashMap<>();param.put("srcappid", hand.getSrcappid());param.put("clientver", "20000");param.put("clienttime", String.valueOf(timestamp));param.put("mid", hand.getMid());param.put("uuid", hand.getUuid());param.put("dfid",hand.getDfid());param.put("appid", hand.getAppid());param.put("mvid", hand.getMvid());param.put("userid", hand.getUserid());param.put("signature", sign);OkHttpClient client = new OkHttpClient();String url = "https://gateway.kugou.com/mixedvideo/v1/relatedVideo/list" + GetParams(param);Request request = new Request.Builder().url(url).headers(headers).build();Response response = client.newCall(request).execute();String responseBody = response.body().string();if (response.isSuccessful()) {Gson gson = new Gson();Type type = new TypeToken<Map<String, Object>>() {}.getType();Map<String, Object> map = gson.fromJson(responseBody, type);if (String.valueOf(map.get("errcode")) =="0.0" || String.valueOf(map.get("errcode"))=="0"){kuGoMvList = JSON.parseArray(JSON.toJSONString(map.get("data")), KuGoMv.class);for (KuGoMv item:kuGoMvList){item.setPlayDuration(getSeconds(item.getDuration()/1000));}return kuGoMvList;}}return kuGoMvList;}/*** 获取MV 播放地址的MD5验签 (源码)*/public static String setMvMd5Sign(long timestamp,KuGouHand hand) {String[] signatureList = {"NVPh5oo715z5DIWAeQlhMDsWXXQV4hwt","appid="+hand.getAppid(),"clienttime="+timestamp,"clientver=1000","dfid="+hand.getDfid(),"id="+hand.getMvid(),"mid="+hand.getMid(),"srcappid="+hand.getSrcappid(),"uuid="+hand.getUuid(),"NVPh5oo715z5DIWAeQlhMDsWXXQV4hwt"};StringBuilder stringBuilder = new StringBuilder();for (String s : signatureList) {stringBuilder.append(s);}String string = stringBuilder.toString();return getMD5(string);}/*** 获取酷狗音乐播放地址MV (源码)*/public static KuGoMv getKuGouMvMp4(Headers headers,long timestamp,KuGouHand hand,KuGoMv kuGoMv) throws IOException {String sign = setMvMd5Sign(timestamp,hand);LinkedHashMap<String, String> param = new LinkedHashMap<>();param.put("srcappid", hand.getSrcappid());param.put("clientver", "1000");param.put("clienttime", String.valueOf(timestamp));param.put("mid", hand.getMid());param.put("uuid", hand.getUuid());param.put("dfid",hand.getDfid());param.put("appid", hand.getAppid());param.put("id", hand.getMvid());param.put("signature", sign);OkHttpClient client = new OkHttpClient();String url = "https://wwwapi.kugou.com/play/mv" + GetParams(param);Request request = new Request.Builder().url(url).headers(headers).build();Response response = client.newCall(request).execute();String responseBody = response.body().string();if (response.isSuccessful()) {Gson gson = new Gson();Type type = new TypeToken<Map<String, Object>>() {}.getType();Map<String, Object> map = gson.fromJson(responseBody, type);String code = map.get("status").toString().replace(".0","");if (code.equals("1")){Map<String, Object> map2 = gson.fromJson(JSON.toJSONString(map.get("data")), type);Type type2 = new TypeToken<Map<String, Map<String,Object>>>() {}.getType();HashMap<String,Map<String,Object>> privileges = JSON.parseObject(JSON.toJSONString(map2.get("privilege")), type2);HashMap<String,Map<String,Object>> plays = JSON.parseObject(JSON.toJSONString(map2.get("play")), type2);if (privileges.size()>=1 && plays.size()>=1){Integer level = 0;String hashName = "";for (Map.Entry<String, Map<String, Object>> entry : privileges.entrySet()) {Map<String, Object> value = entry.getValue();Integer innerValue = Integer.parseInt(String.valueOf(value.get("level")).replace(".0",""));if (innerValue >=level){level=innerValue;hashName = entry.getKey();String[] mvList = String.valueOf(value.get("name")).split("-");kuGoMv.setMvName(mvList[1]);kuGoMv.setSingerName(String.valueOf(value.get("singer_name")));kuGoMv.setLevel(innerValue);}}for (Map.Entry<String, Map<String, Object>> entry : plays.entrySet()) {Map<String, Object> value = entry.getValue();if (entry.getKey().equals(hashName)){kuGoMv.setDownUrl(String.valueOf(value.get("downurl")));kuGoMv.setPlayUrl(value.get("backupdownurl"));}}return kuGoMv;}}}return kuGoMv;}

 2.ToolUtil

   /*** duration 时长转分秒*/public static String getSeconds(Integer num){try {long totalSeconds = Duration.ofSeconds(num).getSeconds();long minutes = totalSeconds / 60;long seconds = totalSeconds % 60;return String.format("%d:%02d", minutes, seconds);}catch (Exception e){return String.valueOf(num);}}/*** 参数装换GET*/public static String GetParams(Map<String, String> params) {StringBuilder result = new StringBuilder();for (Map.Entry<String, String> entry : params.entrySet()) {if (result.length() > 0) {result.append("&");}result.append(entry.getKey()).append("=").append(entry.getValue());}return "?"+result.toString();}/*** 获取所有请求头信息* type true 代表开启条件设置*/public static Headers getHeaders(HttpServletRequest request,String[] strings,Boolean type ) {Headers.Builder headersBuilder = new Headers.Builder();Enumeration<String> headerNames = request.getHeaderNames();while (headerNames.hasMoreElements()) {String headerName = headerNames.nextElement();if (type){if (strings.toString().contains(headerName)) {Enumeration<String> v = request.getHeaders(headerName);while (v.hasMoreElements()) {String value = v.nextElement();headersBuilder.add(headerName, value);}}}else {Enumeration<String> v = request.getHeaders(headerName);while (v.hasMoreElements()) {String value = v.nextElement();headersBuilder.add(headerName, value);}}}return headersBuilder.build();}

版权声明:

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

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