This repository has been archived by the owner on Jun 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 993
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #201 from trazyn/dev
Dev
- Loading branch information
Showing
13 changed files
with
118 additions
and
23 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
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
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
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
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
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,77 @@ | ||
|
||
import _debug from 'debug'; | ||
import chalk from 'chalk'; | ||
|
||
const debug = _debug('dev:plugin:Kuwo'); | ||
const error = _debug('dev:plugin:Kuwo:error'); | ||
|
||
export default async(request, keyword, artists) => { | ||
debug(chalk.black.bgGreen('💊 Loaded Kuwo music.')); | ||
|
||
try { | ||
// Apply cookie | ||
await request({ | ||
uri: 'http://www.kuwo.cn/', | ||
method: 'HEAD', | ||
}); | ||
|
||
var response = await request({ | ||
uri: 'http://search.kuwo.cn/r.s', | ||
qs: { | ||
ft: 'music', | ||
itemset: 'web_2013', | ||
client: 'kt', | ||
rformat: 'json', | ||
encoding: 'utf8', | ||
all: [keyword].concat(artists.split(',')).join('+'), | ||
pn: 0, | ||
rn: 20, | ||
}, | ||
}); | ||
// eslint-disable-next-line | ||
response = eval('(' + response + ')'); | ||
artists = artists.split(','); | ||
|
||
var songs = response.abslist || []; | ||
var payload = songs.find( | ||
e => artists.findIndex(artist => e.ARTIST.indexOf(artist) !== -1) > -1 | ||
); | ||
|
||
console.log(payload); | ||
|
||
if (!payload) { | ||
error(chalk.black.bgRed('🚧 Nothing.')); | ||
return Promise.reject(); | ||
} | ||
|
||
response = await request({ | ||
uri: 'http://antiserver.kuwo.cn/anti.s', | ||
qs: { | ||
type: 'convert_url', | ||
format: 'aac|mp3|wma', | ||
response: 'url', | ||
rid: payload.MP3RID, | ||
}, | ||
}); | ||
|
||
if (!response) { | ||
error(chalk.black.bgRed('🚧 Nothing.')); | ||
return Promise.reject(); | ||
} | ||
|
||
var song = { | ||
src: response, | ||
isFlac: response.endsWith('.aac') | ||
}; | ||
|
||
debug(chalk.black.bgGreen('🚚 Result >>>')); | ||
debug(song); | ||
debug(chalk.black.bgGreen('🚚 <<<')); | ||
} catch (ex) { | ||
// Anti-warnning | ||
error('Failed to get song: %O', ex); | ||
return Promise.reject(); | ||
} | ||
|
||
return song; | ||
}; |
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
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
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
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
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
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
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