2023年4月22日18:19:21
parent
76dd77525d
commit
bbf87a33ad
17
pom.xml
17
pom.xml
|
|
@ -377,6 +377,23 @@
|
|||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>${swagger.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.openfeign</groupId>
|
||||
<artifactId>feign-core</artifactId>
|
||||
<version>10.12</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.odpi.egeria/http-helper -->
|
||||
<dependency>
|
||||
<groupId>org.odpi.egeria</groupId>
|
||||
<artifactId>http-helper</artifactId>
|
||||
<version>3.15</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-web</artifactId>
|
||||
<version>5.3.25</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.zhangmeng.tools.controller;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.http.Header;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
|
|
@ -8,12 +9,18 @@ import com.alibaba.fastjson.JSON;
|
|||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.common.base.Utf8;
|
||||
import com.zhangmeng.tools.music.SongInfo;
|
||||
import com.zhangmeng.tools.music.kugou.KuGouMusic;
|
||||
import com.zhangmeng.tools.music.kuwo.DownLoadInfo;
|
||||
import com.zhangmeng.tools.music.kuwo.DownLoadURL;
|
||||
import com.zhangmeng.tools.music.kuwo.SearchByKey;
|
||||
import com.zhangmeng.tools.music.qq.QQMusic;
|
||||
import com.zhangmeng.tools.music.qq.QqEncrypt;
|
||||
import com.zhangmeng.tools.music.qq.QqQuery;
|
||||
import com.zhangmeng.tools.music.wangyiyun.Song;
|
||||
import com.zhangmeng.tools.music.wangyiyun.WangYiYunMusic;
|
||||
import com.zhangmeng.tools.utils.AlertUtils;
|
||||
import javafx.beans.property.SimpleIntegerProperty;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.collections.FXCollections;
|
||||
|
|
@ -22,21 +29,31 @@ import javafx.fxml.FXML;
|
|||
import javafx.scene.control.*;
|
||||
import javafx.scene.control.cell.PropertyValueFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.sql.Blob;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import static com.zhangmeng.tools.music.qq.RequestModule.apiServer;
|
||||
import static com.zhangmeng.tools.music.qq.RequestModule.headerMap;
|
||||
|
||||
/**
|
||||
* @author : 芊芊墨客
|
||||
|
|
@ -77,6 +94,15 @@ public class MusicDownloadController {
|
|||
|
||||
private SimpleIntegerProperty index = new SimpleIntegerProperty(0);
|
||||
|
||||
public static final String ku_wo_vip_api = "http://www.kuwo.cn/api/www/search/searchMusicBykeyWord?pn=1&rn=30&httpsStatus=1&reqId=a3d144b0-9570-11ed-9918-83c8c32b357d&key=";
|
||||
|
||||
public static String download_url = "http://www.kuwo.cn/api/v1/www/music/playUrl?type=convert_url3&httpsStatus=1";
|
||||
|
||||
public static SimpleObjectProperty<DownLoadInfo> down_load_info = new SimpleObjectProperty<>();
|
||||
public static SimpleObjectProperty<SearchByKey> data_bean = new SimpleObjectProperty<>();
|
||||
|
||||
public static RestTemplate restTemplate;
|
||||
|
||||
@FXML
|
||||
public void initialize() {
|
||||
wangyiyun_music_init();
|
||||
|
|
@ -114,8 +140,8 @@ public class MusicDownloadController {
|
|||
switch (index.get()) {
|
||||
case 0 -> set(wangyiyun_music_table_view, get_wangyiyun_song_info(title));
|
||||
case 1 -> set(QQ_music_table_view,get_qq_song_info(title));
|
||||
// case 2 -> set(kugou_music_table_view);
|
||||
// case 3 -> set(kuwo_music_table_view);
|
||||
case 2 -> set(kugou_music_table_view,get_ku_gou_info(title));
|
||||
case 3 -> set(kuwo_music_table_view,get_kuwo_song_info(title));
|
||||
// case 4 -> set(migu_music_table_view);
|
||||
// case 5 -> set(qianqian_music_table_view);
|
||||
}
|
||||
|
|
@ -123,9 +149,88 @@ public class MusicDownloadController {
|
|||
|
||||
}
|
||||
|
||||
public ObservableList<SongInfo> get_ku_gou_info(String title){
|
||||
|
||||
URL.createObjectURL(new Blob());
|
||||
|
||||
String api = "https://songsearch.kugou.com/song_search_v2";
|
||||
ObservableList<SongInfo> list = FXCollections.observableArrayList();
|
||||
HashMap<String, Object> paramMap = new HashMap<>();
|
||||
paramMap.put("keyword", title);
|
||||
paramMap.put("page", 1);
|
||||
|
||||
String result3= HttpUtil.get(api, paramMap);
|
||||
KuGouMusic kuGouMusic = JSON.parseObject(result3, KuGouMusic.class);
|
||||
if (kuGouMusic.getData() != null){
|
||||
List<KuGouMusic.ResList> lists = kuGouMusic.getData().getLists();
|
||||
int id = 1;
|
||||
for (KuGouMusic.ResList resList : lists) {
|
||||
SongInfo songInfo = new SongInfo();
|
||||
songInfo.setName( resList.getSongName());
|
||||
songInfo.setArtist(resList.getSingerName());
|
||||
songInfo.setAlbum(resList.getAlbumName());
|
||||
songInfo.setId(id);
|
||||
id ++;
|
||||
list.add(songInfo);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public ObservableList<SongInfo> get_kuwo_song_info(String title){
|
||||
ObservableList<SongInfo> list = FXCollections.observableArrayList();
|
||||
List<SongInfo> lists = request_api(title);
|
||||
int i = 0 ;
|
||||
for (SongInfo listBean : lists) {
|
||||
i = i + 1 ;
|
||||
listBean.setId(i);
|
||||
list.add(listBean);
|
||||
}
|
||||
|
||||
return list;
|
||||
// inputStream = response.getEntity().getContent();
|
||||
// byte[] buffer = new byte[1024];
|
||||
// int readBytes = 0;
|
||||
// StringBuilder stringBuilder = new StringBuilder();
|
||||
// while((readBytes = inputStream.read(buffer)) > 0){
|
||||
// Thread.sleep(1);
|
||||
// stringBuilder.append(new String(buffer, 0, readBytes));
|
||||
// }
|
||||
}
|
||||
|
||||
public static List<SongInfo> request_api(String key) {
|
||||
String headers_json_path = MusicDownloadController.class.getClassLoader().getResource("headers.json").toExternalForm();
|
||||
try {
|
||||
List<String> list = FileUtil.readLines(new URL(headers_json_path), StandardCharsets.UTF_8);
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
list.forEach(stringBuilder::append);
|
||||
String headers_json = stringBuilder.toString();
|
||||
Map<String, String> map = JSONObject.parseObject(headers_json, Map.class);
|
||||
|
||||
MultiValueMap<String, String> headers = new HttpHeaders();
|
||||
for (Map.Entry<String, String> entry : map.entrySet()) {
|
||||
headers.add(entry.getKey(), entry.getValue());
|
||||
}
|
||||
HttpEntity<Map<String, String>> httpEntity = new HttpEntity<>(headers);
|
||||
|
||||
if (restTemplate == null){
|
||||
restTemplate = new RestTemplate();
|
||||
}
|
||||
SearchByKey result = restTemplate.exchange(ku_wo_vip_api + key, HttpMethod.GET, httpEntity, SearchByKey.class).getBody();
|
||||
if (result != null){
|
||||
data_bean.setValue(result);
|
||||
return result.getData().getList();
|
||||
}
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public ObservableList<SongInfo> get_qq_song_info(String title){
|
||||
ObservableList<SongInfo> list = FXCollections.observableArrayList();
|
||||
String api = "https://u.y.qq.com/cgi-bin/musicu.fcg";
|
||||
//String api = "https://u.y.qq.com/cgi-bin/musicu.fcg";
|
||||
QqQuery query = new QqQuery();
|
||||
QqQuery.Comm comm = new QqQuery.Comm("19", "1859", "0");
|
||||
query.setComm(comm);
|
||||
|
|
@ -142,15 +247,12 @@ public class MusicDownloadController {
|
|||
req.setParam(param);
|
||||
query.setReq(req);
|
||||
String q = JSON.toJSONString(query);
|
||||
|
||||
Map<String,String> headerMap=new HashMap<>();
|
||||
headerMap.put("user-agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36 Edg/87.0.664.66");
|
||||
headerMap.put("accept-encoding","application/json");
|
||||
headerMap.put("cache-control","max-age=0");
|
||||
|
||||
|
||||
String result2 = HttpRequest.post(api).headerMap(headerMap,false).header()
|
||||
.form(q)//表单内容
|
||||
Random ran=new Random(System.currentTimeMillis());
|
||||
String result2 = HttpRequest.post(apiServer[ran.nextInt(apiServer.length)])
|
||||
.header("user-agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36 Edg/87.0.664.66")
|
||||
.header("accept-encoding","application/json")
|
||||
.form("sign",getSign(q))//表单内容
|
||||
.body(q)
|
||||
.timeout(20000)//超时,毫秒
|
||||
.execute().body();
|
||||
QQMusic qqMusic = JSON.parseObject(result2, QQMusic.class);
|
||||
|
|
@ -174,6 +276,10 @@ public class MusicDownloadController {
|
|||
return list;
|
||||
}
|
||||
|
||||
public String getSign(String params){
|
||||
return QqEncrypt.getSign(JSON.toJSONString(params));
|
||||
}
|
||||
|
||||
public ObservableList<SongInfo> get_wangyiyun_song_info(String title) {
|
||||
ObservableList<SongInfo> list = FXCollections.observableArrayList();
|
||||
String api = "https://music.163.com/api/search/pc";
|
||||
|
|
@ -215,23 +321,23 @@ public class MusicDownloadController {
|
|||
}
|
||||
|
||||
|
||||
// public static void set_songInfo(SongInfo listBean){
|
||||
// String req_id = data_bean.getValue().getReqId();
|
||||
// int mid = listBean.getRid();
|
||||
// String url = download_url + "&reqId=" + req_id + "&mid=" + mid;
|
||||
// if (restTemplate == null){
|
||||
// restTemplate = new RestTemplate();
|
||||
// }
|
||||
// DownLoadURL result = restTemplate.getForObject(url ,DownLoadURL.class);
|
||||
// if (result != null){
|
||||
// String url1 = result.getData().getUrl();
|
||||
// DownLoadInfo loadInfo = new DownLoadInfo();
|
||||
// loadInfo.setSong_url(url1);
|
||||
// loadInfo.setSong_name(listBean.getName());
|
||||
// loadInfo.setSong_author(listBean.getArtist());
|
||||
// down_load_info.set(loadInfo);
|
||||
// }
|
||||
// }
|
||||
public static void set_songInfo(SongInfo listBean){
|
||||
String req_id = data_bean.getValue().getReqId();
|
||||
int mid = listBean.getRid();
|
||||
String url = download_url + "&reqId=" + req_id + "&mid=" + mid;
|
||||
if (restTemplate == null){
|
||||
restTemplate = new RestTemplate();
|
||||
}
|
||||
DownLoadURL result = restTemplate.getForObject(url ,DownLoadURL.class);
|
||||
if (result != null){
|
||||
String url1 = result.getData().getUrl();
|
||||
DownLoadInfo loadInfo = new DownLoadInfo();
|
||||
loadInfo.setSong_url(url1);
|
||||
loadInfo.setSong_name(listBean.getName());
|
||||
loadInfo.setSong_author(listBean.getArtist());
|
||||
down_load_info.set(loadInfo);
|
||||
}
|
||||
}
|
||||
//
|
||||
// public static void download_song(){
|
||||
// String path = "C:/Users/Administrator/Desktop/";
|
||||
|
|
|
|||
|
|
@ -0,0 +1,348 @@
|
|||
package com.zhangmeng.tools.music.kugou;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author : 芊芊墨客
|
||||
* @version : 1.0
|
||||
* @date : 2023-04-22 17:33
|
||||
*/
|
||||
@Data
|
||||
public class KuGouMusic {
|
||||
|
||||
@Data
|
||||
public static class Aggregation {
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Classmap {
|
||||
public Integer attr0;
|
||||
}
|
||||
@Data
|
||||
public static class Classmap__1 {
|
||||
public Integer attr0;
|
||||
}
|
||||
@Data
|
||||
public class ResData {
|
||||
|
||||
public String correctiontip;
|
||||
public Integer pagesize;
|
||||
public Integer page;
|
||||
public Integer correctiontype;
|
||||
public Integer total;
|
||||
public java.util.List<ResList> lists = new ArrayList<>();
|
||||
public SecAggre secAggre;
|
||||
public Aggregation aggregation;
|
||||
public Integer size;
|
||||
public Integer searchfull;
|
||||
public Integer chinesecount;
|
||||
public Integer istagresult;
|
||||
public Integer allowerr;
|
||||
public java.util.List<Object> secAggreV2 = new ArrayList<>();
|
||||
public Integer correctionforce;
|
||||
public Integer istag;
|
||||
public Integer from;
|
||||
public SectagInfo sectagInfo;
|
||||
public Integer subjecttype;
|
||||
public Integer isshareresult;
|
||||
public String correctionsubject;
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Grp {
|
||||
public String sQFileHash;
|
||||
public String publishTime;
|
||||
public Integer audioid;
|
||||
public Integer superDuration;
|
||||
public Integer oldCpy;
|
||||
public Integer publishAge;
|
||||
public Integer hQBitrate;
|
||||
public Integer payType;
|
||||
public String tagContent;
|
||||
public Integer accompany;
|
||||
public String singerName;
|
||||
public Integer hQPrivilege;
|
||||
public String topicRemark;
|
||||
public String oriOtherName;
|
||||
public String source;
|
||||
public Integer resDuration;
|
||||
public Integer sQFileSize;
|
||||
public String albumAux;
|
||||
public Integer hQDuration;
|
||||
public Integer failProcess;
|
||||
public Integer hQPayType;
|
||||
public Integer m4aSize;
|
||||
public Integer sQPkgPrice;
|
||||
public String uploaderContent;
|
||||
public String sQExtName;
|
||||
public Integer isOriginal;
|
||||
public String fileHash;
|
||||
public Integer mvTrac;
|
||||
public String type;
|
||||
public Integer bitrate;
|
||||
public Integer sQPrice;
|
||||
public String extName;
|
||||
public Integer category;
|
||||
public String superExtName;
|
||||
public TransParam__1 transParam;
|
||||
public String otherName;
|
||||
public String songName;
|
||||
public Integer aSQPrivilege;
|
||||
public Integer audioCdn;
|
||||
public Integer sourceID;
|
||||
public Integer sQDuration;
|
||||
public Integer hQFileSize;
|
||||
public Integer pkgPrice;
|
||||
public Integer sQPayType;
|
||||
public Integer albumPrivilege;
|
||||
public String albumID;
|
||||
public Integer hQPrice;
|
||||
public String suffix;
|
||||
public Integer hQFailProcess;
|
||||
public String albumName;
|
||||
public List<Mvdatum> mvdata = new ArrayList<>();
|
||||
public String vvid;
|
||||
public Integer hiFiQuality;
|
||||
public String mixSongID;
|
||||
public List<Integer> singerId = new ArrayList<>();
|
||||
public Integer superBitrate;
|
||||
public String hQExtName;
|
||||
public String resFileHash;
|
||||
public Integer matchFlag;
|
||||
public Integer scid;
|
||||
public String superFileHash;
|
||||
public Integer qualityLevel;
|
||||
public String oriSongName;
|
||||
public Integer resBitrate;
|
||||
public List<Singer> singers = new ArrayList<>();
|
||||
public Integer superFileSize;
|
||||
public String songLabel;
|
||||
public Integer hasAlbum;
|
||||
public Integer sQBitrate;
|
||||
public Integer mvType;
|
||||
public Integer mvTotal;
|
||||
public String mvHash;
|
||||
public String hQFileHash;
|
||||
public String topicUrl;
|
||||
public Integer recommendType;
|
||||
public String auxiliary;
|
||||
public Integer privilege;
|
||||
public Integer fileSize;
|
||||
public Integer duration;
|
||||
public Integer ownerCount;
|
||||
public String uploader;
|
||||
public Integer sQFailProcess;
|
||||
public String id;
|
||||
public Integer topID;
|
||||
public Integer hQPkgPrice;
|
||||
public Integer a320Privilege;
|
||||
public String fileName;
|
||||
public Integer resFileSize;
|
||||
public Integer sQPrivilege;
|
||||
public Integer price;
|
||||
public Integer publish;
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class ResList {
|
||||
|
||||
public String sQFileHash;
|
||||
public String publishTime;
|
||||
public Integer audioid;
|
||||
public Integer superDuration;
|
||||
public Integer oldCpy;
|
||||
public Integer publishAge;
|
||||
public Integer hQBitrate;
|
||||
public Integer payType;
|
||||
public String tagContent;
|
||||
public Integer accompany;
|
||||
public String singerName;
|
||||
public Integer foldType;
|
||||
public Integer hQPrivilege;
|
||||
public String topicRemark;
|
||||
public String oriOtherName;
|
||||
public String source;
|
||||
public Integer resDuration;
|
||||
public Integer sQFileSize;
|
||||
public String albumAux;
|
||||
public Integer hQDuration;
|
||||
public Integer failProcess;
|
||||
public Integer hQPayType;
|
||||
public Integer m4aSize;
|
||||
public Integer sQPkgPrice;
|
||||
public String uploaderContent;
|
||||
public String sQExtName;
|
||||
public Integer isOriginal;
|
||||
public String fileHash;
|
||||
public Integer mvTrac;
|
||||
public String type;
|
||||
public Integer bitrate;
|
||||
public Integer sQPrice;
|
||||
public String extName;
|
||||
public TransParam transParam;
|
||||
public Integer category;
|
||||
public String superExtName;
|
||||
public String otherName;
|
||||
public String songName;
|
||||
public Integer aSQPrivilege;
|
||||
public Integer audioCdn;
|
||||
public Integer sourceID;
|
||||
public Integer sQDuration;
|
||||
public Integer hQFileSize;
|
||||
public java.util.List<Grp> grp = new ArrayList<>();
|
||||
public Integer pkgPrice;
|
||||
public Integer sQPayType;
|
||||
public Integer albumPrivilege;
|
||||
public String albumID;
|
||||
public Integer hQPrice;
|
||||
public String suffix;
|
||||
public Integer hQFailProcess;
|
||||
public String albumName;
|
||||
public java.util.List<Mvdatum__1> mvdata = new ArrayList<>();
|
||||
public String vvid;
|
||||
public Integer hiFiQuality;
|
||||
public String mixSongID;
|
||||
public java.util.List<Integer> singerId = new ArrayList<>();
|
||||
public Integer superBitrate;
|
||||
public String hQExtName;
|
||||
public String resFileHash;
|
||||
public Integer matchFlag;
|
||||
public Integer scid;
|
||||
public String superFileHash;
|
||||
public Integer qualityLevel;
|
||||
public String oriSongName;
|
||||
public Integer resBitrate;
|
||||
public java.util.List<Singer__1> singers = new ArrayList<>();
|
||||
public Integer superFileSize;
|
||||
public String songLabel;
|
||||
public Integer hasAlbum;
|
||||
public Integer sQBitrate;
|
||||
public Integer mvType;
|
||||
public Integer mvTotal;
|
||||
public String mvHash;
|
||||
public String hQFileHash;
|
||||
public String topicUrl;
|
||||
public Integer recommendType;
|
||||
public String auxiliary;
|
||||
public Integer privilege;
|
||||
public Integer fileSize;
|
||||
public Integer duration;
|
||||
public Integer ownerCount;
|
||||
public String uploader;
|
||||
public Integer sQFailProcess;
|
||||
public String id;
|
||||
public Integer topID;
|
||||
public Integer hQPkgPrice;
|
||||
public Integer a320Privilege;
|
||||
public String fileName;
|
||||
public Integer resFileSize;
|
||||
public Integer sQPrivilege;
|
||||
public Integer price;
|
||||
public Integer publish;
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Mvdatum {
|
||||
|
||||
public String id;
|
||||
public String trk;
|
||||
public String hash;
|
||||
public Integer typ;
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Mvdatum__1 {
|
||||
|
||||
public String id;
|
||||
public String trk;
|
||||
public String hash;
|
||||
public Integer typ;
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Qualitymap {
|
||||
|
||||
public Integer attr0;
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Qualitymap__1 {
|
||||
|
||||
public Integer attr0;
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class SecAggre {
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class SectagInfo {
|
||||
|
||||
public Integer isSectag;
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Singer {
|
||||
|
||||
public String name;
|
||||
public Integer ipId;
|
||||
public Integer id;
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Singer__1 {
|
||||
|
||||
public String name;
|
||||
public Integer ipId;
|
||||
public Integer id;
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class TransParam {
|
||||
|
||||
public Integer payBlockTpl;
|
||||
public Classmap classmap;
|
||||
public Integer cid;
|
||||
public Integer cpyAttr0;
|
||||
public String hashMultitrack;
|
||||
public Qualitymap qualitymap;
|
||||
public Integer musicpackAdvance;
|
||||
public Integer display;
|
||||
public Integer displayRate;
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class TransParam__1 {
|
||||
|
||||
public Integer payBlockTpl;
|
||||
public Classmap__1 classmap;
|
||||
public Integer cid;
|
||||
public Integer cpyAttr0;
|
||||
public String hashMultitrack;
|
||||
public Qualitymap__1 qualitymap;
|
||||
public Integer musicpackAdvance;
|
||||
public Integer display;
|
||||
public Integer displayRate;
|
||||
|
||||
}
|
||||
|
||||
public String errorMsg;
|
||||
public ResData data;
|
||||
public Integer status;
|
||||
public Integer errorCode;
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
package com.zhangmeng.tools.music.kuwo;
|
||||
|
||||
/**
|
||||
* @author : 芊芊墨客
|
||||
* @version : 1.0
|
||||
* @date : 2023-04-22 17:11
|
||||
*/
|
||||
public class DownLoadInfo {
|
||||
private String song_url;
|
||||
private String song_name;
|
||||
private String song_author;
|
||||
|
||||
public DownLoadInfo() {
|
||||
}
|
||||
|
||||
public DownLoadInfo(String song_url, String song_name, String song_author) {
|
||||
this.song_url = song_url;
|
||||
this.song_name = song_name;
|
||||
this.song_author = song_author;
|
||||
}
|
||||
|
||||
public String getSong_url() {
|
||||
return song_url;
|
||||
}
|
||||
|
||||
public void setSong_url(String song_url) {
|
||||
this.song_url = song_url;
|
||||
}
|
||||
|
||||
public String getSong_name() {
|
||||
return song_name;
|
||||
}
|
||||
|
||||
public void setSong_name(String song_name) {
|
||||
this.song_name = song_name;
|
||||
}
|
||||
|
||||
public String getSong_author() {
|
||||
return song_author;
|
||||
}
|
||||
|
||||
public void setSong_author(String song_author) {
|
||||
this.song_author = song_author;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,90 @@
|
|||
package com.zhangmeng.tools.music.kuwo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class DownLoadURL {
|
||||
|
||||
|
||||
/**
|
||||
* code : 200
|
||||
* msg : success
|
||||
* reqId : c7fe6fc8f706887a55d212874d085682
|
||||
* data : {"url":"https://other-web-ra01-sycdn.kuwo.cn/9a2886aa582be88eff47806f8c8680a0/63c5ff15/resource/n3/320/81/60/2729835609.mp3"}
|
||||
* profileId : site
|
||||
* curTime : 1673920277475
|
||||
* success : true
|
||||
*/
|
||||
|
||||
private int code;
|
||||
private String msg;
|
||||
private String reqId;
|
||||
private URL data;
|
||||
private String profileId;
|
||||
private long curTime;
|
||||
private boolean success;
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public String getReqId() {
|
||||
return reqId;
|
||||
}
|
||||
|
||||
public void setReqId(String reqId) {
|
||||
this.reqId = reqId;
|
||||
}
|
||||
|
||||
public String getProfileId() {
|
||||
return profileId;
|
||||
}
|
||||
|
||||
public void setProfileId(String profileId) {
|
||||
this.profileId = profileId;
|
||||
}
|
||||
|
||||
public long getCurTime() {
|
||||
return curTime;
|
||||
}
|
||||
|
||||
public void setCurTime(long curTime) {
|
||||
this.curTime = curTime;
|
||||
}
|
||||
|
||||
public boolean isSuccess() {
|
||||
return success;
|
||||
}
|
||||
|
||||
public void setSuccess(boolean success) {
|
||||
this.success = success;
|
||||
}
|
||||
|
||||
public static class URL {
|
||||
/**
|
||||
* url : https://other-web-ra01-sycdn.kuwo.cn/9a2886aa582be88eff47806f8c8680a0/63c5ff15/resource/n3/320/81/60/2729835609.mp3
|
||||
*/
|
||||
|
||||
private String url;
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,60 @@
|
|||
package com.zhangmeng.tools.music.qq;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* @author : 芊芊墨客
|
||||
* @version : 1.0
|
||||
* @date : 2023-04-22 09:44
|
||||
*/
|
||||
public class QqEncrypt {
|
||||
private static final String encNonce="CJBPACrRuNy7";
|
||||
private static final String signPrxfix="zza";
|
||||
private static final char[] dir="0234567890abcdefghijklmnopqrstuvwxyz".toCharArray();
|
||||
/**
|
||||
*
|
||||
*@param encParams 需要加密的参数,这是一段请求体数据,为json字符串格式,例如下面的格式,可以抓包获取
|
||||
* {"comm":{"ct":24,"cv":0},"vip":{"module":"userInfo…baseinfo_v2","param":{"vec_uin":["3011429848"]}}}
|
||||
*
|
||||
* @return 加密的方式为固定字串 zza加上一个10-16位的随机字符串再加上 固定字串 CJBPACrRuNy7加上请求数据拼接的 MD5值
|
||||
*/
|
||||
public static String getSign(String encParams){
|
||||
return signPrxfix+uuidGenerate()+ Md5Encrypt.convertToMd5(encNonce+encParams);
|
||||
}
|
||||
|
||||
private static String uuidGenerate(){
|
||||
int minLen=10;
|
||||
int maxLen=16;
|
||||
Random ran=new Random(System.currentTimeMillis());
|
||||
int ranLen=ran.nextInt(maxLen-minLen)+minLen;
|
||||
StringBuilder sb=new StringBuilder(ranLen);
|
||||
for (int i=0;i<ranLen;i++){
|
||||
sb.append(dir[ran.nextInt(dir.length)]);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static class Md5Encrypt {
|
||||
//必须要重视编码问题了!折腾了好多天才发现MD5要用UTF-8形式加密
|
||||
public static String convertToMd5(String plainText) {
|
||||
byte[] secretBytes = null;
|
||||
try {
|
||||
secretBytes = MessageDigest.getInstance("md5").digest(plainText.getBytes("utf-8"));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("没有这个md5算法!");
|
||||
}
|
||||
String md5code = new BigInteger(1, secretBytes).toString(16);
|
||||
for (int i = 0; i < 32 - md5code.length(); i++) {
|
||||
md5code = "0" + md5code;
|
||||
}
|
||||
return md5code;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,96 @@
|
|||
package com.zhangmeng.tools.music.qq;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import feign.RequestTemplate;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* @author : 芊芊墨客
|
||||
* @version : 1.0
|
||||
* @date : 2023-04-22 09:46
|
||||
*/
|
||||
public class RequestModule {
|
||||
/**
|
||||
* musicu支持加密请求和不加密请求,没有对请求进行限制
|
||||
* musics仅支持加密请求
|
||||
*/
|
||||
public static final String[] apiServer={"https://u.y.qq.com/cgi-bin/musicu.fcg","https://u.y.qq.com/cgi-bin/musics.fcg"};
|
||||
public static final Map<String,String> headerMap=new HashMap<>();
|
||||
|
||||
static {
|
||||
headerMap.put("user-agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36 Edg/87.0.664.66");
|
||||
headerMap.put("accept-encoding","application/json");
|
||||
headerMap.put("cache-control","max-age=0");
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 请求示例:{"area":-100,"sex":-100,"genre":-100,"index":15,"sin":0,"cur_page":1}
|
||||
// * @param area 地区 -100 不限
|
||||
// * @param genre 流派 全部:-100,流行:1 ,摇滚:2,民谣:3,电子:4,爵士:5,嘻哈:6 .....
|
||||
// * @param index 索引 热门:-100 范围 0-26 对应歌手名称拼音A-Z开头
|
||||
// * @param sex 性别 不限:-100 男:0 女:1 组合:2
|
||||
// * @param sin 偏移(第sin位)
|
||||
// * @param currPage 当前页,第n页,默认每页最多80人
|
||||
// * @return
|
||||
// */
|
||||
// public static String getSingerList(int area,int genre,int index,int sex,int sin,int currPage){
|
||||
// RequestTemplate template=new RequestTemplate("Music.SingerListServer","get_singer_list","{\"area\":"+area+",\"sex\":"+sex+",\"genre\":"+genre+",\"index\":"+index+",\"sin\":"+sin+",\"cur_page\":"+currPage+"}");
|
||||
// RequestTemplateBuilder templateBuilder=new RequestTemplateBuilder();
|
||||
// templateBuilder.add("singerList",template);
|
||||
// String sign= QqEncrypt.getSign(templateBuilder.toString());
|
||||
// Random ran=new Random(System.currentTimeMillis());
|
||||
// return HttpRequestHelper.downloadWebSiteUsePost(apiServer[ran.nextInt(apiServer.length)]+"sign="+sign,templateBuilder.toString(),headerMap);
|
||||
// }
|
||||
//
|
||||
// public static String getHotSingerList(){
|
||||
// return getSingerList(-100,-100,-100,-100,0,1);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// *
|
||||
// * @param songId 统一规范,指的是songmid
|
||||
// * @return
|
||||
// */
|
||||
// public static String getSongDetail(String songId){
|
||||
// //{"songinfo":{"module":"music.pf_song_detail_svr","method":"get_song_detail","param":{"song_mid":"112344"}}}
|
||||
// RequestTemplate template=new RequestTemplate("music.pf_song_detail_svr","get_song_detail","{\"song_mid\":\""+songId+"\"}");
|
||||
// RequestTemplateBuilder templateBuilder=new RequestTemplateBuilder();
|
||||
// templateBuilder.add("songdetail",template);
|
||||
// String sign= QqEncrypt.getSign(templateBuilder.toString());
|
||||
// Random ran=new Random(System.currentTimeMillis());
|
||||
// return HttpRequestHelper.downloadWebSiteUsePost(+"sign="+sign,templateBuilder.toString(),headerMap);
|
||||
// }
|
||||
|
||||
public static void main(String[] args) {
|
||||
Random ran=new Random(System.currentTimeMillis());
|
||||
String url = apiServer[ran.nextInt(apiServer.length)];
|
||||
|
||||
QqQuery query = new QqQuery();
|
||||
QqQuery.Comm comm = new QqQuery.Comm("19", "1859", "0");
|
||||
query.setComm(comm);
|
||||
|
||||
QqQuery.Req req = new QqQuery.Req();
|
||||
req.setMethod("DoSearchForQQMusicDesktop");
|
||||
req.setModule("music.search.SearchCgiService");
|
||||
QqQuery.Req.Param param = new QqQuery.Req.Param();
|
||||
param.setGrp(1);
|
||||
param.setNumPerPage(50);
|
||||
param.setPageNum(1);
|
||||
param.setQuery("魏佳艺");
|
||||
param.setSearchType(0);
|
||||
req.setParam(param);
|
||||
query.setReq(req);
|
||||
String q = JSON.toJSONString(query);
|
||||
|
||||
String sign= QqEncrypt.getSign(q);
|
||||
System.out.println(sign);
|
||||
System.out.println(q);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,98 @@
|
|||
package com.zhangmeng.tools.music.qq;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author : 芊芊墨客
|
||||
* @version : 1.0
|
||||
* @date : 2023-04-22 15:17
|
||||
*/
|
||||
public class RequestTemplate{
|
||||
public String module="";
|
||||
public String method="";
|
||||
public Object param=new Object();
|
||||
|
||||
public RequestTemplate() {
|
||||
}
|
||||
|
||||
public RequestTemplate(String module, String method, Object param) {
|
||||
this.module = module;
|
||||
this.method = method;
|
||||
this.param = param;
|
||||
}
|
||||
|
||||
public String getModule() {
|
||||
return module;
|
||||
}
|
||||
|
||||
public void setModule(String module) {
|
||||
this.module = module;
|
||||
}
|
||||
|
||||
public String getMethod() {
|
||||
return method;
|
||||
}
|
||||
|
||||
public void setMethod(String method) {
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
public Object getParam() {
|
||||
return param;
|
||||
}
|
||||
|
||||
public void setParam(Object param) {
|
||||
this.param = param;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{" +
|
||||
"\"module\":\"" + module + "\"" +
|
||||
",\"method\":\"" + method + "\"" +
|
||||
",\"param\":" + param.toString() +
|
||||
"}";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造请求结构,所有请求都可以是这样的
|
||||
*
|
||||
* {
|
||||
* "comm": {
|
||||
* "ct": 24,
|
||||
* "cv": 0
|
||||
* },
|
||||
* "singerList": {
|
||||
* "module": "Music.SingerListServer",
|
||||
* "method": "get_singer_list",
|
||||
* "param": {
|
||||
* "area": -100,
|
||||
* "sex": -100,
|
||||
* "genre": -100,
|
||||
* "index": -100,
|
||||
* "sin": 0,
|
||||
* "cur_page": 1
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
class RequestTemplateBuilder {
|
||||
private Map<String,Object> requestTemplateMap=new HashMap<>();
|
||||
public RequestTemplateBuilder add(String name, Object req){
|
||||
requestTemplateMap.put(name,req);
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb=new StringBuilder();
|
||||
for (String key: requestTemplateMap.keySet()){
|
||||
sb.append("\"").append(key).append("\":").append(requestTemplateMap.get(key).toString()).append(",");
|
||||
}
|
||||
sb.substring(0,sb.length()-1);
|
||||
return "{"+sb.substring(0,sb.length()-1)+"}";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"accept": "application/json, text/plain, */*",
|
||||
"accept - encoding": "gzip, deflate",
|
||||
"accept - language": "zh - CN, zh;q = 0.9",
|
||||
"cache - control": "no - cache",
|
||||
"Connection": "keep-alive",
|
||||
"csrf": "HH3GHIQ0RYM",
|
||||
"Referer": "http://www.kuwo.cn/search/list?key=%E5%91%A8%E6%9D%B0%E4%BC%A6",
|
||||
"User-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36",
|
||||
"Cookie": "_ga=GA1.2.218753071.1648798611; _gid=GA1.2.144187149.1648798611; _gat=1; Hm_lvt_cdb524f42f0ce19b169a8071123a4797=1648798611; Hm_lpvt_cdb524f42f0ce19b169a8071123a4797=1648798611; kw_token=HH3GHIQ0RYM"
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue