mirror of https://github.com/aruppi/aruppi-api
Added Themes
This commit is contained in:
parent
e4697302d8
commit
2f6c29d2a0
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "aruppi",
|
"name": "aruppi",
|
||||||
"version": "1.0.0",
|
"version": "2.0.0",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "aruppi",
|
"name": "aruppi",
|
||||||
"version": "1.0.0",
|
"version": "2.0.0",
|
||||||
"description": "Aruppi is a custom API to obtain data from the Japanese culture for the mobile app",
|
"description": "Aruppi is a custom API to obtain data from the Japanese culture for the mobile app",
|
||||||
"main": "./src/api/api.js",
|
"main": "./src/api/api.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -49,8 +49,6 @@
|
||||||
"express": "^4.16.4",
|
"express": "^4.16.4",
|
||||||
"helmet": "^3.22.0",
|
"helmet": "^3.22.0",
|
||||||
"node-base64-image": "^2.0.1",
|
"node-base64-image": "^2.0.1",
|
||||||
"npm": "^6.14.5",
|
|
||||||
"request": "^2.88.0",
|
|
||||||
"rss-to-json": "^1.1.1"
|
"rss-to-json": "^1.1.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,11 +9,12 @@ const {
|
||||||
animeExtraInfo,
|
animeExtraInfo,
|
||||||
searchAnime,
|
searchAnime,
|
||||||
transformUrlServer,
|
transformUrlServer,
|
||||||
obtainPreviewNews
|
obtainPreviewNews,
|
||||||
|
structureThemes
|
||||||
} = require('../utils/index');
|
} = require('../utils/index');
|
||||||
|
|
||||||
const {
|
const {
|
||||||
BASE_ANIMEFLV, BASE_ANIMEFLV_JELU, BASE_JIKAN, BASE_IVOOX, BASE_QWANT, BASE_YOUTUBE
|
BASE_ANIMEFLV, BASE_ANIMEFLV_JELU, BASE_JIKAN, BASE_IVOOX, BASE_QWANT, BASE_YOUTUBE, BASE_THEMEMOE
|
||||||
} = require('./urls');
|
} = require('./urls');
|
||||||
|
|
||||||
const schedule = async (day) =>{
|
const schedule = async (day) =>{
|
||||||
|
@ -342,6 +343,39 @@ const getRadioStations = async () => {
|
||||||
return require('../assets/radiostations.json');
|
return require('../assets/radiostations.json');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getOpAndEd = async (title) => {
|
||||||
|
|
||||||
|
const data = await cloudscraper.get(`${BASE_THEMEMOE}anime/search/${title}`);
|
||||||
|
const body = JSON.parse(data);
|
||||||
|
|
||||||
|
return await structureThemes(body, true, 0)
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
const getThemesSeason = async (year, season) => {
|
||||||
|
|
||||||
|
let data
|
||||||
|
|
||||||
|
if (season === undefined) {
|
||||||
|
data = await cloudscraper.get(`${BASE_THEMEMOE}seasons/${year}`);
|
||||||
|
} else {
|
||||||
|
data = await cloudscraper.get(`${BASE_THEMEMOE}seasons/${year}/${season}`);
|
||||||
|
}
|
||||||
|
const body = JSON.parse(data);
|
||||||
|
|
||||||
|
return await structureThemes(body, false, 0)
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
const getRandomTheme = async () => {
|
||||||
|
|
||||||
|
const data = await cloudscraper.get(`${BASE_THEMEMOE}roulette`);
|
||||||
|
const body = JSON.parse(data);
|
||||||
|
|
||||||
|
return await structureThemes(body, true)
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
schedule,
|
schedule,
|
||||||
top,
|
top,
|
||||||
|
@ -356,5 +390,8 @@ module.exports = {
|
||||||
search,
|
search,
|
||||||
getImages,
|
getImages,
|
||||||
getYoutubeVideos,
|
getYoutubeVideos,
|
||||||
getRadioStations
|
getRadioStations,
|
||||||
|
getOpAndEd,
|
||||||
|
getThemesSeason,
|
||||||
|
getRandomTheme
|
||||||
};
|
};
|
||||||
|
|
|
@ -27,7 +27,10 @@ router.get('/', (req, res) => {
|
||||||
'Search': '/api/v2/search/:title',
|
'Search': '/api/v2/search/:title',
|
||||||
'Images': '/api/v2/images/:query',
|
'Images': '/api/v2/images/:query',
|
||||||
'Videos': '/api/v2/videos/:channelId',
|
'Videos': '/api/v2/videos/:channelId',
|
||||||
'Radios': '/api/v2/radio'
|
'Radios': '/api/v2/radio',
|
||||||
|
'Themes': '/api/v2/themes/:title',
|
||||||
|
'Season Themes': '/api/v2/themeSeason/:year/:season?',
|
||||||
|
'Random Theme': '/api/v2/randomTheme'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
@ -35,4 +38,4 @@ router.get('/', (req, res) => {
|
||||||
|
|
||||||
router.use('/', routes);
|
router.use('/', routes);
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|
|
@ -267,4 +267,48 @@ router.get('/radio' , (req, res) =>{
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
router.get('/themes/:title' , (req, res) =>{
|
||||||
|
|
||||||
|
let title = req.params.title;
|
||||||
|
|
||||||
|
api.getOpAndEd(title)
|
||||||
|
.then(themes =>{
|
||||||
|
res.status(200).json({
|
||||||
|
themes
|
||||||
|
});
|
||||||
|
}).catch((err) =>{
|
||||||
|
console.error(err);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
router.get('/themeSeason/:year/:season?', (req, res) =>{
|
||||||
|
|
||||||
|
let year = req.params.year;
|
||||||
|
let season = req.params.season
|
||||||
|
|
||||||
|
api.getThemesSeason(year, season)
|
||||||
|
.then(themes =>{
|
||||||
|
res.status(200).json({
|
||||||
|
themes
|
||||||
|
});
|
||||||
|
}).catch((err) =>{
|
||||||
|
console.error(err);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
router.get('/randomTheme', (req, res) =>{
|
||||||
|
|
||||||
|
api.getRandomTheme()
|
||||||
|
.then(random =>{
|
||||||
|
res.status(200).json({
|
||||||
|
random
|
||||||
|
});
|
||||||
|
}).catch((err) =>{
|
||||||
|
console.error(err);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|
|
@ -11,5 +11,6 @@ module.exports = {
|
||||||
BASE_CRUNCHYROLL: 'https://www.crunchyroll.com/newsrss?lang=esES',
|
BASE_CRUNCHYROLL: 'https://www.crunchyroll.com/newsrss?lang=esES',
|
||||||
SEARCH_URL: 'https://animeflv.net/browse?q=',
|
SEARCH_URL: 'https://animeflv.net/browse?q=',
|
||||||
BASE_EPISODE_IMG_URL: 'https://cdn.animeflv.net/screenshots/',
|
BASE_EPISODE_IMG_URL: 'https://cdn.animeflv.net/screenshots/',
|
||||||
BASE_QWANT: 'https://api.qwant.com/search/images?'
|
BASE_QWANT: 'https://api.qwant.com/search/images?',
|
||||||
|
BASE_THEMEMOE: 'https://themes.moe/api/'
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,6 +3,6 @@ const port = process.env.PORT || 5000;
|
||||||
|
|
||||||
app.listen(port, () => {
|
app.listen(port, () => {
|
||||||
/* eslint-disable no-console */
|
/* eslint-disable no-console */
|
||||||
console.log(`\n🚀 ... Listening: http://localhost:${port}`);
|
console.log(`\n🚀 ... Listening: http://localhost:${port}/api/v2`);
|
||||||
/* eslint-enable no-console */
|
/* eslint-enable no-console */
|
||||||
});
|
});
|
||||||
|
|
|
@ -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, SEARCH_URL, BASE_ARUPPI
|
BASE_ANIMEFLV, BASE_JIKAN, BASE_EPISODE_IMG_URL, SEARCH_URL, BASE_ARUPPI, BASE_THEMEMOE
|
||||||
} = require('../api/urls');
|
} = require('../api/urls');
|
||||||
|
|
||||||
const animeflvInfo = async (id, index) =>{
|
const animeflvInfo = async (id, index) =>{
|
||||||
|
@ -334,6 +334,72 @@ const obtainPreviewNews = (encoded) => {
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const structureThemes = async (body, indv, task) => {
|
||||||
|
|
||||||
|
const promises = []
|
||||||
|
let themes
|
||||||
|
let respFinal
|
||||||
|
|
||||||
|
if (task === 0) {
|
||||||
|
for(let i = 0; i <= body.length -1; i++) {
|
||||||
|
|
||||||
|
if (indv === true) {
|
||||||
|
const data = await cloudscraper.get(`${BASE_THEMEMOE}themes/${body[i]}`);
|
||||||
|
respFinal = JSON.parse(data)
|
||||||
|
themes = await getThemes(respFinal[0].themes)
|
||||||
|
} else {
|
||||||
|
respFinal = body
|
||||||
|
themes = await getThemes(body[0].themes)
|
||||||
|
}
|
||||||
|
|
||||||
|
respFinal.map(doc => {
|
||||||
|
|
||||||
|
promises.push({
|
||||||
|
title: doc.name,
|
||||||
|
season: doc.season,
|
||||||
|
year: doc.year,
|
||||||
|
themes: themes,
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
respFinal = body
|
||||||
|
themes = await getThemes(respFinal.themes)
|
||||||
|
|
||||||
|
promises.push({
|
||||||
|
title: respFinal.name,
|
||||||
|
season: respFinal.season,
|
||||||
|
year: respFinal.year,
|
||||||
|
themes: themes,
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return promises;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
const getThemes = async (themes) => {
|
||||||
|
|
||||||
|
let promises = []
|
||||||
|
|
||||||
|
themes.map(doc => {
|
||||||
|
|
||||||
|
promises.push({
|
||||||
|
name: doc.themeName,
|
||||||
|
type: doc.themeType,
|
||||||
|
video: doc.mirror.mirrorURL
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
return promises;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
animeflvInfo,
|
animeflvInfo,
|
||||||
getAnimeCharacters,
|
getAnimeCharacters,
|
||||||
|
@ -342,5 +408,7 @@ module.exports = {
|
||||||
imageUrlToBase64,
|
imageUrlToBase64,
|
||||||
searchAnime,
|
searchAnime,
|
||||||
transformUrlServer,
|
transformUrlServer,
|
||||||
obtainPreviewNews
|
obtainPreviewNews,
|
||||||
|
structureThemes,
|
||||||
|
getThemes
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue