|
|
@ -3,7 +3,7 @@ const cheerio = require('cheerio');
|
|
|
|
const base64 = require('node-base64-image');
|
|
|
|
const base64 = require('node-base64-image');
|
|
|
|
|
|
|
|
|
|
|
|
const {
|
|
|
|
const {
|
|
|
|
BASE_ANIMEFLV, BASE_JIKAN, BASE_EPISODE_IMG_URL
|
|
|
|
BASE_ANIMEFLV, BASE_JIKAN, BASE_EPISODE_IMG_URL, SEARCH_URL
|
|
|
|
} = require('../api/urls');
|
|
|
|
} = require('../api/urls');
|
|
|
|
|
|
|
|
|
|
|
|
const animeflvInfo = async(id) =>{
|
|
|
|
const animeflvInfo = async(id) =>{
|
|
|
@ -239,15 +239,32 @@ const imageUrlToBase64 = async(url) => {
|
|
|
|
return await base64.encode(url, {string:true});
|
|
|
|
return await base64.encode(url, {string:true});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*const imageUrlToBase64 = async(url) => {
|
|
|
|
const search = async() =>{ }
|
|
|
|
let res = await cloudscraper({
|
|
|
|
|
|
|
|
url,
|
|
|
|
const searchAnime = async(query) => {
|
|
|
|
method: "GET",
|
|
|
|
|
|
|
|
encoding: null
|
|
|
|
const res = await cloudscraper(`${SEARCH_URL}${query}`);
|
|
|
|
});
|
|
|
|
const body = await res;
|
|
|
|
|
|
|
|
const $ = cheerio.load(body);
|
|
|
|
|
|
|
|
const promises = [];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$('div.Container ul.ListAnimes li article').each((index , element) =>{
|
|
|
|
|
|
|
|
const $element = $(element);
|
|
|
|
|
|
|
|
const id = $element.find('div.Description a.Button').attr('href').slice(1);
|
|
|
|
|
|
|
|
const title = $element.find('a h3').text();
|
|
|
|
|
|
|
|
let poster = $element.find('a div.Image figure img').attr('src') || $element.find('a div.Image figure img').attr('data-cfsrc');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
promises.push(search().then(async extra => ({
|
|
|
|
|
|
|
|
id: id || null,
|
|
|
|
|
|
|
|
title: title || null,
|
|
|
|
|
|
|
|
image: await imageUrlToBase64(poster) || null
|
|
|
|
|
|
|
|
})));
|
|
|
|
|
|
|
|
|
|
|
|
return Buffer.from(res).toString("base64");
|
|
|
|
})
|
|
|
|
};*/
|
|
|
|
|
|
|
|
|
|
|
|
return Promise.all(promises);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const MergeRecursive = (obj1 , obj2) => {
|
|
|
|
const MergeRecursive = (obj1 , obj2) => {
|
|
|
|
for(var p in obj2) {
|
|
|
|
for(var p in obj2) {
|
|
|
@ -282,6 +299,7 @@ module.exports = {
|
|
|
|
getAnimeVideoPromo,
|
|
|
|
getAnimeVideoPromo,
|
|
|
|
animeExtraInfo,
|
|
|
|
animeExtraInfo,
|
|
|
|
imageUrlToBase64,
|
|
|
|
imageUrlToBase64,
|
|
|
|
|
|
|
|
searchAnime,
|
|
|
|
MergeRecursive,
|
|
|
|
MergeRecursive,
|
|
|
|
urlify
|
|
|
|
urlify
|
|
|
|
}
|
|
|
|
}
|