11const cookieName = '字幕组'
22const cookieKey = 'chavy_cookie_zimuzu'
33const cookieAppKey = 'chavy_cookie_zimuzu_app'
4+ const authUrlAppKey = 'chavy_auth_url_zimuzu_app'
45const chavy = init ( )
56const cookieVal = chavy . getdata ( cookieKey )
6- const cookieAppVal = chavy . getdata ( cookieAppKey )
7+ let cookieAppVal = chavy . getdata ( cookieAppKey )
8+ const authUrlAppVal = chavy . getdata ( authUrlAppKey )
79const signinfo = { }
810
911sign ( )
@@ -24,19 +26,60 @@ function signweb() {
2426 } )
2527}
2628
27- function signapp ( ) {
28- let url = { url : `http://h5.rrhuodong.com/index.php?g=api/mission&m=clock&a=store&id=2` , headers : { Cookie : cookieAppVal } }
29+ function loginapp ( cb ) {
30+ if ( authUrlAppVal ) {
31+ const url = { url : authUrlAppVal , headers : { } }
32+ url . headers [ 'Accept' ] = `*/*`
33+ url . headers [ 'Accept-Encoding' ] = `gzip;q=1.0, compress;q=0.5`
34+ url . headers [ 'Accept-Language' ] = `zh-Hans-CN;q=1.0, en-US;q=0.9`
35+ url . headers [ 'Connection' ] = `close`
36+ url . headers [ 'Host' ] = `ios.zmzapi.com`
37+ url . headers [ 'Referer' ] = `http://h5.rrhuodong.com/mobile/mission/pages/task.html`
38+ url . headers [ 'User-Agent' ] = `YYets_swift/2.5.7 (com.yyets.ZiMuZu; build:29; iOS 13.3.1) Alamofire/4.9.1`
39+ chavy . get ( url , ( error , response , data ) => {
40+ const result = JSON . parse ( data )
41+ if ( result . status == 1 ) refreshapp ( result , cb )
42+ else signinfo . app = result
43+ } )
44+ } else {
45+ cb ( )
46+ }
47+ }
48+
49+ function refreshapp ( logininfo , cb ) {
50+ const url = { url : `http://h5.rrhuodong.com/index.php?g=api/mission&m=index&a=login&uid=${ logininfo . data . uid } &token=${ logininfo . data . token } ` , headers : { } }
2951 url . headers [ 'Accept' ] = `application/json, text/plain, */*`
3052 url . headers [ 'Accept-Encoding' ] = `gzip, deflate`
3153 url . headers [ 'Accept-Language' ] = `zh-cn`
3254 url . headers [ 'Connection' ] = `close`
3355 url . headers [ 'Host' ] = `h5.rrhuodong.com`
3456 url . headers [ 'Referer' ] = `http://h5.rrhuodong.com/mobile/mission/pages/task.html`
3557 url . headers [ 'User-Agent' ] = `Mozilla/5.0 (iPhone; CPU iPhone OS 13_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148`
36-
3758 chavy . get ( url , ( error , response , data ) => {
38- chavy . log ( `${ cookieName } , signapp - data: ${ data } ` )
39- signinfo . app = JSON . parse ( data )
59+ const respcookie = response . headers [ 'Set-Cookie' ]
60+ if ( respcookie && respcookie . indexOf ( 'PHPSESSID=' ) >= 0 ) {
61+ cookieAppVal = response . headers [ 'Set-Cookie' ] . match ( / P H P S E S S I D = ( [ ^ ; ] * ) / ) [ 0 ]
62+ if ( cookieAppVal ) chavy . setdata ( cookieAppVal , cookieAppKey )
63+ }
64+ cb ( )
65+ } )
66+ }
67+
68+ function signapp ( ) {
69+ loginapp ( ( ) => {
70+ let url = { url : `http://h5.rrhuodong.com/index.php?g=api/mission&m=clock&a=store&id=2` , headers : { Cookie : cookieAppVal } }
71+ url . headers [ 'Accept' ] = `application/json, text/plain, */*`
72+ url . headers [ 'Accept-Encoding' ] = `gzip, deflate`
73+ url . headers [ 'Accept-Language' ] = `zh-cn`
74+ url . headers [ 'Connection' ] = `close`
75+ url . headers [ 'Host' ] = `h5.rrhuodong.com`
76+ url . headers [ 'Referer' ] = `http://h5.rrhuodong.com/mobile/mission/pages/task.html`
77+ url . headers [ 'User-Agent' ] = `Mozilla/5.0 (iPhone; CPU iPhone OS 13_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148`
78+
79+ chavy . get ( url , ( error , response , data ) => {
80+ chavy . log ( `${ cookieName } , signapp - data: ${ data } ` )
81+ signinfo . app = JSON . parse ( data )
82+ } )
4083 } )
4184}
4285
@@ -106,7 +149,7 @@ function init() {
106149 }
107150 if ( isQuanX ( ) ) {
108151 url . method = 'GET'
109- $task . fetch ( url ) . then ( ( resp ) => cb ( null , { } , resp . body ) )
152+ $task . fetch ( url ) . then ( ( resp ) => cb ( null , resp , resp . body ) )
110153 }
111154 }
112155 post = ( url , cb ) => {
@@ -115,7 +158,7 @@ function init() {
115158 }
116159 if ( isQuanX ( ) ) {
117160 url . method = 'POST'
118- $task . fetch ( url ) . then ( ( resp ) => cb ( null , { } , resp . body ) )
161+ $task . fetch ( url ) . then ( ( resp ) => cb ( null , resp , resp . body ) )
119162 }
120163 }
121164 done = ( value = { } ) => {
0 commit comments