feat: added anime extraction util methods
This commit is contained in:
@@ -176,3 +176,28 @@ export const extractMostPopularAnimes = (
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export function retrieveServerId(
|
||||||
|
$: CheerioAPI,
|
||||||
|
index: number,
|
||||||
|
category: "sub" | "dub"
|
||||||
|
) {
|
||||||
|
return (
|
||||||
|
$(`.ps_-block.ps_-block-sub.servers-${category} > .ps__-list .server-item`)
|
||||||
|
?.map((_, el) =>
|
||||||
|
$(el).attr("data-server-id") == `${index}` ? $(el) : null
|
||||||
|
)
|
||||||
|
?.get()[0]
|
||||||
|
?.attr("data-id") || null
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function substringAfter(str: string, toFind: string) {
|
||||||
|
const index = str.indexOf(toFind);
|
||||||
|
return index == -1 ? "" : str.substring(index + toFind.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function substringBefore(str: string, toFind: string) {
|
||||||
|
const index = str.indexOf(toFind);
|
||||||
|
return index == -1 ? "" : str.substring(0, index);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user