diff --git a/src/utils/get/getComments.ts b/src/utils/get/getComments.ts index 5264fd1..68ec3c1 100644 --- a/src/utils/get/getComments.ts +++ b/src/utils/get/getComments.ts @@ -56,6 +56,13 @@ export const getComments = async ( ID = ID[0] const resultComments = await parseComments(ID, commentLimit, proxy) + + if (!resultComments.comments.length) + return resolve({ + status: "error", + message: "No comments found!" + }) + return resolve({ status: "success", result: resultComments.comments, diff --git a/src/utils/get/getUserLiked.ts b/src/utils/get/getUserLiked.ts index 3bcd3e6..cb868e9 100644 --- a/src/utils/get/getUserLiked.ts +++ b/src/utils/get/getUserLiked.ts @@ -43,6 +43,12 @@ export const getUserLiked = ( const secUid = res.result.user.secUid const data = await parseUserLiked(id, secUid, cookie, postLimit, proxy) + if (!data.length) + return resolve({ + status: "error", + message: "User not found!" + }) + resolve({ status: "success", result: data, @@ -69,12 +75,6 @@ const parseUserLiked = async ( // Prevent missing response favorites result = await requestUserLiked(id, secUid, cookie, postLimit, proxy) - // Validate - if (result === "") { - hasMore = false - break - } - result?.itemList?.forEach((v: any) => { const statsAuthor: StatisticsAuthorLiked = { likeCount: v.authorStats.diggCount, @@ -235,6 +235,11 @@ const requestUserLiked = async ( : undefined)) || undefined }) + + if (data === "") { + throw new Error("Empty response") + } + return data } catch (error) { if (attempt === 3) { @@ -244,7 +249,7 @@ const requestUserLiked = async ( } }, { - retries: 3, + retries: 10, minTimeout: 1000, maxTimeout: 5000, factor: 2 diff --git a/src/utils/get/getUserPosts.ts b/src/utils/get/getUserPosts.ts index 9644efd..1e7d485 100644 --- a/src/utils/get/getUserPosts.ts +++ b/src/utils/get/getUserPosts.ts @@ -30,6 +30,12 @@ export const getUserPosts = ( const secUid = res.result.user.secUid const data = await parseUserPosts(secUid, postLimit, proxy) + if (!data.length) + return resolve({ + status: "error", + message: "User not found!" + }) + resolve({ status: "success", result: data, @@ -71,12 +77,6 @@ const parseUserPosts = async ( // Prevent missing response posts result = await requestUserPosts(proxy, xttparams) - // Validate - if (result === "") { - hasMore = false - break - } - result?.itemList?.forEach((v: any) => { const author: AuthorPost = { id: v.author.id, @@ -189,7 +189,11 @@ const requestUserPosts = async ( undefined } ) - console.log(data) + + if (data === "") { + throw new Error("Empty response") + } + return data } catch (error) { if ( @@ -203,7 +207,7 @@ const requestUserPosts = async ( } }, { - retries: 3, + retries: 10, minTimeout: 1000, maxTimeout: 5000, factor: 2, diff --git a/src/utils/search/liveSearch.ts b/src/utils/search/liveSearch.ts index d08517e..b5cb696 100644 --- a/src/utils/search/liveSearch.ts +++ b/src/utils/search/liveSearch.ts @@ -113,6 +113,9 @@ export const SearchLive = async ( result.push({ roomInfo, liveInfo }) }) + if (!result.length) + return resolve({ status: "error", message: "Live not found!" }) + resolve({ status: "success", result, diff --git a/src/utils/search/userSearch.ts b/src/utils/search/userSearch.ts index bef6000..573eb4b 100644 --- a/src/utils/search/userSearch.ts +++ b/src/utils/search/userSearch.ts @@ -84,6 +84,9 @@ export const SearchUser = ( }) } + if (!result.length) + return resolve({ status: "error", message: "User not found!" }) + resolve({ status: "success", result, diff --git a/src/utils/search/videoSearch.ts b/src/utils/search/videoSearch.ts index ff77418..14e6211 100644 --- a/src/utils/search/videoSearch.ts +++ b/src/utils/search/videoSearch.ts @@ -116,6 +116,9 @@ export const SearchVideo = async ( }) }) + if (!result.length) + return resolve({ status: "error", message: "Video not found!" }) + resolve({ status: "success", result, @@ -158,13 +161,18 @@ const requestVideoSearch = async ( undefined } ) + + if (data === "") { + throw new Error("Empty response") + } + return data } catch (error) { throw error } }, { - retries: 3, + retries: 10, minTimeout: 1000, maxTimeout: 5000, factor: 2,