better-ani-scraped 1.6.6 → 1.6.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -3,7 +3,7 @@ import { AnimeScraper } from "../../index.js"; // REPLACE BY "from 'better-ani-s
|
|
|
3
3
|
const main = async () => {
|
|
4
4
|
const animesama = new AnimeScraper('animesama');
|
|
5
5
|
|
|
6
|
-
const search = await animesama.searchAnime("
|
|
6
|
+
const search = await animesama.searchAnime("gachiakuta", 100, [], ["Anime", "Film", "Autres", "Scans"]);
|
|
7
7
|
console.log("Search Results:", search);
|
|
8
8
|
};
|
|
9
9
|
|
package/package.json
CHANGED
package/scrapers/animesama.js
CHANGED
|
@@ -46,12 +46,15 @@ function getHeaders(referer = BASE_URL) {
|
|
|
46
46
|
export async function searchAnime(
|
|
47
47
|
query,
|
|
48
48
|
limit = 10,
|
|
49
|
-
wantedLanguages =
|
|
50
|
-
wantedTypes =
|
|
49
|
+
wantedLanguages = null,
|
|
50
|
+
wantedTypes = null,
|
|
51
51
|
page = null
|
|
52
52
|
) {
|
|
53
|
+
const languages = Array.isArray(wantedLanguages) ? wantedLanguages : ["vostfr", "vf", "vastfr"];
|
|
54
|
+
const types = Array.isArray(wantedTypes) ? wantedTypes : ["Anime", "Film"];
|
|
55
|
+
|
|
53
56
|
const isWanted = (text, list) =>
|
|
54
|
-
list.some(item => text.toLowerCase().includes(item.toLowerCase()));
|
|
57
|
+
list.length === 0 || list.some(item => text.toLowerCase().includes(item.toLowerCase()));
|
|
55
58
|
|
|
56
59
|
const results = [];
|
|
57
60
|
|
|
@@ -76,11 +79,11 @@ export async function searchAnime(
|
|
|
76
79
|
const cover = anchor.find("img").first().attr("src");
|
|
77
80
|
|
|
78
81
|
const tagText = anchor.find("p").filter((_, p) =>
|
|
79
|
-
isWanted($(p).text(),
|
|
82
|
+
isWanted($(p).text(), types)
|
|
80
83
|
).first().text();
|
|
81
84
|
|
|
82
85
|
const languageText = anchor.find("p").filter((_, p) =>
|
|
83
|
-
isWanted($(p).text(),
|
|
86
|
+
isWanted($(p).text(), languages)
|
|
84
87
|
).first().text();
|
|
85
88
|
|
|
86
89
|
const altTitles = altRaw
|
|
@@ -92,7 +95,10 @@ export async function searchAnime(
|
|
|
92
95
|
? genreRaw.split(",").map((g) => g.trim()).filter(Boolean)
|
|
93
96
|
: [];
|
|
94
97
|
|
|
95
|
-
|
|
98
|
+
const hasValidType = types.length === 0 || tagText;
|
|
99
|
+
const hasValidLanguage = languages.length === 0 || languageText;
|
|
100
|
+
|
|
101
|
+
if (title && link && hasValidType && hasValidLanguage) {
|
|
96
102
|
results.push({
|
|
97
103
|
title,
|
|
98
104
|
altTitles,
|