diff --git a/api/api.ts b/api/api.ts index 14c79fc0..78c738db 100644 --- a/api/api.ts +++ b/api/api.ts @@ -15,7 +15,7 @@ import { albums, AvailableLocales, availableLocales } from './albumParser.js' import { search as searchF } from './common.js' import { joinJob } from './spider.js' -import { dispatch, receipt } from './dispatcher.js' +import { dispatch, dispatch256, receipt } from './dispatcher.js' const __dirname = dirname(fileURLToPath(import.meta.url)) @@ -202,6 +202,10 @@ router.post('/dispatch', ctx => { ctx.body = { url: dispatch() } }) +router.post('/dispatch256', ctx => { + ctx.body = { urls: dispatch256() } +}) + router.post('/receipt', koaBody(), ctx => { const { url, data } = ctx.request.body ctx.body = { result: receipt(url, JSON.parse(data)) } diff --git a/api/dispatcher.ts b/api/dispatcher.ts index a821d62e..4b15681c 100644 --- a/api/dispatcher.ts +++ b/api/dispatcher.ts @@ -20,6 +20,7 @@ export const fetch = async (url: string) => { } export const dispatch = () => jobs[Math.floor(Math.random() * jobs.length)]?.url +export const dispatch256 = () => jobs.filter((_, i) => i < 256).map(job => job.url) export const receipt = (url: string, data: any) => { if (data.code === 0) {