Skip to content

Commit

Permalink
1.修复酷我分页专辑报错问题修改为多次批量并非之前的改大每页数据
Browse files Browse the repository at this point in the history
  • Loading branch information
a13087635768 committed Nov 18, 2024
1 parent 4e7ecc2 commit ce506a5
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 40 deletions.
142 changes: 104 additions & 38 deletions src/main/java/com/sqmusicplus/plug/kw/hander/NKwSearchHander.java
Original file line number Diff line number Diff line change
Expand Up @@ -391,46 +391,51 @@ public DownloadEntity downloadSong(Music music, PlugBrType brType, String addSub
}

@Override
public ArrayList<DownloadEntity> downloadAlbum(String albumsId, PlugBrType brType,String addSubsonicPlayListName,String artist, Boolean isAudioBook, String albumName) {
ArrayList<DownloadEntity> downloadEntities = new ArrayList<>();
AtomicReference<String> change = new AtomicReference<>(artist);

String searchUrl = config.getAlbumInfoUrl().replaceAll("#\\{albumid}", albumsId);
AlbumInfoResult albumInfoResult = DownloadUtils.getHttp().sync(searchUrl)
.get() // GET请求
.getBody() // 响应报文体
.toBean(AlbumInfoResult.class);
List<AlbumInfoResult.MusiclistDTO> musiclist = albumInfoResult.getMusiclist();

SqConfig accompaniment = getConfigService().getOne(new QueryWrapper<SqConfig>().eq("config_key", "music.ignore.accompaniment"));
SqConfig matchAlbumSinger = getConfigService().getOne(new QueryWrapper<SqConfig>().eq("config_key", "music.strong.match.album.singer"));
SqConfig albumSingerUnity = getConfigService().getOne(new QueryWrapper<SqConfig>().eq("config_key", "music.album.singer.unity"));

musiclist.forEach(md -> {
if (Boolean.getBoolean(accompaniment.getConfigValue())) {
if (md.getName().contains("(伴奏)") || md.getName().contains("(试听版)") || md.getName().contains("(片段)")) {
return;
}
}
if (Boolean.getBoolean(matchAlbumSinger.getConfigValue()) && !isAudioBook) {
if (!md.getArtist().contains(change.get())) {
return;
}
}
if (!Boolean.getBoolean(albumSingerUnity.getConfigValue()) && !isAudioBook) {
change.set(md.getArtist());
}
if (isAudioBook) {
downloadEntities.add(new DownloadEntity("nKwSearchHander",md.getId(), brType, md.getName(), artist, albumName, isAudioBook));
} else {
//添加到缓存
downloadEntities.add(new DownloadEntity("nKwSearchHander",md.getId(), brType, md.getName(), change.get(), albumInfoResult.getName()));
}

});
return downloadEntities;
public ArrayList<DownloadEntity> downloadAlbum(String albumsId, PlugBrType brType, String addSubsonicPlayListName, String artist, Boolean isAudioBook, String albumName) {
return downloadAlbum(albumsId, brType, addSubsonicPlayListName, artist, isAudioBook, albumName,0, 1000);
}

// @Override
// public ArrayList<DownloadEntity> downloadAlbum(String albumsId, PlugBrType brType,String addSubsonicPlayListName,String artist, Boolean isAudioBook, String albumName) {
// ArrayList<DownloadEntity> downloadEntities = new ArrayList<>();
// AtomicReference<String> change = new AtomicReference<>(artist);
//
// String searchUrl = config.getAlbumInfoUrl().replaceAll("#\\{albumid}", albumsId);
// AlbumInfoResult albumInfoResult = DownloadUtils.getHttp().sync(searchUrl)
// .get() // GET请求
// .getBody() // 响应报文体
// .toBean(AlbumInfoResult.class);
// List<AlbumInfoResult.MusiclistDTO> musiclist = albumInfoResult.getMusiclist();
//
// SqConfig accompaniment = getConfigService().getOne(new QueryWrapper<SqConfig>().eq("config_key", "music.ignore.accompaniment"));
// SqConfig matchAlbumSinger = getConfigService().getOne(new QueryWrapper<SqConfig>().eq("config_key", "music.strong.match.album.singer"));
// SqConfig albumSingerUnity = getConfigService().getOne(new QueryWrapper<SqConfig>().eq("config_key", "music.album.singer.unity"));
//
// musiclist.forEach(md -> {
// if (Boolean.getBoolean(accompaniment.getConfigValue())) {
// if (md.getName().contains("(伴奏)") || md.getName().contains("(试听版)") || md.getName().contains("(片段)")) {
// return;
// }
// }
// if (Boolean.getBoolean(matchAlbumSinger.getConfigValue()) && !isAudioBook) {
// if (!md.getArtist().contains(change.get())) {
// return;
// }
// }
// if (!Boolean.getBoolean(albumSingerUnity.getConfigValue()) && !isAudioBook) {
// change.set(md.getArtist());
// }
// if (isAudioBook) {
// downloadEntities.add(new DownloadEntity("nKwSearchHander",md.getId(), brType, md.getName(), artist, albumName, isAudioBook));
// } else {
// //添加到缓存
// downloadEntities.add(new DownloadEntity("nKwSearchHander",md.getId(), brType, md.getName(), change.get(), albumInfoResult.getName()));
// }
//
// });
// return downloadEntities;
// }

@Override
public List<DownloadEntity> downloadArtistAllSong(String artistId, PlugBrType brType,String addSubsonicPlayListName) {
List<Music> music = queryAllArtistSongList(artistId, 0);
Expand Down Expand Up @@ -580,5 +585,66 @@ public List<Music> queryAllPlayInfoList(String playListId, Integer pageSize, Int

}

public ArrayList<DownloadEntity> downloadAlbum(String albumsId, PlugBrType brType,String addSubsonicPlayListName,String artist, Boolean isAudioBook, String albumName,Integer pageNumber, Integer pageSize) {
if (pageNumber==null){
pageNumber=0;
}
pageSize=pageSize==null?1000:pageSize;

ArrayList<DownloadEntity> downloadEntities = new ArrayList<>();
AtomicReference<String> change = new AtomicReference<>(artist);
String searchUrl = config.getAlbumInfoUrl().replaceAll("#\\{albumid}", albumsId);
searchUrl = searchUrl.replaceAll("#\\{pn}", pageNumber.toString());
searchUrl = searchUrl.replaceAll("#\\{pagesize}", pageSize.toString());
AlbumInfoResult albumInfoResult = DownloadUtils.getHttp().sync(searchUrl)
.get() // GET请求
.getBody() // 响应报文体
.toBean(AlbumInfoResult.class);
List<AlbumInfoResult.MusiclistDTO> musiclist = albumInfoResult.getMusiclist();
String songnum = albumInfoResult.getSongnum();
//判断是否需分页查询
if (Integer.parseInt(songnum) > pageSize) {
int countsize = Integer.parseInt(songnum) % pageSize == 0 ? Integer.parseInt(songnum) / pageSize : Integer.parseInt(songnum) / pageSize + 1;
for (int i = 1; i < countsize; i++) {
String addsearchUrl = config.getAlbumInfoUrl().replaceAll("#\\{albumid}", albumsId);
addsearchUrl = addsearchUrl.replaceAll("#\\{pn}", i+"");
addsearchUrl = addsearchUrl.replaceAll("#\\{pagesize}", pageSize.toString());
AlbumInfoResult addalbumInfoResult = DownloadUtils.getHttp().sync(addsearchUrl)
.get() // GET请求
.getBody() // 响应报文体
.toBean(AlbumInfoResult.class);
musiclist.addAll(addalbumInfoResult.getMusiclist());
}
}

SqConfig accompaniment = getConfigService().getOne(new QueryWrapper<SqConfig>().eq("config_key", "music.ignore.accompaniment"));
SqConfig matchAlbumSinger = getConfigService().getOne(new QueryWrapper<SqConfig>().eq("config_key", "music.strong.match.album.singer"));
SqConfig albumSingerUnity = getConfigService().getOne(new QueryWrapper<SqConfig>().eq("config_key", "music.album.singer.unity"));

musiclist.forEach(md -> {
if (Boolean.getBoolean(accompaniment.getConfigValue())) {
if (md.getName().contains("(伴奏)") || md.getName().contains("(试听版)") || md.getName().contains("(片段)")) {
return;
}
}
if (Boolean.getBoolean(matchAlbumSinger.getConfigValue()) && !isAudioBook) {
if (!md.getArtist().contains(change.get())) {
return;
}
}
if (!Boolean.getBoolean(albumSingerUnity.getConfigValue()) && !isAudioBook) {
change.set(md.getArtist());
}
if (isAudioBook) {
downloadEntities.add(new DownloadEntity("nKwSearchHander",md.getId(), brType, md.getName(), artist, albumName, isAudioBook));
} else {
//添加到缓存
downloadEntities.add(new DownloadEntity("nKwSearchHander",md.getId(), brType, md.getName(), change.get(), albumInfoResult.getName()));
}

});
return downloadEntities;
}


}
2 changes: 1 addition & 1 deletion src/main/resources/application-plug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ kw:
# 专辑列表
AlbumListUrl: https://search.kuwo.cn/r.s?pn=0&rn=10000&artistid=#{artistid}&stype=albumlist&sortby=1&alflac=1&show_copyright_off=1&pcmp4=1&encoding=utf8&plat=pc&thost=search.kuwo.cn&vipver=MUSIC_9.1.1.2_BCS2&devid=38668888&pcjson=1
# 专辑信息
AlbumInfoUrl: https://search.kuwo.cn/r.s?pn=0&rn=10000&albumid=#{albumid}&stype=albuminfo&show_copyright_off=1&alflac=1&pcmp4=1&encoding=utf8&plat=pc&vipver=MUSIC_9.1.1.2_BCS2&devid=38668888&newver=1&pcjson=1
AlbumInfoUrl: https://search.kuwo.cn/r.s?pn=#{pn}&rn=#{pagesize}&albumid=#{albumid}&stype=albuminfo&show_copyright_off=1&alflac=1&pcmp4=1&encoding=utf8&plat=pc&vipver=MUSIC_9.1.1.2_BCS2&devid=38668888&newver=1&pcjson=1
#专辑列表
ArtistAlbumListUrl: https://search.kuwo.cn/r.s?pn=0&rn=10000&artistid=#{artistid}&stype=albumlist&sortby=1&alflac=1&show_copyright_off=1&pcmp4=1&encoding=utf8&plat=pc&thost=search.kuwo.cn&vipver=MUSIC_9.1.1.2_BCS2&devid=38668888&pcjson=1
# 歌手单曲列表(分页)
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,5 @@ sa-token:
is-log: false
is-print: false

version: 2.14.2
version: 2.14.3

0 comments on commit ce506a5

Please sign in to comment.