forked from anime-vsub/app
-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2be63bc
commit deac2f4
Showing
5 changed files
with
697 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export function AnimeEpisodes(html) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { parserDom } from "../__helpers__/parserDom" | ||
|
||
interface AnimeItem { | ||
name_lower: string | ||
search_name: string | ||
id: number | ||
type: string | ||
name: string | ||
url: string | ||
image_url: string | ||
} | ||
|
||
export default function AnimeSearch(html: string) { | ||
const $ = parserDom(html) | ||
|
||
return $(".js-categories-seasonal tr") | ||
.toArray() | ||
.map((tr) => { | ||
const url = $(tr).find(".hoverinfo_trigger").attr("href") | ||
if (!url) return null | ||
|
||
const indexParamAnime = url.indexOf("/anime/") + 7 | ||
|
||
if (indexParamAnime === -1) return null | ||
|
||
const id = parseInt( | ||
url.slice(indexParamAnime, url.indexOf("/", indexParamAnime)) | ||
) | ||
const name = $(tr).find("strong").text() | ||
// eslint-disable-next-line camelcase | ||
const image_url = $(tr).find("img").attr("src") | ||
|
||
// eslint-disable-next-line camelcase | ||
return { id, type: "anime", name, url, image_url } | ||
}) | ||
.filter(Boolean) as AnimeItem[] | ||
} |
Oops, something went wrong.