@@ -164,8 +164,7 @@ class netease {
164164 const nnidName = '_ntes_nnid' ;
165165 const nuidValue = this . _create_secret_key ( 32 ) ;
166166 const nnidValue = `${ nuidValue } ,${ new Date ( ) . getTime ( ) } ` ;
167- const nmtidName = 'NMTID' ;
168- const nmtidValue = '0' ;
167+ const musicuName = 'MUSIC_U' ;
169168
170169 // netease default cookie expire time: 100 years
171170 const expire =
@@ -174,43 +173,44 @@ class netease {
174173 [
175174 { url : domain , name : nuidName } ,
176175 { url : domain , name : nnidName } ,
177- { url : domain , name : nmtidName } ,
176+ { url : domain , name : musicuName } ,
178177 ] ,
179178 ( item , cb ) => {
180179 cookieGet ( item , ( result ) => cb ( null , result ) ) ;
181180 } ,
182181 ( _ , results ) => {
183- if ( results . filter ( ( i ) => i === null ) . length > 0 ) {
184- async . concat (
185- [
186- {
187- url : domain ,
188- name : nuidName ,
189- value : nuidValue ,
190- expirationDate : expire ,
191- sameSite : 'no_restriction' ,
192- } ,
193- {
194- url : domain ,
195- name : nnidName ,
196- value : nnidValue ,
197- expirationDate : expire ,
198- sameSite : 'no_restriction' ,
199- } ,
200- {
201- url : domain ,
202- name : nmtidName ,
203- value : nmtidValue ,
204- expirationDate : expire ,
205- sameSite : 'no_restriction' ,
206- } ,
207- ] ,
208- cookieSet ,
209- ( ) => {
210- callback ( null ) ;
211- }
212- ) ;
213- }
182+ if ( results . filter ( ( i ) => i === null || i . sameSite !== 'no_restriction' ) . length === 0 ) return ;
183+ let musicu = results . filter ( ( i ) => i !== null && i . name === musicuName && i . value ) ;
184+ if ( musicu . length === 0 ) return ;
185+ async . concat (
186+ [
187+ {
188+ url : domain ,
189+ name : nuidName ,
190+ value : nuidValue ,
191+ expirationDate : expire ,
192+ sameSite : 'no_restriction' ,
193+ } ,
194+ {
195+ url : domain ,
196+ name : nnidName ,
197+ value : nnidValue ,
198+ expirationDate : expire ,
199+ sameSite : 'no_restriction' ,
200+ } ,
201+ {
202+ url : domain ,
203+ name : musicuName ,
204+ value : musicu [ 0 ] . value ,
205+ expirationDate : expire ,
206+ sameSite : 'no_restriction' ,
207+ } ,
208+ ] ,
209+ cookieSet ,
210+ ( ) => {
211+ callback ( null ) ;
212+ }
213+ ) ;
214214 }
215215 ) ;
216216 }
@@ -920,7 +920,7 @@ class netease {
920920 const encrypt_req_data = this . weapi ( { } ) ;
921921 return {
922922 success : ( fn ) => {
923- axios . post ( url , new URLSearchParams ( encrypt_req_data ) ) . then ( ( res ) => {
923+ this . ne_ensure_cookie ( ( ) => axios . post ( url , new URLSearchParams ( encrypt_req_data ) ) . then ( ( res ) => {
924924 let result = { is_login : false } ;
925925 let status = 'fail' ;
926926 if ( res . data . account !== null ) {
@@ -941,7 +941,7 @@ class netease {
941941 status,
942942 data : result ,
943943 } ) ;
944- } ) ;
944+ } ) ) ;
945945 } ,
946946 } ;
947947 }
0 commit comments