comment_like.js 821 字节
Newer Older
B
binaryify 已提交
1
//comment like
D
dds_feng 已提交
2
module.exports = (req, res, createWebAPIRequest, request) => {
B
binaryify 已提交
3
  let cookie = req.get('Cookie') ? req.get('Cookie') : ''
4
  cookie = 'os=pc;' + cookie
B
binaryify 已提交
5
  const cid = req.query.cid //评论 id
6
  const id = req.query.id
B
binaryify 已提交
7
  const typeMap = {
B
binaryify 已提交
8 9 10 11
    0: 'R_SO_4_', //歌曲
    1: 'R_MV_5_', //mv
    2: 'A_PL_0_', //歌单
    3: 'R_AL_3_', //专辑
12 13
    4: 'A_DJ_1_', //电台
    5: 'R_VI_62_' //  视频
B
binaryify 已提交
14 15
  }
  const type = typeMap[req.query.type]
16
  const data = {
B
binaryify 已提交
17 18
    threadId: `${type}${id}`,
    commentId: cid,
B
binaryify 已提交
19 20 21
    csrf_token: ''
  }
  const action = req.query.t == 1 ? 'like' : 'unlike'
B
binaryify 已提交
22

B
binaryify 已提交
23
  const url = `/weapi/v1/comment/${action}`
24
  createWebAPIRequest(
B
binaryify 已提交
25
    'music.163.com',
26
    url,
B
binaryify 已提交
27
    'POST',
28 29 30
    data,
    cookie,
    music_req => res.send(music_req),
B
binaryify 已提交
31 32 33
    err => res.status(502).send('fetch error')
  )
}