Fetch 4Anime videos and data via Node.
Learn more here
v3
term().v2
Instance.episodes() Read here...result.toJSON()const FourAnime = require('node-4anime-scraper');
// Or with imports
// import FourAnime from 'node-4anime-scraper'
// on typescript
// import * as FourAnime from 'node-4anime-scraper'
FourAnime.term('shingeki no kyojin').then(search => {
// `search` is an array of `SearchResult` instances...
const first = search[0].toJSON();
const last = search.pop().toJSON();
// or
const readable = search.map(s => s.toJSON());
});
FourAnime.term(s: string)
SearchResult instances.SearchResult instance.See Docs... for more.
// with Promises
FourAnime.term('jujutsu kaisen')
.then(results => {
results.forEach(e => console.log(e.toJSON()));
})
.catch(function (e) {
console.error(e);
});
// with async/await
const results = await FourAnime.term('jujutsu kaisen');
results.forEach(s => console.log(s.toJSON()));
Instance.episodes()???On v2, Instance.episodes() is no longer available.
Instead use SearchResult.getAnime() to fetch anime data and episode links. The function returns a promise.
// Promises
FourAnime.term('shingeki').then(results => {
const first = results[0];
first.getAnime().then(anime => {
// Logs an array of episodes
console.log(anime.getEpisodes());
});
});
// or with async/await
const results = await FourAnime.term('shingeki');
const first = results[0];
const anime = await first.getAnime();
// and so on...
This might have bugs or might not work... If there are issues don't forget to create one.
On getAnime(), you can pass an episodes option to filter the episodes.
const results = await FourAnime.term('shingeki');
const first = results[0];
// Get the episodes we want
const filtered_episodes = await first.getAnime({ episodes: '11, 12, 13' });
// Remove the episodes we already watched add a `-` at the beginning. MAKE SURE TO ADD SPACE AFTER THE HYPHEN
const removed_episodes = await first.getAnime({ episodes: '- 1, 2, 3' });
// You can use spaces instead of commas.
const removed_episodes = await first.getAnime({
// It will ignore the whitespaces
episodes: '- 1 2 3 5',
});
FourAnime.term() and SearchResult.getAnime() returns an instance.
To make it much readable, use toJSON() or get()
FourAnime.term('shingeki').then(results => {
const first = results[0];
first.getAnime().then(anime => {
console.log(anime.toJSON());
});
});
Thnx
Generated using TypeDoc