mirror of
https://github.com/movie-web/providers.git
synced 2025-09-13 13:33:25 +00:00
move showbox fix to util function
This commit is contained in:
@@ -2,6 +2,7 @@ import CryptoJS from 'crypto-js';
|
|||||||
import { customAlphabet } from 'nanoid';
|
import { customAlphabet } from 'nanoid';
|
||||||
|
|
||||||
import type { ScrapeContext } from '@/utils/context';
|
import type { ScrapeContext } from '@/utils/context';
|
||||||
|
import { createSearchParams } from '@/utils/params';
|
||||||
|
|
||||||
import { apiUrls, appId, appKey, key } from './common';
|
import { apiUrls, appId, appKey, key } from './common';
|
||||||
import { encrypt, getVerify } from './crypto';
|
import { encrypt, getVerify } from './crypto';
|
||||||
@@ -35,12 +36,12 @@ export const sendRequest = async (ctx: ScrapeContext, data: object, altApi = fal
|
|||||||
const base64body = btoa(body);
|
const base64body = btoa(body);
|
||||||
|
|
||||||
const formatted = {
|
const formatted = {
|
||||||
'data': base64body,
|
data: base64body,
|
||||||
'appid': '27',
|
appid: '27',
|
||||||
'platform': 'android',
|
platform: 'android',
|
||||||
'version': '129',
|
version: '129',
|
||||||
'medium': 'Website',
|
medium: 'Website',
|
||||||
'token': randomId(32)
|
token: randomId(32),
|
||||||
};
|
};
|
||||||
|
|
||||||
const requestUrl = altApi ? apiUrls[1] : apiUrls[0];
|
const requestUrl = altApi ? apiUrls[1] : apiUrls[0];
|
||||||
@@ -52,7 +53,7 @@ export const sendRequest = async (ctx: ScrapeContext, data: object, altApi = fal
|
|||||||
'Content-Type': 'application/x-www-form-urlencoded',
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
'User-Agent': 'okhttp/3.2.0',
|
'User-Agent': 'okhttp/3.2.0',
|
||||||
},
|
},
|
||||||
body: Object.entries(formatted).map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`).join('&'),
|
body: createSearchParams(formatted),
|
||||||
});
|
});
|
||||||
return JSON.parse(response);
|
return JSON.parse(response);
|
||||||
};
|
};
|
||||||
|
5
src/utils/params.ts
Normal file
5
src/utils/params.ts
Normal file
@@ -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('&');
|
||||||
|
}
|
Reference in New Issue
Block a user