mirror of
https://github.com/hpware/news-analyze.git
synced 2025-06-23 15:51:01 +08:00
Update slug stuff.
This commit is contained in:
parent
004028d7b5
commit
c8429ee1a3
@ -45,7 +45,7 @@ We can ignore everything else, other than the strange UUID in the json. Well, th
|
|||||||
Here is the fancy URL:
|
Here is the fancy URL:
|
||||||
`https://today.line.me/api/v6/listings/{the-uuid-you-got-in-the-listings-json-file}/?country=tw&offset=0&length=24`
|
`https://today.line.me/api/v6/listings/{the-uuid-you-got-in-the-listings-json-file}/?country=tw&offset=0&length=24`
|
||||||
|
|
||||||
This api can be used for fetching the news from them, however, there is an issue, the max length is only just 24 (yes, I tried it only can return 24 when requesting for 1000)
|
This api can be used for fetching the news from them, however, there is an issue, the max length is only just 24 (yes, I tried it only can return 27* when requesting for 1000)
|
||||||
|
|
||||||
|
|
||||||
And viewing the JSON, oh would you look at that.
|
And viewing the JSON, oh would you look at that.
|
||||||
|
5
components/app/windows/news.vue
Normal file
5
components/app/windows/news.vue
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<template>
|
||||||
|
<div class="justify-center align-center text-center">
|
||||||
|
<div></div>
|
||||||
|
</div>
|
||||||
|
</template>
|
@ -59,15 +59,46 @@ function filterUUIDs(ids: string[]): string[] {
|
|||||||
return ids.filter((id) => uuidPattern.test(id));
|
return ids.filter((id) => uuidPattern.test(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function filter2(ids: string[]): string[] {
|
||||||
|
const pattern = /.*:[a-zA-Z0-9]{24}/g;
|
||||||
|
return ids.filter((id) => pattern.test(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
async function tryToPullDataUUID(uuid: string) {
|
||||||
|
const buildUrl =
|
||||||
|
"https://today.line.me/api/v6/listings/" +
|
||||||
|
uuid +
|
||||||
|
"?country=tw&offset=0&length=27";
|
||||||
|
const req = await fetch(buildUrl);
|
||||||
|
const res = await req.json();
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
export default defineEventHandler(async (event) => {
|
export default defineEventHandler(async (event) => {
|
||||||
try {
|
try {
|
||||||
|
const query = getQuery(event);
|
||||||
|
if (!query.query) {
|
||||||
|
return {
|
||||||
|
error: "NOT_A_QUERY",
|
||||||
|
};
|
||||||
|
}
|
||||||
const data = await getUUID(String(query.query));
|
const data = await getUUID(String(query.query));
|
||||||
const validUUIDs = filterUUIDs(data || []);
|
const validUUIDs = filterUUIDs(data || []);
|
||||||
const slug = getRouterParam(event, "slug");
|
const diffFormat = [];
|
||||||
const urlBuild = "/api/home/uuid_lt/action?query=" + String(slug.trim());
|
data.forEach((key) => {
|
||||||
const articleArray = [];
|
if (validUUIDs.includes(key)) {
|
||||||
const { data: res } = await useFetch(urlBuild);
|
return;
|
||||||
return res;
|
} else {
|
||||||
|
diffFormat.push(key);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const returnData = [];
|
||||||
|
validUUIDs.forEach(async (key) => {
|
||||||
|
const data = await tryToPullDataUUID(key);
|
||||||
|
returnData.push(data);
|
||||||
|
});
|
||||||
|
const fillll = filter2(diffFormat);
|
||||||
|
return { valid: validUUIDs, maybe: fillll, returnData: returnData };
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
return {
|
return {
|
Loading…
x
Reference in New Issue
Block a user