Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
jeluchu committed Feb 2, 2021
2 parents 1746c96 + 18724d7 commit 8bdd642
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 72 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# **Aruppi API** (v3.4.0)
# **Aruppi API** (v3.4.1)

> This API has everything about Japan, from anime, music, radio, images, videos ... to japanese culture
>
Expand Down Expand Up @@ -73,7 +73,7 @@ But if you need to see the code or the operation of the old version you can do i

Aruppi has grown since it was launched and we need to continue improving the application along with the services to be able to give new features.

At this time version 2.6.8 will remain functional until Aruppi App users fully migrate to version 1.5.0 of the app
At this time version 2.6.9 will remain functional until Aruppi App users fully migrate to version 1.5.0 of the app

## **:handshake: Contributing**

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aruppi",
"version": "3.4.0",
"version": "3.4.1",
"description": "Aruppi is a custom API to obtain data from the Japanese culture for the mobile app",
"main": "./src/api/api.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/api/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => ({
Expand Down
32 changes: 18 additions & 14 deletions src/v2/api/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -111,7 +115,7 @@ const getAnitakume = async () =>{

const getNews = async (pageRss) =>{

const promises = []
const promises = [];

for(let i = 0; i <= pageRss.length -1; i++) {

Expand Down Expand Up @@ -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({
Expand All @@ -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({
Expand All @@ -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)
});
}

Expand Down Expand Up @@ -343,7 +347,7 @@ const getYoutubeVideos = async (channelId) => {
};

const getRadioStations = async () => {
return require('../assets/radiostations.json');
return radioStations;
}

const getOpAndEd = async (title) => {
Expand Down Expand Up @@ -432,7 +436,7 @@ const getAnimeGenres = async(genre, order, page) => {

};

const getAllThemes = async () => require('../../assets/themes.json');
const getAllThemes = async () => animeThemes;

module.exports = {
schedule,
Expand Down
2 changes: 1 addition & 1 deletion src/v2/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ router.get('/', (req, res) => {
res.json({
message: 'Aruppi API - 🎏',
author: 'Jéluchu',
version: '2.6.8',
version: '2.6.9',
credits: 'The bitch loves APIs that offers data to Aruppi App',
deprecated: 'This version will be available until users migrate to Aruppi App v1.5.0',
entries: [
Expand Down
91 changes: 39 additions & 52 deletions src/v2/utils/index.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -194,54 +197,48 @@ 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 });
return data.characters.map(doc => ({
id: doc.mal_id,
name: doc.name,
image: doc.image_url,
role: doc.role
}));
}
} catch (err) {
console.log(err)
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,
image: doc.image_url,
role: doc.role
}));
}
};

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})
return data.promo.map(doc => ({
title: doc.title,
previewImage: doc.image_url,
videoURL: doc.video_url
}));
}
} catch (err) {
console.log(err)
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
}));
}
};

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 = ''

Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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 => ({
Expand All @@ -520,7 +504,6 @@ module.exports = {
getAnimeCharacters,
getAnimeVideoPromo,
animeExtraInfo,
getMALid,
imageUrlToBase64,
searchAnime,
transformUrlServer,
Expand All @@ -529,5 +512,9 @@ module.exports = {
getThemes,
getAnimes,
getDirectory,
videoServersJK
videoServersJK,
directoryAnimes,
radioStations,
animeGenres,
animeThemes
}

0 comments on commit 8bdd642

Please sign in to comment.