更新音源API (#1352)

* 更新API

---------

Co-authored-by: lyswhut <lyswhut@qq.com>
This commit is contained in:
Folltoshe
2023-04-29 15:09:17 +08:00
committed by GitHub
co-authored by lyswhut
parent 200ca1eeda
commit 908815def3
36 changed files with 1422 additions and 207 deletions
+2
View File
@@ -5,8 +5,10 @@ import musicSearch from './musicSearch'
import { apis } from '../api-source'
import hotSearch from './hotSearch'
import comment from './comment'
// import tipSearch from './tipSearch'
const tx = {
// tipSearch,
leaderboard,
songList,
musicSearch,
@@ -1,5 +1,6 @@
import { httpFetch } from '../../request'
import { formatPlayTime, sizeFormate } from '../../index'
import { formatSingerName } from '../utils'
let boardList = [{ id: 'tx__4', name: '流行指数榜', bangid: '4' }, { id: 'tx__26', name: '热歌榜', bangid: '26' }, { id: 'tx__27', name: '新歌榜', bangid: '27' }, { id: 'tx__62', name: '飙升榜', bangid: '62' }, { id: 'tx__58', name: '说唱榜', bangid: '58' }, { id: 'tx__57', name: '喜力电音榜', bangid: '57' }, { id: 'tx__28', name: '网络歌曲榜', bangid: '28' }, { id: 'tx__5', name: '内地榜', bangid: '5' }, { id: 'tx__3', name: '欧美榜', bangid: '3' }, { id: 'tx__59', name: '香港地区榜', bangid: '59' }, { id: 'tx__16', name: '韩国榜', bangid: '16' }, { id: 'tx__60', name: '抖快榜', bangid: '60' }, { id: 'tx__29', name: '影视金曲榜', bangid: '29' }, { id: 'tx__17', name: '日本榜', bangid: '17' }, { id: 'tx__52', name: '腾讯音乐人原创榜', bangid: '52' }, { id: 'tx__36', name: 'K歌金曲榜', bangid: '36' }, { id: 'tx__61', name: '台湾地区榜', bangid: '61' }, { id: 'tx__63', name: 'DJ舞曲榜', bangid: '63' }, { id: 'tx__64', name: '综艺新歌榜', bangid: '64' }, { id: 'tx__65', name: '国风热歌榜', bangid: '65' }, { id: 'tx__67', name: '听歌识曲榜', bangid: '67' }, { id: 'tx__72', name: '动漫音乐榜', bangid: '72' }, { id: 'tx__73', name: '游戏音乐榜', bangid: '73' }, { id: 'tx__75', name: '有声榜', bangid: '75' }, { id: 'tx__131', name: '校园音乐人排行榜', bangid: '131' }]
@@ -104,13 +105,6 @@ export default {
const requestDataObj = httpFetch(url)
return requestDataObj.promise
},
getSinger(singers) {
let arr = []
singers.forEach(singer => {
arr.push(singer.name)
})
return arr.join('、')
},
filterData(rawList) {
// console.log(rawList)
return rawList.map(item => {
@@ -146,7 +140,7 @@ export default {
}
// types.reverse()
return {
singer: this.getSinger(item.singer),
singer: formatSingerName(item.singer, 'name'),
name: item.name,
albumName: item.album.name,
albumId: item.album.mid,
+2 -12
View File
@@ -1,9 +1,6 @@
// import '../../polyfill/array.find'
import { httpFetch } from '../../request'
import { formatPlayTime, sizeFormate } from '../../index'
// import { debug } from '../../utils/env'
// import { formatSinger } from './util'
import { formatSingerName } from '../utils'
export default {
limit: 50,
@@ -52,13 +49,6 @@ export default {
return body.req.data
})
},
getSinger(singers) {
let arr = []
singers.forEach(singer => {
arr.push(singer.name)
})
return arr.join('、')
},
handleResult(rawList) {
// console.log(rawList)
const list = []
@@ -104,7 +94,7 @@ export default {
albumId = item.album.mid
}
list.push({
singer: this.getSinger(item.singer),
singer: formatSingerName(item.singer, 'name'),
name: item.name,
albumName,
albumId,
+7 -23
View File
@@ -1,5 +1,6 @@
import { httpFetch } from '../../request'
import { decodeName, formatPlayTime, sizeFormate, dateFormat } from '../../index'
import { decodeName, formatPlayTime, sizeFormate, dateFormat, formatPlayCount } from '../../index'
import { formatSingerName } from '../utils'
export default {
_requestObj_tags: null,
@@ -125,20 +126,10 @@ export default {
})
},
/**
* 格式化播放数量
* @param {*} num
*/
formatPlayCount(num) {
if (num > 100000000) return parseInt(num / 10000000) / 10 + '亿'
if (num > 10000) return parseInt(num / 1000) / 10 + '万'
return num
},
filterList(data, page) {
return {
list: data.v_playlist.map(item => ({
play_count: this.formatPlayCount(item.access_num),
play_count: formatPlayCount(item.access_num),
id: item.tid,
author: item.creator_info.nick,
name: item.title,
@@ -159,7 +150,7 @@ export default {
// console.log(content.v_item)
return {
list: content.v_item.map(({ basic }) => ({
play_count: this.formatPlayCount(basic.play_cnt),
play_count: formatPlayCount(basic.play_cnt),
id: basic.tid,
author: basic.creator.nick,
name: basic.title,
@@ -228,17 +219,10 @@ export default {
img: cdlist.logo,
desc: decodeName(cdlist.desc).replace(/<br>/g, '\n'),
author: cdlist.nickname,
play_count: this.formatPlayCount(cdlist.visitnum),
play_count: formatPlayCount(cdlist.visitnum),
},
}
},
getSinger(singers) {
let arr = []
singers.forEach(singer => {
arr.push(singer.name)
})
return arr.join('、')
},
filterListDetail(rawList) {
// console.log(rawList)
return rawList.map(item => {
@@ -274,7 +258,7 @@ export default {
}
// types.reverse()
return {
singer: this.getSinger(item.singer),
singer: formatSingerName(item.singer, 'name'),
name: item.name,
albumName: item.album.name,
albumId: item.album.mid,
@@ -319,7 +303,7 @@ export default {
return {
list: body.data.list.map(item => {
return {
play_count: this.formatPlayCount(item.listennum),
play_count: formatPlayCount(item.listennum),
id: item.dissid,
author: item.creator.name,
name: item.dissname,
+7 -8
View File
@@ -1,13 +1,12 @@
import { httpFetch } from '../../request'
export default {
regExps: {
relWord: /RELWORD=(.+)/,
},
// regExps: {
// relWord: /RELWORD=(.+)/,
// },
requestObj: null,
tempSearch(str) {
this.cancelTempSearch()
tipSearch(str) {
this.cancelTipSearch()
this.requestObj = httpFetch(`https://c.y.qq.com/splcloud/fcgi-bin/smartbox_new.fcg?is_xml=0&format=json&key=${encodeURIComponent(str)}&loginUin=0&hostUin=0&format=json&inCharset=utf8&outCharset=utf-8&notice=0&platform=yqq&needNewCode=0`, {
headers: {
Referer: 'https://y.qq.com/portal/player.html',
@@ -21,10 +20,10 @@ export default {
handleResult(rawData) {
return rawData.map(info => `${info.name} - ${info.singer}`)
},
cancelTempSearch() {
cancelTipSearch() {
if (this.requestObj && this.requestObj.cancelHttp) this.requestObj.cancelHttp()
},
async search(str) {
return this.tempSearch(str).then(result => this.handleResult(result.song.itemlist))
return this.tipSearch(str).then(result => this.handleResult(result.song.itemlist))
},
}