Skip to content

Commit

Permalink
add:netease-search
Browse files Browse the repository at this point in the history
  • Loading branch information
xizeyoupan committed Mar 24, 2024
1 parent 633c102 commit 274b7b3
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 16 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ Meting后端的基础是一个[接口](https://github.com/metowolf/Meting/blob/m

## 进度

| | server参数名称 | 图片 | 歌词 | url | 单曲/song | 歌单/playlist | 歌手/artist |
| ------------- | -------------- | ---- | ---- | --- | --------- | ------------- | ----------- |
| 网易云 | netease |||||||
| qq音乐 | tencent |||||| × |
| youtube music | ytmusic || √⁰ |||| × |
| spotify | spotify || √⁰ | √⁰ | √⁰ | √⁰ | × |
| more.. | | | | | | | |
| | server参数名称 | 图片 | 歌词 | url | 单曲/song | 歌单/playlist | 歌手/artist | 搜索/search |
| ------------- | -------------- | ---- | ---- | --- | --------- | ------------- | ----------- |--------- |
| 网易云 | netease ||||||||
| qq音乐 | tencent |||||| × |× |
| youtube music | ytmusic || √⁰ |||| × |× |
| spotify | spotify || √⁰ | √⁰ | √⁰ | √⁰ | × |× |
| more.. | | | | | | | | |

## 地区限制

Expand Down
1 change: 1 addition & 0 deletions src/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default {
"artist": { "show": true, "value": "12441107" },
"lrc": { "show": false, "value": "2015217630" },
"url": { "show": false, "value": "473403185" },
"search": { "show": true, "value": "KN33S0XXX" },
},
"ytmusic": {
"playlist": { "show": true, "value": "RDCLAK5uy_l12ynH8dyLsBmE11ToAHLm9P04NS2i9ME" },
Expand Down
9 changes: 8 additions & 1 deletion src/providers/netease/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import { get_playlist } from "./playlist.js"
import { get_song_url, get_song_info } from "./song.js"
import { get_lyric } from "./lyric.js"
import { get_artist_songs } from "./artist_songs.js"
import { get_search_songs } from "./search.js"

const support_type = ['url', 'lrc', 'song', 'playlist', 'artist']
const support_type = ['url', 'lrc', 'song', 'playlist', 'artist', 'search', 'pic']

const handle = async (type, id, cookie = '') => {
let result;
Expand All @@ -14,6 +15,9 @@ const handle = async (type, id, cookie = '') => {
case 'url':
result = await get_song_url(id)
break
case 'pic':
result = (await get_song_info(id))[0].pic
break
case 'song':
result = await get_song_info(id)
break
Expand All @@ -23,6 +27,9 @@ const handle = async (type, id, cookie = '') => {
case 'artist':
result = await get_artist_songs(id)
break
case 'search':
result = await get_search_songs(id)
break
default:
return -1;
}
Expand Down
25 changes: 25 additions & 0 deletions src/providers/netease/search.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { request } from "./util.js"
import { map_song_list } from "./util.js"

export const get_search_songs = async (id, cookie) => {

const data = {
s: id,
type: 1, // 1: 单曲, 10: 专辑, 100: 歌手, 1000: 歌单, 1002: 用户, 1004: MV, 1006: 歌词, 1009: 电台, 1014: 视频
limit: 30,
offset: 0,
total: true,
}

const res = await request('POST', `https://interface.music.163.com/eapi/cloudsearch`, data, {
crypto: 'eapi',
cookie: {},
url: '/api/cloudsearch/pc'
})

return map_song_list(res.result)

}

// const res = await get_search_songs("KN33S0XXX");
// console.log(res)
19 changes: 11 additions & 8 deletions src/providers/netease/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,14 @@ export const request = async (method, url, data = {}, options) => {
}

export const map_song_list = (song_list) => {
return song_list.songs.map(song => ({
title: song.name,
author: song.ar.reduce((i, v) => ((i ? i + " / " : i) + v.name), ''),
pic: song.al.picUrl,
url: song.id,
lrc: song.id
}))
}
return song_list.songs.map(song => {
const artists = song.ar || song.artists
return {
title: song.name,
author: artists.reduce((i, v) => ((i ? i + " / " : i) + v.name), ''),
pic: song?.al?.picUrl || song.id,
url: song.id,
lrc: song.id
}
})
}

0 comments on commit 274b7b3

Please sign in to comment.