-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a4c9517
Showing
4 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
var request = require("request"); | ||
var argv = require('minimist')(process.argv.slice(2)); | ||
|
||
var qqUrl = `http://i.y.qq.com/s.plcloud/fcgi-bin/smartbox_new.fcg?key=${encodeURI(argv.keywords)}`; | ||
var baiduUrl = `http://sug.music.baidu.com/info/suggestion?word=${encodeURI(argv.keywords)}`; | ||
var xiamiUrl = `http://www.xiami.com/ajax/search-index?key=${encodeURI(argv.keywords)}`; | ||
|
||
request.get(qqUrl, function(error, response, body){ | ||
var result = JSON.parse(body.toString()); | ||
if(result.data && result.data.song && result.data.song.count){ | ||
var qqLink = `http://y.qq.com/#type=song&mid=${result.data.song.itemlist[0].mid}`; | ||
console.log('qq',qqLink); | ||
}else{ | ||
request.get(baiduUrl, function(error, response, body){ | ||
var result = JSON.parse(body.toString()); | ||
if(result.data && result.data.song[0]){ | ||
var baiduLink = ''; | ||
var encrypted_songid = result.data.song[0].encrypted_songid; | ||
var songid = result.data.song[0].songid; | ||
if(encrypted_songid){ | ||
baiduLink = `http://music.baidu.com/song/s/${encrypted_songid}` | ||
}else{ | ||
baiduLink = `http://y.baidu.com/song/${songid}`; | ||
} | ||
console.log('baidu',baiduLink); | ||
}else{ | ||
request.get(xiamiUrl,function(error, response, body){ | ||
// xiami response is `html` | ||
var result = body.toString(); | ||
|
||
var jsdom = require("jsdom").jsdom; | ||
var doc = jsdom(result); | ||
var window = doc.defaultView; | ||
var resultNodes = doc.getElementsByClassName('song_result'); | ||
|
||
if(resultNodes.length){ | ||
var xiamiLink = resultNodes[0].getAttribute('href'); | ||
console.log('xiami',xiamiLink); | ||
}else{ | ||
var neteaseApi=require('NeteaseCloudMusicApi').api | ||
neteaseApi.search(argv.keywords,function(data){ | ||
var songs = JSON.parse(data).result.songs; | ||
if(songs.length){ | ||
var neteaseLink = `http://music.163.com/#/song?id=${songs[0].id}`; | ||
console.log('netease',neteaseLink); | ||
} | ||
}); | ||
} | ||
}); | ||
} | ||
}); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "music", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"keywords": [ | ||
"song" | ||
], | ||
"author": "hirra", | ||
"license": "ISC", | ||
"dependencies":{ | ||
"request":"*", | ||
"minimist":"*", | ||
"jsdom":"*", | ||
"NeteaseCloudMusicApi":"*" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# 简介 | ||
由于现在歌曲版权问题,导致有些歌只能在某些特定的平台才能找到。因此这个工具可以方便大家快速找到音乐链接。 |