rynn-k / gists
animelovers.js javascript
const axios = require('axios');

class AnimeLovers {
    constructor() {
        this.client = axios.create({
            baseURL: 'https://apps.animekita.org/api/v1.1.9',
            headers: {
                'accept-encoding': 'gzip',
                'host': 'apps.animekita.org',
                'user-agent': 'Dart/3.1 (dart:io)'
            }
        });
        
        this.genres = ['action', 'adventure', 'comedy', 'demons', 'drama', 'ecchi', 'fantasy', 'game', 'harem', 'historical', 'horror', 'josei', 'magic', 'martial-arts', 'mecha', 'military', 'music', 'mystery', 'psychological', 'parody', 'police', 'romance', 'samurai', 'school', 'sci-fi', 'seinen', 'shoujo', 'shoujo-ai', 'shounen', 'slice-of-life', 'sports', 'space', 'super-power', 'supernatural', 'thriller', 'vampire', 'yaoi', 'yuri'];
        this.resolutions = ['320p', '480p', '720p', '1080p', '4K'];
    }
    
    async fetch(url) {
        const { data } = await this.client(url).catch(e => { throw new Error(e.message); });
        return data;
    }
    
    validate(val, list, label) {
        if (list && !list.includes(val)) throw new Error(`List available ${label}: ${list.join(', ')}.`);
        if (!list && isNaN(val)) throw new Error('Invalid page input.');
    }
    
    async newUploads(page = '1') {
        this.validate(page);
        
        return this.fetch(`/baruupload.php?page=${page}`);
    }
    
    async movieList() {
        return this.fetch('/movie.php');
    }
    
    async schedule() {
        return this.fetch('/jadwal.php');
    }
    
    async animeList() {
        return this.fetch('/anime-list.php');
    }
    
    async genre(genre, page = '1') {
        this.validate(genre, this.genres, 'genres');
        this.validate(page);
        
        return this.fetch(`/genreseries.php?url=${genre}/&page=${page}`);
    }
    
    async search(query) {
        if (!query) throw new Error('Query is required.');
        
        return this.fetch(`/search.php?keyword=${query}`);
    }
    
    async detail(url) {
        if (!url) throw new Error('Url is required.');
        
        return this.fetch(`/series.php?url=${url}`);
    }
    
    async episode(url, reso = '720p') {
        if (!url) throw new Error('Url is required.');
        this.validate(reso, this.resolutions, 'resolutions');
        
        return this.fetch(`/chapter.php?url=${url}&reso=${reso}`);
    }
}

// Usage:
const ani = new AnimeLovers();
ani.animeList().then(console.log);
2483 bytes ยท Updated Mar 10, 2026