QQ音乐vkey获取,更新播放url

匿名 (未验证) 提交于 2019-12-02 21:53:52

QQ音乐接口播放经常换,

最开始

url: `http://ws.stream.qqmusic.qq.com/${musicData.songid}.m4a?fromtag=46`

然后

url:`http://ws.stream.qqmusic.qq.com/C100${musicData.songmid}.m4a?fromtag=0&guid=126548448`

现在

url: `http://dl.stream.qqmusic.qq.com/C400${musicData.songmid}.m4a?fromtag=38&guid=5931742855&vkey=${vkey}`

vkey的获取

// 获取歌曲的vkey export function getSongVkey(songmid) {     const url = 'https://c.y.qq.com/base/fcgi-bin/fcg_music_express_mobile3.fcg'     const data = Object.assign({}, {         callback: 'musicJsonCallback',         loginUin: 3051522991,         format: 'jsonp',         platform: 'yqq',         needNewCode: 0,         cid: 205361747,         uin: 3051522991,         guid: 5931742855,         songmid: songmid,         filename: `C400${songmid}.m4a`     })      return jsonp(url, data) } 

 调用

    //重组 res.data.list 数据,只拿需要的     _formatSongs(list){       let result = []       list.forEach((item)=>{         // console.log('item',item)         // 解构赋值-拿到item 下的 musicData 列表数据         let {musicData} = item         //------------- 更新的加上vkey         getSongVkey(musicData.songmid).then((res) => {           const vkey = res.data.items[0].vkey;           if (musicData.songid && musicData.albummid) {             result.push(CreatSong(musicData, vkey))           }         })         //-------------         // console.log('musicData',musicData)         // if(musicData.songid && musicData.albummid){         //   result.push(CreatSong(musicData))         // }       })       return result     }
export function CreatSong(musicData,vkey){ //加了一个传参和更新了url     return new Song({         id: musicData.songid,         mid: musicData.songmid,         singer: filterSinger(musicData.singer),//filterSinger 中处理一遍         name: musicData.songname,         album: musicData.albumname,         duration: musicData.interval,         image: `https://y.gtimg.cn/music/photo_new/T002R300x300M000${musicData.albummid}.jpg?max_age=2592000`,        url: `http://dl.stream.qqmusic.qq.com/C400${musicData.songmid}.m4a?fromtag=38&guid=5931742855&vkey=${vkey}`     }) }

调用调试完成!

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!