Get data + play source through QQ music interface

Recently, I am learning to make a web mobile music player. Because I don't want to make a database to store data, I am learning to get some data from the QQ music interface

If other data is normal, but can't play, you can try this

I found two useful sources yesterday. I hope they can give some help to like-minded friends

It's used here songmid 
url: `http://isure.stream.qqmusic.qq.com/C100${musicData.songmid}.m4a?fromtag=32`        
url: `http://thirdparty.gtimg.com/C100${musicData.songmid}.m4a?fromtag=38`

Get song list data:

url: https://c.y.qq.com/splcloud/fcgi-bin/fcg_get_diss_by_tag.fcg

//songList.js
export function getDiscList() {
    const url = '/api/getDiscList'
    const data = Object.assign({}, commonParams, {
        platform: 'yqq',
        hostUin: 0,
        sin: 0,
        ein: 29,
        sortId: 5,
        needNewCode: 0,
        categoryId: 10000000,
        rnd: Math.random(),
        format: 'json'
    })

    return axios.get(url, {
        params: data
    }).then((res) => {
        return Promise.resolve(res.data)
    })
}

webpack.dev.conf.js
// Get through axios agent
/**
* Through axios, send an http request from the real QQ music address, modify a headers at the same time, and respond correctly,
* And return the content to the front-end interface
* @param  {[type]}   req     [require]
* @param  {String}   res    [response]
* @param  {Function} params: req.query  [Parameters]
* @return {[type]}           [description]
*/
apiRoutes.get('/api/getDiscList', function(req, res) {
     var url = 'https://c.y.qq.com/splcloud/fcgi-bin/fcg_get_diss_by_tag.fcg'
     axios.get(url, {
         headers: {
             referer: 'https://c.y.qq.com/',
             host: 'c.y.qq.com'
         },
         params: req.query
     }).then((response) => {
        // Return data to the front end
         res.json(response.data)
     }).catch((e) => {
        console.log(e)
     })
})

Get the data of the carousel chart:

url: https://c.y.qq.com/musichall/fcgi-bin/fcg_yqqhomepagerecommend.fcg

export function getRecommend() {
    const url = 'https://c.y.qq.com/musichall/fcgi-bin/fcg_yqqhomepagerecommend.fcg'
    const data = Object.assign({}, commonParams, {
        platform: 'h5',
        uin: 0,
        needNewCode: 1
    })
    return jsonp(url, data, options)
}

Get lyrics data:

url: https://c.y.qq.com/lyric/fcgi-bin/fcg_query_lyric_new.fcg

export function getDiscList() {
    const url = '/api/getDiscList'
    const data = Object.assign({}, commonParams, {
        platform: 'yqq',
        hostUin: 0,
        sin: 0,
        ein: 29,
        sortId: 5,
        needNewCode: 0,
        categoryId: 10000000,
        rnd: Math.random(),
        format: 'jsonp'
    })

    return axios.get(url, {
        params: data
    }).then((res) => {
        return Promise.resolve(res.data)
    })
}
// webpack.dev.conf.js
apiRoutes.get('/api/lyric', function(req, res) {
   var url = 'https://c.y.qq.com/lyric/fcgi-bin/fcg_query_lyric_new.fcg'
   axios.get(url, {
         headers: {
            referer: 'https://c.y.qq.com',
            host: 'c.y.qq.com'
        },
        params: req.query
   }).then((response) => {
         var ret = response.data
         if (typeof ret === 'string') {
             var reg = /^\w+\(({[^()]+})\)$/
             var matches = ret.match(reg)
                 if (matches) {
                    ret = JSON.parse(matches[1])
                 }
        }
        res.json(ret)
   }).catch((e) => {
         console.log(e)
  })
})

Get singer information:

url: https://szc.y.qq.com/v8/fcg-bin/v8.fcg

export function getSingerList() {
    const url = 'https://c.y.qq.com/v8/fcg-bin/v8.fcg'
    const data = Object.assign({}, commonParams, {
        channel: 'singer',
        page: 'list',
        key: 'all_all_all',
        pagesize: 100,
        pagenum: 1,
        hostUin: 0,
        needNewCode: 0,
        platform: 'yqq',
        g_tk: 2001751543
    })
    return jsonp(url, data, options)
}

Get song details:

url:  https://c.y.qq.com/v8/fcg-bin/fcg_v8_singer_track_cp.fcg

export function getSingerDetail(singerId) {
    const url = 'https://c.y.qq.com/v8/fcg-bin/fcg_v8_singer_track_cp.fcg'

    const data = Object.assign({}, commonParams, {
        hostUin: 0,
        needNewCode: 0,
        order: 'listen',
        platform: 'h5page',
        begin: 0,
        num: 100,
        songstatus: 1,
        singermid: singerId,
        g_tk: 2001751543
    })
    return jsonp(url, data, options)
}

Get leaderboard data (grab mobile terminal):

url: https://c.y.qq.com/v8/fcg-bin/fcg_myqq_toplist.fcg


To get a list of Songs:

url: https://c.y.qq.com/qzone/fcg-bin/fcg_ucc_getcdinfo_byids_cp.fcg

Get list details (mobile terminal):

url: https://c.y.qq.com/v8/fcg-bin/fcg_v8_toplist_cp.fcg

QQ Music

Tags: axios JSON Mobile Webpack

Posted on Tue, 05 May 2020 06:21:53 -0400 by 9902468