清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
实现根据歌曲 url 或者专辑 url 来下载歌曲、歌词、封面的功能,其中下载的歌曲目录根据艺术家+专辑名称生成
平心而论,虽然没了杰伦 coldplay,但是对于冷门的歌曲,虾米的曲库还算比较全的,是一个不错的选择。之前下载歌曲的时候用过各种 chrome 插件,大概的原理都是浏览器听歌的时候嗅探访问地址,或者到浏览器缓存中招到歌曲。也一直没去深究没想去做一个自己的下载器。
昨天晚上的时候看到有人提到网易歌曲下载,于是乎研究了下虾米的歌曲下载。今天花了点时间把虾米的下载写了出来。
本地效率测试:此时时刻 巡回演唱会 25+1 首歌曲,全部下载成功,共133M,耗时1分38秒。
源代码:https://github.com/houweitao/DownloadXiaMi
static public String decodeRubust(String str) {
if (str == null || str.length() < 1)
return null;
int num = Integer.valueOf(str.charAt(0) + "");
int step = (str.length() - 1) / num;
int helpStep = step;
String[] matrix = new String[num];
System.out.println(str.length() - 1);
int duo = (str.length() - 1) % num;
for (int i = 0, j = 1; i < matrix.length; i++, j = j + helpStep) {
if (i < duo)
helpStep = step + 1;
else
helpStep = step;
matrix[i] = str.substring(j, j + helpStep);
System.out.println(matrix[i]);
}
// print(matrix);
return makeSense(matrix);
}
private static String makeSense(String[] matrix) {
StringBuffer sb = new StringBuffer();
for (int j = 0; j < matrix[0].length(); j++) {
for (int i = 0; i < matrix.length; i++) {
if (matrix[i].length() - 1 >= j)
sb.append(matrix[i].charAt(j));
}
}
System.out.println(sb.toString());
String tmp = new String();
try {
tmp = URLDecoder.decode(sb.toString(), "UTF-8");
tmp = tmp.replaceAll("\\^", "0");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
tmp = null;
}
if (tmp.subSequence(0, 7).equals("http://") && tmp.substring(tmp.length()-6).equals("0-null"))
return tmp;
else
return null;
}