hanime-crave
Version:
hanime.tv scraper
38 lines (33 loc) • 1.85 kB
JavaScript
const HentaiEpisode = require('../structures/episode.js');
module.exports = (seed = Math.floor(Math.random() * 9999999999999)) => {
return new Promise((res, rej) => {
if(isNaN(seed)) return rej(new Error("Seed has to be a number between 0 and [no idea what extent]"));
fetch(`https://hr.hanime.tv/api/v8/hentai_videos?source=randomize&r=${seed}`)
.then(resp => resp.json())
.then(json => {
let episodes = [];
for(let i = 0; i < json.hentai_videos.length; i++)
episodes[i] = new HentaiEpisode(json.hentai_videos[i].name,
json.hentai_videos[i].slug,
json.hentai_videos[i].created_at,
json.hentai_videos[i].created_at_unix,
json.hentai_videos[i].released_at,
json.hentai_videos[i].released_at_unix,
json.hentai_videos[i].views,
json.hentai_videos[i].interests,
json.hentai_videos[i].poster_url,
json.hentai_videos[i].cover_url,
json.hentai_videos[i].brand,
json.hentai_videos[i].is_censored,
json.hentai_videos[i].likes,
json.hentai_videos[i].dislikes,
json.hentai_videos[i].downloads,
json.hentai_videos[i].is_banned_in);
res({
info: {total: json.hentai_videos.length, seed: seed},
episodes: episodes
})
})
.catch(err => rej(err))
})
}