()
| 132 | |
| 133 | |
| 134 | async function testDisneyPlus() { |
| 135 | try { |
| 136 | let { region, cnbl } = await Promise.race([testHomePage(), timeout(7000)]) |
| 137 | console.log(`homepage: region=${region}, cnbl=${cnbl}`) |
| 138 | // 即将登陆 |
| 139 | // if (cnbl == 2) { |
| 140 | // return { region, status: STATUS_COMING } |
| 141 | // } |
| 142 | let { countryCode, inSupportedLocation, accessToken } = await Promise.race([getLocationInfo(), timeout(7000)]) |
| 143 | console.log(`getLocationInfo: countryCode=${countryCode}, inSupportedLocation=${inSupportedLocation}`) |
| 144 | |
| 145 | region = countryCode ?? region |
| 146 | console.log( "region:"+region) |
| 147 | // 即将登陆 |
| 148 | if (inSupportedLocation === false || inSupportedLocation === 'false') { |
| 149 | return { region, status: STATUS_COMING } |
| 150 | } else { |
| 151 | // 支持解锁 |
| 152 | return { region, status: STATUS_AVAILABLE } |
| 153 | } |
| 154 | |
| 155 | let support = await Promise.race([testPublicGraphqlAPI(accessToken), timeout(7000)]) |
| 156 | if (!support) { |
| 157 | return { status: STATUS_NOT_AVAILABLE } |
| 158 | } |
| 159 | // 支持解锁 |
| 160 | return { region, status: STATUS_AVAILABLE } |
| 161 | |
| 162 | } catch (error) { |
| 163 | console.log("error:"+error) |
| 164 | |
| 165 | // 不支持解锁 |
| 166 | if (error === 'Not Available') { |
| 167 | console.log("不支持") |
| 168 | return { status: STATUS_NOT_AVAILABLE } |
| 169 | } |
| 170 | |
| 171 | // 检测超时 |
| 172 | if (error === 'Timeout') { |
| 173 | return { status: STATUS_TIMEOUT } |
| 174 | } |
| 175 | |
| 176 | return { status: STATUS_ERROR } |
| 177 | } |
| 178 | |
| 179 | } |
| 180 | |
| 181 | function getLocationInfo() { |
| 182 | return new Promise((resolve, reject) => { |
no test coverage detected