Add Thumb news photos

pull/1/head
Jéluchu 5 years ago
parent 9350a37f3d
commit 49c2ead964

@ -8,7 +8,8 @@ const {
getAnimeVideoPromo,
animeExtraInfo,
searchAnime,
transformUrlServer
transformUrlServer,
obtainPreviewNews
} = require('../utils/index');
const {
@ -109,6 +110,7 @@ const getNews = async (pageRss) =>{
title: doc.title,
url: doc.link,
author: pageRss[i].author,
thumbnail: obtainPreviewNews(doc[pageRss[i].content]),
content: doc[pageRss[i].content]
});

@ -26,7 +26,8 @@ router.get('/', (req, res) => {
'GetAnimeServers': '/api/v2/getAnimeServers/:id',
'Search': '/api/v2/search/:title',
'Images': '/api/v2/images/:query',
'Videos': '/api/v2/videos/:channelId'
'Videos': '/api/v2/videos/:channelId',
'Radios': '/api/v2/radio'
}
]
});

@ -1,4 +1,5 @@
module.exports = {
BASE_ARUPPI: 'https://aruppi.jeluchu.xyz/',
BASE_ANIMEFLV: 'https://animeflv.net/',
BASE_ANIMEFLV_JELU: 'https://aruppi.jeluchu.xyz/apis/animeflv/v1/',
BASE_YOUTUBE: 'https://aruppi.jeluchu.xyz/apis/youtube/v3/search?channelId=',
@ -11,4 +12,4 @@ module.exports = {
SEARCH_URL: 'https://animeflv.net/browse?q=',
BASE_EPISODE_IMG_URL: 'https://cdn.animeflv.net/screenshots/',
BASE_QWANT: 'https://api.qwant.com/search/images?'
};
};

@ -306,6 +306,34 @@ const transformUrlServer = async(urlReal) =>{
return promises;
}
const obtainPreviewNews = (encoded) => {
let image;
if (encoded.includes('<img src=')) {
image = encoded
.substring(encoded.indexOf("<img src=\""), encoded.indexOf("\" alt"))
.substring(10).replace("http", "https")
.replace("httpss", "https")
} else if (encoded.includes('<img')) {
image = encoded.split("src=")[1].split(" class=")[0].replace("\"", "")
} else if (encoded.includes('https://www.youtube.com/embed/')) {
let getSecondThumb = encoded.split('https://www.youtube.com/embed/')[1].split('?feature')[0]
image = `https://img.youtube.com/vi/${getSecondThumb}/0.jpg`
} else if (encoded.includes('https://www.dailymotion.com/')) {
let getDailymotionThumb = encoded
.substring(encoded.indexOf("\" src=\""), encoded.indexOf("\" a"))
.substring(47)
image = `https://www.dailymotion.com/thumbnail/video/${getDailymotionThumb}`
} else {
let number = Math.floor(Math.random() * 30);
image = `${BASE_ARUPPI}news/${number}.png`
}
return image;
}
module.exports = {
animeflvInfo,
getAnimeCharacters,
@ -313,5 +341,6 @@ module.exports = {
animeExtraInfo,
imageUrlToBase64,
searchAnime,
transformUrlServer
}
transformUrlServer,
obtainPreviewNews
}

Loading…
Cancel
Save