修复mg源搜索接口不显示时长
This commit is contained in:
parent
db0af38e07
commit
e3e4cf8026
@ -1,7 +1,8 @@
|
|||||||
// import '../../polyfill/array.find'
|
// import '../../polyfill/array.find'
|
||||||
|
|
||||||
import { httpFetch } from '../../request'
|
import { httpFetch } from '../../request'
|
||||||
import { sizeFormate } from '../../index'
|
import { sizeFormate, formatPlayTime } from '../../index'
|
||||||
|
import { encode } from './util'
|
||||||
// import { debug } from '../../utils/env'
|
// import { debug } from '../../utils/env'
|
||||||
// import { formatSinger } from './util'
|
// import { formatSinger } from './util'
|
||||||
|
|
||||||
@ -11,8 +12,9 @@ export default {
|
|||||||
page: 0,
|
page: 0,
|
||||||
allPage: 1,
|
allPage: 1,
|
||||||
musicSearch(str, page, limit) {
|
musicSearch(str, page, limit) {
|
||||||
const searchRequest = httpFetch(`http://pd.musicapp.migu.cn/MIGUM2.0/v1.0/content/search_all.do?ua=Android_migu&version=5.0.1&text=${encodeURIComponent(str)}&pageNo=${page}&pageSize=${limit}&searchSwitch=%7B%22song%22%3A1%2C%22album%22%3A0%2C%22singer%22%3A0%2C%22tagSong%22%3A0%2C%22mvSong%22%3A0%2C%22songlist%22%3A0%2C%22bestShow%22%3A1%7D`, {
|
const timestamp = Date.now()
|
||||||
// searchRequest = httpFetch(`http://jadeite.migu.cn:7090/music_search/v2/search/searchAll?sid=4f87090d01c84984a11976b828e2b02c18946be88a6b4c47bcdc92fbd40762db&isCorrect=1&isCopyright=1&searchSwitch=%7B%22song%22%3A1%2C%22album%22%3A0%2C%22singer%22%3A0%2C%22tagSong%22%3A1%2C%22mvSong%22%3A0%2C%22bestShow%22%3A1%2C%22songlist%22%3A0%2C%22lyricSong%22%3A0%7D&pageSize=${limit}&text=${encodeURIComponent(str)}&pageNo=${page}&sort=0`, {
|
const encodeData = encode(str, timestamp)
|
||||||
|
const searchRequest = httpFetch(`https://jadeite.migu.cn/music_search/v3/search/searchAll?pageNo=${page}&pageSize=${limit}&sort=0&text=${str}&searchSwitch={"song":1,"album":0,"singer":0,"tagSong":0,"mvSong":0,"bestShow":0,"songlist":0,"lyricSong":0}&isCopyright=1&isCorrect=1`, {
|
||||||
headers: {
|
headers: {
|
||||||
// sign: 'c3b7ae985e2206e97f1b2de8f88691e2',
|
// sign: 'c3b7ae985e2206e97f1b2de8f88691e2',
|
||||||
// timestamp: 1578225871982,
|
// timestamp: 1578225871982,
|
||||||
@ -20,10 +22,17 @@ export default {
|
|||||||
// mode: 'android',
|
// mode: 'android',
|
||||||
// ua: 'Android_migu',
|
// ua: 'Android_migu',
|
||||||
// version: '6.9.4',
|
// version: '6.9.4',
|
||||||
osVersion: 'android 7.0',
|
// osVersion: 'android 10.0',
|
||||||
'User-Agent': 'okhttp/3.9.1',
|
uiVersion: 'A_music_3.6.1',
|
||||||
|
deviceId: encodeData.deviceId,
|
||||||
|
timestamp: timestamp.toString(),
|
||||||
|
sign: encodeData.sign,
|
||||||
|
'User-Agent': 'Mozilla/5.0 (Linux; U; Android 11.0.0; zh-cn; MI 11 Build/OPR1.170623.032) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30',
|
||||||
|
channel: '0146921',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
// searchRequest = httpFetch(`http://pd.musicapp.migu.cn/MIGUM2.0/v1.0/content/search_all.do?ua=Android_migu&version=5.0.1&text=${encodeURIComponent(str)}&pageNo=${page}&pageSize=${limit}&searchSwitch=%7B%22song%22%3A1%2C%22album%22%3A0%2C%22singer%22%3A0%2C%22tagSong%22%3A0%2C%22mvSong%22%3A0%2C%22songlist%22%3A0%2C%22bestShow%22%3A1%7D`, {
|
||||||
|
// searchRequest = httpFetch(`http://jadeite.migu.cn:7090/music_search/v2/search/searchAll?sid=4f87090d01c84984a11976b828e2b02c18946be88a6b4c47bcdc92fbd40762db&isCorrect=1&isCopyright=1&searchSwitch=%7B%22song%22%3A1%2C%22album%22%3A0%2C%22singer%22%3A0%2C%22tagSong%22%3A1%2C%22mvSong%22%3A0%2C%22bestShow%22%3A1%2C%22songlist%22%3A0%2C%22lyricSong%22%3A0%7D&pageSize=${limit}&text=${encodeURIComponent(str)}&pageNo=${page}&sort=0`, {
|
||||||
// searchRequest = httpFetch(`https://app.c.nf.migu.cn/MIGUM2.0/v1.0/content/search_all.do?isCopyright=1&isCorrect=1&pageNo=${page}&pageSize=${limit}&searchSwitch={%22song%22:1,%22album%22:0,%22singer%22:0,%22tagSong%22:0,%22mvSong%22:0,%22songlist%22:0,%22bestShow%22:0}&sort=0&text=${encodeURIComponent(str)}`)
|
// searchRequest = httpFetch(`https://app.c.nf.migu.cn/MIGUM2.0/v1.0/content/search_all.do?isCopyright=1&isCorrect=1&pageNo=${page}&pageSize=${limit}&searchSwitch={%22song%22:1,%22album%22:0,%22singer%22:0,%22tagSong%22:0,%22mvSong%22:0,%22songlist%22:0,%22bestShow%22:0}&sort=0&text=${encodeURIComponent(str)}`)
|
||||||
return searchRequest.promise.then(({ body }) => body)
|
return searchRequest.promise.then(({ body }) => body)
|
||||||
},
|
},
|
||||||
@ -39,36 +48,37 @@ export default {
|
|||||||
let ids = new Set()
|
let ids = new Set()
|
||||||
const list = []
|
const list = []
|
||||||
rawData.forEach(item => {
|
rawData.forEach(item => {
|
||||||
if (ids.has(item.id)) return
|
let data = item[0]
|
||||||
ids.add(item.id)
|
if (ids.has(data.id)) return
|
||||||
|
ids.add(data.id)
|
||||||
const types = []
|
const types = []
|
||||||
const _types = {}
|
const _types = {}
|
||||||
item.newRateFormats && item.newRateFormats.forEach(type => {
|
data.audioFormats && data.audioFormats.forEach(type => {
|
||||||
let size
|
let size
|
||||||
switch (type.formatType) {
|
switch (type.formatType) {
|
||||||
case 'PQ':
|
case 'PQ':
|
||||||
size = sizeFormate(type.size ?? type.androidSize)
|
size = sizeFormate(type.asize ?? type.isize)
|
||||||
types.push({ type: '128k', size })
|
types.push({ type: '128k', size })
|
||||||
_types['128k'] = {
|
_types['128k'] = {
|
||||||
size,
|
size,
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case 'HQ':
|
case 'HQ':
|
||||||
size = sizeFormate(type.size ?? type.androidSize)
|
size = sizeFormate(type.asize ?? type.isize)
|
||||||
types.push({ type: '320k', size })
|
types.push({ type: '320k', size })
|
||||||
_types['320k'] = {
|
_types['320k'] = {
|
||||||
size,
|
size,
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case 'SQ':
|
case 'SQ':
|
||||||
size = sizeFormate(type.size ?? type.androidSize)
|
size = sizeFormate(type.asize ?? type.isize)
|
||||||
types.push({ type: 'flac', size })
|
types.push({ type: 'flac', size })
|
||||||
_types.flac = {
|
_types.flac = {
|
||||||
size,
|
size,
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case 'ZQ':
|
case 'ZQ':
|
||||||
size = sizeFormate(type.size ?? type.androidSize)
|
size = sizeFormate(type.asize ?? type.isize)
|
||||||
types.push({ type: 'flac24bit', size })
|
types.push({ type: 'flac24bit', size })
|
||||||
_types.flac24bit = {
|
_types.flac24bit = {
|
||||||
size,
|
size,
|
||||||
@ -77,28 +87,21 @@ export default {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const albumNInfo = item.albums && item.albums.length
|
|
||||||
? {
|
|
||||||
id: item.albums[0].id,
|
|
||||||
name: item.albums[0].name,
|
|
||||||
}
|
|
||||||
: {}
|
|
||||||
|
|
||||||
list.push({
|
list.push({
|
||||||
singer: this.getSinger(item.singers),
|
singer: this.getSinger(data.singerList),
|
||||||
name: item.name,
|
name: data.name,
|
||||||
albumName: albumNInfo.name,
|
albumName: data.album,
|
||||||
albumId: albumNInfo.id,
|
albumId: data.albumId,
|
||||||
songmid: item.copyrightId,
|
songmid: data.copyrightId,
|
||||||
songId: item.songId,
|
songId: data.songId,
|
||||||
copyrightId: item.copyrightId,
|
copyrightId: data.copyrightId,
|
||||||
source: 'mg',
|
source: 'mg',
|
||||||
interval: null,
|
interval: formatPlayTime(data.duration),
|
||||||
img: item.imgItems && item.imgItems.length ? item.imgItems[0].img : null,
|
img: data.img3,
|
||||||
lrc: null,
|
lrc: null,
|
||||||
lrcUrl: item.lyricUrl,
|
lrcUrl: data.lyricUrl,
|
||||||
mrcUrl: item.mrcurl,
|
mrcUrl: data.mrcurl,
|
||||||
trcUrl: item.trcUrl,
|
trcUrl: data.trcUrl,
|
||||||
otherSource: null,
|
otherSource: null,
|
||||||
types,
|
types,
|
||||||
_types,
|
_types,
|
||||||
@ -116,7 +119,7 @@ export default {
|
|||||||
if (!result || result.code !== '000000') return Promise.reject(new Error(result ? result.info : '搜索失败'))
|
if (!result || result.code !== '000000') return Promise.reject(new Error(result ? result.info : '搜索失败'))
|
||||||
const songResultData = result.songResultData || { result: [], totalCount: 0 }
|
const songResultData = result.songResultData || { result: [], totalCount: 0 }
|
||||||
|
|
||||||
let list = this.handleResult(songResultData.result)
|
let list = this.handleResult(songResultData.resultList)
|
||||||
if (list == null) return this.search(str, page, limit, retryNum)
|
if (list == null) return this.search(str, page, limit, retryNum)
|
||||||
|
|
||||||
this.total = parseInt(songResultData.totalCount)
|
this.total = parseInt(songResultData.totalCount)
|
||||||
|
|||||||
9
src/renderer/utils/musicSdk/mg/util.js
Normal file
9
src/renderer/utils/musicSdk/mg/util.js
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import { toMD5 } from '../utils'
|
||||||
|
|
||||||
|
export const encode = (keyword, timestamp) => {
|
||||||
|
const deviceId = '963B7AA0D21511ED807EE5846EC87D16'
|
||||||
|
const signatureMd5 = '6cdc72a439cef99a3418d2a78aa28c73'
|
||||||
|
const text = `${keyword}${signatureMd5}yyapp2d16148780a1dcc7408e06336b98cfd50${deviceId}${timestamp}`
|
||||||
|
return { sign: toMD5(text), deviceId }
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user