Skip to content

Instantly share code, notes, and snippets.

@nahakyuu
Last active December 23, 2015 08:09
Show Gist options
  • Save nahakyuu/5b30bfaad5ecfc240c50 to your computer and use it in GitHub Desktop.
Save nahakyuu/5b30bfaad5ecfc240c50 to your computer and use it in GitHub Desktop.
虾米下载链接提取
module.exports = function (str ,num) {
var line = Math.floor(str.length / num);
var begin = 0;
var end = line;
var temp = [];
//切割str
for (var i = line * num - str.length; i; i++) {
temp.push(str.slice(begin, ++end));
begin = end;end += line;
}
for (var i = str.length - num - line * num; i; i++) {
temp.push(str.slice(begin, end));
begin = end;end += line;
}
//合并
var result = '';
for (var i = 0; i < line; i++) {
for( var j = 0; j < num; j++) {
result += temp[j][i];
}
}
for (var i = 0; i < str.length - line * num; i++) {
result += temp[i][line];
}
return decodeURIComponent(result).replace(/\^/g,'0');
}
var superagent = require('superagent');
var decode = require('./decode')
var url =
'http://www.xiami.com/song/playlist/id/' +
process.argv[2] +
'/object_id/0/cat/json';
superagent.get().end(function(err, res){
if (err)
return console.error(err);
var result = JSON.parse(res.text);
var location = result.data.trackList[0].location;
console.log(decode(location.slice(1), Number(location[0])));
});
{
"name": "decode-xiami",
"main": "index.js",
"author": "nahakyuu <root@aroa.me>",
"dependencies": {
"superagent": "^1.3.0"
}
}
@nahakyuu
Copy link
Author

蛮久之前写的了

下架的歌曲大概会导致意外错误吧

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment