Adding the funcionality to the v2 with the new directory

pull/22/head
capitanwesler 5 years ago
parent 4165ef546e
commit 2f18461bf4

@ -81,7 +81,7 @@ const getAllDirectory = async (genres) => {
return !item.genres.includes("Ecchi") && !item.genres.includes("ecchi");
});
} else {
data = JSON.parse(JSON.stringify(require('../assets/directory.json')));
data = directoryAnimes;
}
return data.map(doc => ({

@ -19,11 +19,15 @@ const {
videoServersJK,
getAnimes,
getDirectory,
getThemes
getThemes,
directoryAnimes,
radioStations,
animeGenres,
animeThemes
} = require('../utils');
const ThemeParser = require('../utils/animetheme');
const parserThemes = new ThemeParser()
const parserThemes = new ThemeParser();
const {
BASE_ANIMEFLV_JELU, BASE_JIKAN, BASE_IVOOX, BASE_QWANT, BASE_YOUTUBE, GENRES_URL, BASE_THEMEMOE
@ -111,7 +115,7 @@ const getAnitakume = async () =>{
const getNews = async (pageRss) =>{
const promises = []
const promises = [];
for(let i = 0; i <= pageRss.length -1; i++) {
@ -242,10 +246,10 @@ const getMoreInfo = async (title) =>{
try {
const promises = []
const promises = [];
let data = JSON.parse(JSON.stringify(require('../../assets/directory.json')));
const res = data.filter(x => x.title === title || x.mal_title === title)[0];
let data = directoryAnimes;
const res = data.filter(x => x.title === title)[0];
if (!res.jkanime) {
promises.push({
@ -257,9 +261,9 @@ const getMoreInfo = async (title) =>{
rating: res.score || null,
genres: res.genres || null,
episodes: await animeflvInfo(res.id).then(episodes => episodes || null),
moreInfo: await animeExtraInfo(res.mal_title).then(info => info || null),
promo: await getAnimeVideoPromo(res.mal_title).then(promo => promo || null),
characters: await getAnimeCharacters(res.mal_title).then(characters => characters || null)
moreInfo: await animeExtraInfo(res.mal_id).then(info => info || null),
promo: await getAnimeVideoPromo(res.mal_id).then(promo => promo || null),
characters: await getAnimeCharacters(res.mal_id).then(characters => characters || null)
});
} else {
promises.push({
@ -271,9 +275,9 @@ const getMoreInfo = async (title) =>{
rating: res.score || null,
genres: res.genres || null,
episodes: await jkanimeInfo(res.id).then(episodes => episodes || null),
moreInfo: await animeExtraInfo(res.mal_title).then(info => info || null),
promo: await getAnimeVideoPromo(res.mal_title).then(promo => promo || null),
characters: await getAnimeCharacters(res.mal_title).then(characters => characters || null)
moreInfo: await animeExtraInfo(res.mal_id).then(info => info || null),
promo: await getAnimeVideoPromo(res.mal_id).then(promo => promo || null),
characters: await getAnimeCharacters(res.mal_id).then(characters => characters || null)
});
}
@ -343,7 +347,7 @@ const getYoutubeVideos = async (channelId) => {
};
const getRadioStations = async () => {
return require('../assets/radiostations.json');
return radioStations;
}
const getOpAndEd = async (title) => {
@ -432,7 +436,7 @@ const getAnimeGenres = async(genre, order, page) => {
};
const getAllThemes = async () => require('../../assets/themes.json');
const getAllThemes = async () => animeThemes;
module.exports = {
schedule,

@ -1,10 +1,13 @@
const {
BASE_ANIMEFLV, BASE_JIKAN, BASE_EPISODE_IMG_URL, BASE_ARUPPI, ANIMEFLV_SEARCH, BASE_JKANIME
} = require('../api/urls.js');
const {
homgot
} = require('../api/apiCall.js');
const directoryAnimes = JSON.parse(JSON.stringify(require('../../assets/directory.json')));
const radioStations = require('../../assets/radiostations.json');
const animeGenres = require('../../assets/genres.json');
const animeThemes = require('../../assets/themes.json');
function btoa(str) {
let buffer;
@ -194,13 +197,16 @@ const animeflvInfo = async (id) => {
};
const getAnimeCharacters = async(title) =>{
const matchAnime = await getMALid(title)
const getAnimeCharacters = async(mal_id) =>{
let data;
try {
if(matchAnime !== null) {
const data = await homgot(`${BASE_JIKAN}anime/${matchAnime.mal_id}/characters_staff`, { parse: true });
data = await homgot(`${BASE_JIKAN}anime/${mal_id}/characters_staff`, { parse: true });
}catch(error) {
console.log(error);
}
if(data !== null) {
return data.characters.map(doc => ({
id: doc.mal_id,
name: doc.name,
@ -208,40 +214,31 @@ const getAnimeCharacters = async(title) =>{
role: doc.role
}));
}
} catch (err) {
console.log(err)
}
};
const getAnimeVideoPromo = async(title) =>{
const matchAnime = await getMALid(title)
const getAnimeVideoPromo = async(mal_id) =>{
let data;
try {
if(matchAnime !== null) {
const data = await homgot(`${BASE_JIKAN}anime/${matchAnime.mal_id}/videos`, {parse: true})
data = await homgot(`${BASE_JIKAN}anime/${mal_id}/videos`, {parse: true});
}catch(error) {
console.log(error);
}
if(data !== null) {
return data.promo.map(doc => ({
title: doc.title,
previewImage: doc.image_url,
videoURL: doc.video_url
}));
}
} catch (err) {
console.log(err)
}
};
const animeExtraInfo = async (title) => {
const matchAnime = await getMALid(title)
const animeExtraInfo = async (mal_id) => {
const data = await homgot(`${BASE_JIKAN}anime/${mal_id}`, {parse: true});
try {
if(matchAnime !== null) {
const data = await homgot(`${BASE_JIKAN}anime/${matchAnime.mal_id}`, {parse: true})
if(data !== null) {
const promises = [];
let broadcast = ''
@ -298,19 +295,6 @@ const animeExtraInfo = async (title) => {
};
const getMALid = async(title) =>{
const res = await homgot(`${BASE_JIKAN}search/anime?q=${title}`,{ parse: true })
const matchAnime = res.results.find(x => x.title === title);
if(typeof matchAnime === 'undefined') {
return null;
} else {
return matchAnime;
}
};
const imageUrlToBase64 = async (url) => {
let img = await homgot(url)
return img.rawBody.toString('base64');
@ -491,11 +475,11 @@ const getDirectory = async (genres) => {
let data
if (genres === "sfw") {
data = JSON.parse(JSON.stringify(require('../../assets/directory.json'))).filter(function (item) {
data = directoryAnimes.filter(function (item) {
return !item.genres.includes("Ecchi") && !item.genres.includes("ecchi");
})
} else {
data = JSON.parse(JSON.stringify(require('../../assets/directory.json')));
data = directoryAnimes;
}
return data.map(doc => ({
@ -520,7 +504,6 @@ module.exports = {
getAnimeCharacters,
getAnimeVideoPromo,
animeExtraInfo,
getMALid,
imageUrlToBase64,
searchAnime,
transformUrlServer,
@ -529,5 +512,9 @@ module.exports = {
getThemes,
getAnimes,
getDirectory,
videoServersJK
videoServersJK,
directoryAnimes,
radioStations,
animeGenres,
animeThemes
}

Loading…
Cancel
Save