mirror of
https://github.com/daydreamer-json/ak-endfield-api-archive.git
synced 2026-03-24 16:22:25 +01:00
feat: add launcher protocol data archive
- Add protocol data for multiple locales and versions - Implement protocol archiving in archive command - Update Api types and default settings for protocol support
This commit is contained in:
@@ -531,6 +531,7 @@ async function fetchAndSaveLatestLauncher(launcherTargets: LauncherTarget[]) {
|
||||
async function fetchAndSaveLatestWebApis(gameTargets: GameTarget[]) {
|
||||
logger.debug('Fetching latestWebApis ...');
|
||||
const langs = apiUtils.akEndfield.defaultSettings.launcherWebLang;
|
||||
const langsCN = apiUtils.akEndfield.defaultSettings.launcherWebLangCN;
|
||||
const apis = [
|
||||
{ name: 'sidebar', method: apiUtils.akEndfield.launcherWeb.sidebar, dir: 'sidebar' },
|
||||
{ name: 'singleEnt', method: apiUtils.akEndfield.launcherWeb.singleEnt, dir: 'single_ent' },
|
||||
@@ -540,7 +541,7 @@ async function fetchAndSaveLatestWebApis(gameTargets: GameTarget[]) {
|
||||
] as const;
|
||||
|
||||
for (const target of gameTargets) {
|
||||
for (const lang of langs) {
|
||||
for (const lang of target.region === 'cn' ? langsCN : langs) {
|
||||
for (const api of apis) {
|
||||
networkQueue.add(async () => {
|
||||
const rsp = await api.method(target.appCode, target.channel, target.subChannel, lang, target.region);
|
||||
@@ -569,6 +570,50 @@ async function fetchAndSaveLatestWebApis(gameTargets: GameTarget[]) {
|
||||
await networkQueue.onIdle();
|
||||
}
|
||||
|
||||
async function fetchAndSaveLauncherProtocol(gameTargets: GameTarget[]) {
|
||||
logger.debug('Fetching launcherProtocol ...');
|
||||
const langs = apiUtils.akEndfield.defaultSettings.launcherWebLang;
|
||||
const langsCN = apiUtils.akEndfield.defaultSettings.launcherWebLangCN;
|
||||
const filterChannel = [
|
||||
appConfig.network.api.akEndfield.subChannel.cnWinRel,
|
||||
appConfig.network.api.akEndfield.subChannel.osWinRel,
|
||||
appConfig.network.api.akEndfield.subChannel.osWinRelEpic,
|
||||
];
|
||||
for (const target of gameTargets.filter((e) => filterChannel.includes(e.launcherSubChannel))) {
|
||||
for (const lang of target.region === 'cn' ? langsCN : langs) {
|
||||
networkQueue.add(async () => {
|
||||
const rsp = await apiUtils.akEndfield.launcher.protocol(
|
||||
target.launcherAppCode,
|
||||
target.channel,
|
||||
target.subChannel,
|
||||
lang,
|
||||
target.region,
|
||||
'',
|
||||
);
|
||||
if (!rsp) return;
|
||||
logger.trace(`Found protocol: ${rsp.dataVersion}, ${target.region.toUpperCase()}, ${target.name}, ${lang}`);
|
||||
const prettyRsp = {
|
||||
req: {
|
||||
appCode: target.launcherAppCode,
|
||||
channel: target.channel,
|
||||
subChannel: target.subChannel,
|
||||
language: lang,
|
||||
dataVersion: '',
|
||||
},
|
||||
rsp,
|
||||
};
|
||||
await saveResultWithHistory(
|
||||
['akEndfield', 'launcher', 'protocol', String(target.subChannel), lang],
|
||||
null,
|
||||
prettyRsp,
|
||||
{ ignoreRules: diffIgnoreRules },
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
await networkQueue.onIdle();
|
||||
}
|
||||
|
||||
async function mainCmdHandler() {
|
||||
const cfg = appConfig.network.api.akEndfield;
|
||||
const gameTargets: GameTarget[] = [
|
||||
@@ -638,6 +683,7 @@ async function mainCmdHandler() {
|
||||
await fetchAndSaveLatestGamePatches(gameTargets);
|
||||
await fetchAndSaveLatestGameResources(gameTargets);
|
||||
await fetchAndSaveLatestWebApis(gameTargets);
|
||||
await fetchAndSaveLauncherProtocol(gameTargets);
|
||||
await fetchAndSaveLatestLauncher(launcherTargets);
|
||||
await fetchAndSaveAllGameResRawData(gameTargets);
|
||||
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
type LauncherProtocol = {
|
||||
dataVersion: string;
|
||||
protocol: {
|
||||
version: string;
|
||||
};
|
||||
};
|
||||
type LauncherLatestGame = {
|
||||
action: number;
|
||||
version: string; // x.y.z
|
||||
@@ -549,6 +555,7 @@ type GameHubGiftCodeRedeem = {
|
||||
};
|
||||
|
||||
export type {
|
||||
LauncherProtocol,
|
||||
LauncherLatestGame,
|
||||
LauncherLatestGameResources,
|
||||
LauncherLatestLauncher,
|
||||
|
||||
@@ -24,4 +24,5 @@ export default {
|
||||
'zh-cn',
|
||||
'zh-tw',
|
||||
] as const,
|
||||
launcherWebLangCN: ['zh-cn'] as const,
|
||||
};
|
||||
|
||||
@@ -7,6 +7,39 @@ import defaultSettings from './defaultSettings.js';
|
||||
import launcherWeb from './launcherWeb.js';
|
||||
|
||||
export default {
|
||||
protocol: async (
|
||||
appCode: string,
|
||||
channel: number,
|
||||
subChannel: number,
|
||||
language: (typeof defaultSettings.launcherWebLang)[number],
|
||||
region: 'os' | 'cn',
|
||||
dataVersion: string = '',
|
||||
): Promise<TypesApiAkEndfield.LauncherProtocol> => {
|
||||
const apiBase =
|
||||
region === 'cn'
|
||||
? appConfig.network.api.akEndfield.base.launcherCN
|
||||
: appConfig.network.api.akEndfield.base.launcher;
|
||||
const rsp = await ky
|
||||
.post(`https://${apiBase}/proxy/batch_proxy`, {
|
||||
...defaultSettings.ky,
|
||||
json: {
|
||||
proxy_reqs: [
|
||||
{
|
||||
kind: 'get_protocol',
|
||||
get_protocol_req: {
|
||||
appcode: appCode,
|
||||
channel: String(channel),
|
||||
sub_channel: String(subChannel),
|
||||
language,
|
||||
dataVersion,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
.json();
|
||||
return (rsp as any).proxy_rsps[0].get_protocol as TypesApiAkEndfield.LauncherProtocol;
|
||||
},
|
||||
latestGame: async (
|
||||
appCode: string,
|
||||
launcherAppCode: string,
|
||||
|
||||
Reference in New Issue
Block a user