1- import { httpFetch } from '../../request'
21import { formatPlayTime , sizeFormate } from '../../index'
32import { formatSingerName } from '../utils'
3+ import { signRequest } from './utils'
44
55export default {
66 limit : 50 ,
@@ -10,71 +10,77 @@ export default {
1010 successCode : 0 ,
1111 musicSearch ( str , page , limit , retryNum = 0 ) {
1212 if ( retryNum > 5 ) return Promise . reject ( new Error ( '搜索失败' ) )
13- // searchRequest = httpFetch(`https://c.y.qq.com/soso/fcgi-bin/client_search_cp?ct=24&qqmusic_ver=1298&new_json=1&remoteplace=sizer.yqq.song_next&searchid=49252838123499591&t=0&aggr=1&cr=1&catZhida=1&lossless=0&flag_qc=0&p=${page}&n=${limit}&w=${encodeURIComponent(str)}&loginUin=0&hostUin=0&format=json&inCharset=utf8&outCharset=utf-8¬ice=0&platform=yqq&needNewCode=0`)
14- // const searchRequest = httpFetch(`https://shc.y.qq.com/soso/fcgi-bin/client_search_cp?ct=24&qqmusic_ver=1298&remoteplace=txt.yqq.top&aggr=1&cr=1&catZhida=1&lossless=0&flag_qc=0&p=${page}&n=${limit}&w=${encodeURIComponent(str)}&cv=4747474&ct=24&format=json&inCharset=utf-8&outCharset=utf-8¬ice=0&platform=yqq.json&needNewCode=0&uin=0&hostUin=0&loginUin=0`)
15- const searchRequest = httpFetch ( 'https://u.y.qq.com/cgi-bin/musicu.fcg' , {
16- method : 'post' ,
17- headers : {
18- 'User-Agent' : 'QQMusic 14090508(android 12)' ,
13+ const searchRequest = signRequest ( {
14+ comm : {
15+ ct : '11' ,
16+ cv : '14090508' ,
17+ v : '14090508' ,
18+ tmeAppID : 'qqmusic' ,
19+ phonetype : 'EBG-AN10' ,
20+ deviceScore : '553.47' ,
21+ devicelevel : '50' ,
22+ newdevicelevel : '20' ,
23+ rom : 'HuaWei/EMOTION/EmotionUI_14.2.0' ,
24+ os_ver : '12' ,
25+ OpenUDID : '0' ,
26+ OpenUDID2 : '0' ,
27+ QIMEI36 : '0' ,
28+ udid : '0' ,
29+ chid : '0' ,
30+ aid : '0' ,
31+ oaid : '0' ,
32+ taid : '0' ,
33+ tid : '0' ,
34+ wid : '0' ,
35+ uid : '0' ,
36+ sid : '0' ,
37+ modeSwitch : '6' ,
38+ teenMode : '0' ,
39+ ui_mode : '2' ,
40+ nettype : '1020' ,
41+ v4ip : '' ,
1942 } ,
20- body : {
21- comm : {
22- ct : '11' ,
23- cv : '14090508' ,
24- v : '14090508' ,
25- tmeAppID : 'qqmusic' ,
26- phonetype : 'EBG-AN10' ,
27- deviceScore : '553.47' ,
28- devicelevel : '50' ,
29- newdevicelevel : '20' ,
30- rom : 'HuaWei/EMOTION/EmotionUI_14.2.0' ,
31- os_ver : '12' ,
32- OpenUDID : '0' ,
33- OpenUDID2 : '0' ,
34- QIMEI36 : '0' ,
35- udid : '0' ,
36- chid : '0' ,
37- aid : '0' ,
38- oaid : '0' ,
39- taid : '0' ,
40- tid : '0' ,
41- wid : '0' ,
42- uid : '0' ,
43- sid : '0' ,
44- modeSwitch : '6' ,
45- teenMode : '0' ,
46- ui_mode : '2' ,
47- nettype : '1020' ,
48- v4ip : '' ,
49- } ,
50- req : {
51- module : 'music.search.SearchCgiService' ,
52- method : 'DoSearchForQQMusicMobile' ,
53- param : {
54- search_type : 0 ,
55- query : str ,
56- page_num : page ,
57- num_per_page : limit ,
58- highlight : 0 ,
59- nqc_flag : 0 ,
60- multi_zhida : 0 ,
61- cat : 2 ,
62- grp : 1 ,
63- sin : 0 ,
64- sem : 0 ,
65- } ,
43+ req : {
44+ module : 'music.search.SearchCgiService' ,
45+ method : 'DoSearchForQQMusicMobile' ,
46+ param : {
47+ search_type : 0 ,
48+ searchid : Math . random ( ) . toString ( ) . slice ( 2 ) ,
49+ query : str ,
50+ page_num : page ,
51+ num_per_page : limit ,
52+ highlight : 0 ,
53+ nqc_flag : 0 ,
54+ multi_zhida : 0 ,
55+ cat : 2 ,
56+ grp : 1 ,
57+ sin : 0 ,
58+ sem : 0 ,
6659 } ,
6760 } ,
6861 } )
69- // searchRequest = httpFetch(`http://ioscdn.kugou.com/api/v3/search/song?keyword=${encodeURIComponent(str)}&page=${page}&pagesize=${this.limit}&showtype=10&plat=2&version=7910&tag=1&correct=1&privilege=1&sver=5`)
70- return searchRequest . promise . then ( ( { body } ) => {
62+ return searchRequest . then ( ( { body } ) => {
7163 // console.log(body)
72- if ( body . code != this . successCode || body . req . code != this . successCode ) return this . musicSearch ( str , page , limit , ++ retryNum )
64+ if ( ! body || ! body . req || body . code != this . successCode || body . req . code != this . successCode ) {
65+ return this . musicSearch ( str , page , limit , ++ retryNum )
66+ }
7367 return body . req . data
7468 } )
7569 } ,
70+ // randomInt(min, max) {
71+ // return Math.floor(Math.random() * (max - min + 1)) + min
72+ // },
73+ // getSearchId() {
74+ // const e = BigInt(this.randomInt(1, 20))
75+ // const t = e * 18014398509481984n
76+ // const n = BigInt(this.randomInt(0, 4194304)) * 4294967296n
77+ // const a = BigInt(Date.now())
78+ // const r = (a * 1000n) % (24n * 60n * 60n * 1000n)
79+ // return String(t + n + r)
80+ // },
7681 handleResult ( rawList ) {
77- console . log ( rawList )
82+ // console.log(rawList)
83+ if ( ! rawList || ! Array . isArray ( rawList ) ) return [ ]
7884 const list = [ ]
7985 rawList . forEach ( item => {
8086 if ( ! item . file ?. media_mid ) return
0 commit comments