Merge pull request #100 from thehairy/dev
Fix showbox scraper for native app
This commit is contained in:
commit
c735ce33a0
|
@ -2,6 +2,7 @@ import CryptoJS from 'crypto-js';
|
|||
import { customAlphabet } from 'nanoid';
|
||||
|
||||
import type { ScrapeContext } from '@/utils/context';
|
||||
import { createSearchParams } from '@/utils/params';
|
||||
|
||||
import { apiUrls, appId, appKey, key } from './common';
|
||||
import { encrypt, getVerify } from './crypto';
|
||||
|
@ -34,13 +35,14 @@ export const sendRequest = async (ctx: ScrapeContext, data: object, altApi = fal
|
|||
});
|
||||
const base64body = btoa(body);
|
||||
|
||||
const formatted = new URLSearchParams();
|
||||
formatted.append('data', base64body);
|
||||
formatted.append('appid', '27');
|
||||
formatted.append('platform', 'android');
|
||||
formatted.append('version', '129');
|
||||
formatted.append('medium', 'Website');
|
||||
formatted.append('token', randomId(32));
|
||||
const formatted = {
|
||||
data: base64body,
|
||||
appid: '27',
|
||||
platform: 'android',
|
||||
version: '129',
|
||||
medium: 'Website',
|
||||
token: randomId(32),
|
||||
};
|
||||
|
||||
const requestUrl = altApi ? apiUrls[1] : apiUrls[0];
|
||||
|
||||
|
@ -51,7 +53,7 @@ export const sendRequest = async (ctx: ScrapeContext, data: object, altApi = fal
|
|||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'User-Agent': 'okhttp/3.2.0',
|
||||
},
|
||||
body: formatted,
|
||||
body: createSearchParams(formatted),
|
||||
});
|
||||
return JSON.parse(response);
|
||||
};
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
export function createSearchParams(params: { [key: string]: string | number }): string {
|
||||
return Object.entries(params)
|
||||
.map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`)
|
||||
.join('&');
|
||||
}
|
Loading…
Reference in New Issue