慕课网vue播放器最新QQ音乐api

21 篇文章 0 订阅
3 篇文章 0 订阅

前言:最近做了慕课网上的vue播放器,做的过程中,花费了大量的时间去找api,为了方便大家学习,特意写了个后台来抓取qq音乐的api,有需要的可以粘贴运行,处理一下跨域就能用了:

const axios = require('axios')
const express = require('express')
const app = express()
const Router = express.Router()

// 获取推荐歌单
app.get('/api/apiData', (req, res) => {
    const url = 'https://u.y.qq.com/cgi-bin/musics.fcg?-=recom04079145148486929&g_tk=413529511&sign=zzahy5a2de1886ff15c4441255ee9ef959d8dacccc3f88&loginUin=1982414933&hostUin=0&format=json&inCharset=utf8&outCharset=utf-8&notice=0&platform=yqq.json&needNewCode=0&data=%7B%22comm%22%3A%7B%22ct%22%3A24%7D%2C%22category%22%3A%7B%22method%22%3A%22get_hot_category%22%2C%22param%22%3A%7B%22qq%22%3A%22%22%7D%2C%22module%22%3A%22music.web_category_svr%22%7D%2C%22recomPlaylist%22%3A%7B%22method%22%3A%22get_hot_recommend%22%2C%22param%22%3A%7B%22async%22%3A1%2C%22cmd%22%3A2%7D%2C%22module%22%3A%22playlist.HotRecommendServer%22%7D%2C%22playlist%22%3A%7B%22method%22%3A%22get_playlist_by_category%22%2C%22param%22%3A%7B%22id%22%3A8%2C%22curPage%22%3A1%2C%22size%22%3A40%2C%22order%22%3A5%2C%22titleid%22%3A8%7D%2C%22module%22%3A%22playlist.PlayListPlazaServer%22%7D%2C%22new_song%22%3A%7B%22module%22%3A%22newsong.NewSongServer%22%2C%22method%22%3A%22get_new_song_info%22%2C%22param%22%3A%7B%22type%22%3A5%7D%7D%2C%22new_album%22%3A%7B%22module%22%3A%22newalbum.NewAlbumServer%22%2C%22method%22%3A%22get_new_album_info%22%2C%22param%22%3A%7B%22area%22%3A1%2C%22sin%22%3A0%2C%22num%22%3A20%7D%7D%2C%22new_album_tag%22%3A%7B%22module%22%3A%22newalbum.NewAlbumServer%22%2C%22method%22%3A%22get_new_album_area%22%2C%22param%22%3A%7B%7D%7D%2C%22toplist%22%3A%7B%22module%22%3A%22musicToplist.ToplistInfoServer%22%2C%22method%22%3A%22GetAll%22%2C%22param%22%3A%7B%7D%7D%2C%22focus%22%3A%7B%22module%22%3A%22music.musicHall.MusicHallPlatform%22%2C%22method%22%3A%22GetFocus%22%2C%22param%22%3A%7B%7D%7D%7D'
    axios.get(url)
        .then(response => {
            res.json(response.data)
        })
})
// 获取歌手
app.get('/api/apiSinger', (req, res) => {
    const url = 'https://c.y.qq.com/v8/fcg-bin/v8.fcg?g_tk=1928093487&inCharset=utf-8&outCharset=utf-8&notice=0&format=jsonp&channel=singer&page=list&key=all_all_all&pagesize=100&pagenum=1&hostUin=0&needNewCode=0&platform=yqq'
    axios.get(url)
        .then(response => {
            res.json(response.data)
        })
        .catch(err => {
            console.log(err)
        })
})
// 获取播放地址
app.get('/api/apiGetUrlPlay', (req, res) => {
    // 需要歌的mid
    const url = 'https://u.y.qq.com/cgi-bin/musicu.fcg??format=json&data=%7B%22req_0%22%3A%7B%22module%22%3A%22vkey.GetVkeyServer%22%2C%22method%22%3A%22CgiGetVkey%22%2C%22param%22%3A%7B%22guid%22%3A%22358840384%22%2C%22songmid%22%3A%5B%22' + req.query.mid + '%22%5D%2C%22songtype%22%3A%5B0%5D%2C%22uin%22%3A%221443481947%22%2C%22loginflag%22%3A1%2C%22platform%22%3A%2220%22%7D%7D%2C%22comm%22%3A%7B%22uin%22%3A%2218585073516%22%2C%22format%22%3A%22json%22%2C%22ct%22%3A24%2C%22cv%22%3A0%7D%7D'
    axios.get(url)
        .then(response => {
            res.json(response.data)
        })
        .catch(err => {
            console.log(err)
        })
})
// 获取歌词
app.get('/api/getLyric', (req, res) => {
    let url = 'https://c.y.qq.com/lyric/fcgi-bin/fcg_query_lyric_new.fcg'
    axios.get(url, {
        params: {
            hostUin: 0,
            needNewCode: 0,
            categoryId: 10000000,
            pcachetime: +new Date(),
            format: 'json',
            songmid: req.query.mid, //歌的mid
            g_tk_new_20200303: 5381,
            g_tk: 5381,
            loginUin: 0,
            inCharset: 'utf8',
            outCharset: 'utf-8',
            notice: 0,
            platform: 'yqq.json',
        },
        headers: {
            origin: 'https://y.qq.com',
            referer: 'https://y.qq.com/portal/player.html'
        }
    }).then(response => {
        res.json(response.data)
    })
})

