Update more stuff, the shit fix is just rm -rf ing .nuxt .output

This commit is contained in:
yuanhau 2025-05-22 18:13:55 +08:00
parent 62833af4ae
commit bb7ab3a088
2 changed files with 25 additions and 7 deletions

View file

@ -4,10 +4,8 @@ This took me some time, but they use a fancy system for pulling news data.
## Endpoint on news.yuanhau.com aka this repo (Cached results)
### /api/home/uuid_lt/action?query=${query}
Fetches the uuid in each listings of the query
### /api/home/lt/${query}
### /api/home/uuid_lt/feed?query=${query}
Fetches the uuid and returns back with the news
## Main endpoint

View file

@ -71,6 +71,16 @@ async function tryToPullDataUUID(uuid: string) {
"?country=tw&offset=0&length=27";
const req = await fetch(buildUrl);
const res = await req.json();
return res.items;
}
async function tryToPullDataNUUID(link: string) {
const buildUrl =
"https://today.line.me/webapi/recommendation/hybrid/listings/" +
link +
"?country=tw&maxVideoCount=0&offset=0&length=70&optOut=false";
const req = await fetch(buildUrl);
const res = await req.json();
return res;
}
@ -91,7 +101,7 @@ export default defineEventHandler(async (event) => {
const data = await tryToPullDataUUID(key);
return data;
}),
);
).then((ans) => ans.flat());
const diffFormat = [];
data.forEach((key) => {
if (validUUIDs.includes(key)) {
@ -101,10 +111,20 @@ export default defineEventHandler(async (event) => {
}
});
const fillll = filter2(diffFormat);
const cconaa: any[] = await Promise.all(
fillll.map(async (key) => {
if (key.includes("news_cat")) {
const data = await tryToPullDataNUUID(key);
return data;
} else {
}
}),
).then((ans) => ans.flat());
return {
valid: uniqueUUIDs,
maybe: fillll,
returnData: returnData,
uuids: uniqueUUIDs,
nuuid: fillll,
uuidData: returnData,
nuuiddata: cconaa,
};
} catch (e) {
console.log(e);