const axios = require('axios'); class Animob { constructor() { this.client = axios.create({ baseURL: 'https://animob-vidstr.fun/api', headers: { 'accept-encoding': 'gzip', connection: 'Keep-Alive', host: 'animob-vidstr.fun', 'user-agent': 'okhttp/4.9.2' } }); } home = async function () { try { const { data } = await this.client('/'); return data.results; } catch (error) { throw new Error(error.message); } } genre = async function (genre = 'action', page = 1) { try { const _genre = ['action', 'adventure', 'cars', 'comedy', 'dementia', 'demons', 'drama', 'ecchi', 'fantasy', 'game', 'harem', 'historical', 'horror', 'isekai', 'josei', 'kids', 'magic', 'martial-arts', 'mecha', 'military', 'music', 'mystery', 'parody', 'police', 'psychological', 'romance', 'samurai', 'school', 'sci-fi', 'seinen', 'shoujo', 'shoujo-ai', 'shounen', 'shounen-ai', 'slice-of-life', 'space', 'sports', 'super-power', 'supernatural', 'thriller', 'vampire']; if (!_genre.includes(genre)) throw new Error(`Available genres: ${_genre.join}.`); const { data } = await this.client(`/genre/${genre}`, { params: { page: page } }); return data.results; } catch (error) { throw new Error(error.message); } } search = async function (query, page = 1) { try { if (!query) throw new Error('Query is required.'); const { data } = await this.client('/filter', { params: { keyword: query, page: page } }); return data.results; } catch (error) { throw new Error(error.message); } } detail = async function (id) { try { if (!id) throw new Error('Id is required.'); const { data } = await this.client(`/info?id=${id}`); const { data: ep } = await this.client(`/episodes/${id}`); return { ...data.results, episodes: ep.results.episodes }; } catch (error) { throw new Error(error.message); } } episode = async function (episodeId) { try { if (!episodeId || !episodeId.includes('?ep=')) throw new Error('Invalid episode id.'); const { data } = await this.client(`/backup/show-anime?episodeId=${episodeId}`); return data.results; } catch (error) { throw new Error(error.message); } } } // Usage: const a = new Animob(); a.detail('please-put-them-on-takamine-san-uncensored-19640').then(console.log);