//获取推荐歌单中的歌
app.get('/api/getRecommendList', (req, res) => {
    let url = 'https://c.y.qq.com/qzone/fcg-bin/fcg_ucc_getcdinfo_byids_cp.fcg'
    axios.get(url, {
        params: {
            type: 1,
            json: 1,
            utf8: 1,
            onlysong: 0,
            new_format: 1,
            disstid: req.query.discId, // 歌单的discId
            g_tk_new_20200303: 5381,
            g_tk: 5381,
            loginUin: 0,
            hostUin: 0,
            format: 'json',
            inCharset: 'utf8',
            outCharset: 'utf-8',
            notice: 0,
            platform: 'yqq.json',
            needNewCode: 0
        },
        headers: {
            origin: 'https://y.qq.com',
            referer: 'https://y.qq.com/portal/player.html'
        }
    }).then(response => {
        res.json(response.data)
    })
})

//获取排行榜歌单类别
app.get('/api/getTopList', (req, res) => {
    let url = 'https://c.y.qq.com/v8/fcg-bin/fcg_myqq_toplist.fcg'
    axios.get(url, {
        params: {
            g_tk: 1928093487,
            inCharset: 'utf-8',
            outCharset: 'utf-8',
            notice: 0,
            format: 'json',
            uin: 0,
            needNewCode: 1,
            platform: 'h5'
        },
        headers: {
            origin: 'https://y.qq.com',
            referer: 'https://y.qq.com/portal/player.html'
        }
    }).then(response => {
        res.json(response.data)
    })
})
//获取排行榜歌单对应的歌列表
app.get('/api/getMusicList', (req, res) => {
    let url = `https://c.y.qq.com/v8/fcg-bin/fcg_v8_toplist_cp.fcg`
    axios.get(url, {
        params: {
            topid: req.query.topId, // 排行榜的topId
            platform: 'yqq.json',
            format: 'json'
        },
        headers: {
            origin: 'https://y.qq.com',
            referer: 'https://y.qq.com/portal/player.html'
        }
    }).then(response => {
        res.json(response.data)
    })
})

// 获取热搜关键词
app.get('/api/getHotKey', (req, res) => {
    let url = `https://c.y.qq.com/splcloud/fcgi-bin/gethotkey.fcg`
    axios.get(url, {
        params: {
            g_tk_new_20200303: 5381,
            g_tk: 5381,
            loginUin: 0,
            hostUin: 0,
            format: 'json',
            inCharset: 'utf8',
            outCharset: 'utf-8',
            notice: 0,
            platform: 'yqq.json',
            needNewCode: 0
        },
        headers: {
            origin: 'https://y.qq.com',
            referer: 'https://y.qq.com/portal/player.html'
        }
    }).then(response => {
        res.json(response.data)
    })
})

// 根据关键字进行搜索
app.get('/api/search', (req, res) => {
    let url = `https://c.y.qq.com/soso/fcgi-bin/client_search_cp`
    axios.get(url, {
        params: {
            catZhida: req.query.showSinger ? 1 : 0,
            p: req.query.page, 
            n: req.query.perpage, // 
            w: req.query.key, // 关键字
            format: 'json',
            inCharset: 'utf8',
            outCharset: 'utf-8'
        },
        headers: {
            origin: 'https://y.qq.com',
            referer: 'https://y.qq.com/portal/player.html'
        }
    }).then(response => {
        res.json(response.data)
    })
})
app.use(express.static('./dist'))
app.listen(8080, (err) => {
    if (err) {
        return console.log(err)
    }
    console.log('http://localhost:8080正在运行')
})
  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 6
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值