Skip to content

Commit

Permalink
Include updates for security dependant bots
Browse files Browse the repository at this point in the history
  • Loading branch information
jeluchu committed Oct 10, 2021
1 parent dafe022 commit 9ba3e10
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 22 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# **Aruppi API** (v4.1.2)
# **Aruppi API** (v4.1.3)

> This API has everything about Japan, from anime, music, radio, images, videos ... to japanese culture
>
Expand Down
28 changes: 14 additions & 14 deletions 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": "4.1.2",
"version": "4.1.3",
"description": "Aruppi is a custom API to obtain data from the Japanese culture for the mobile app",
"main": "./src/api/api.ts",
"scripts": {
Expand Down
59 changes: 59 additions & 0 deletions src/controllers/UtilsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,65 @@ export default class UtilsController {
}
}

async getPlaylists(req: Request, res: Response, next: NextFunction) {

const { playlistId } = req.params;
let data: any;

try {
if (redisClient.connected) {

const resultQueryRedis: any = redisClient.get(
`playlist_videos_${hashStringMd5(playlistId)}`,
);

if (resultQueryRedis) {
const resultRedis: any = JSON.parse(resultQueryRedis);
return res.status(200).json(resultRedis);
}
}

data = await requestGot(
`${urls.BASE_YOUTUBE_PLAYLIST}${playlistId}`,
{ scrapy: false, parse: true },
);
} catch (err) {
return next(err);
}

const results: any[] = data.items.map((item: any) => {
return {
title: item.snippet.title,
videoId: item.id.videoId,
thumbDefault: item.snippet.thumbnails.default.url,
thumbMedium: item.snippet.thumbnails.medium.url,
thumbHigh: item.snippet.thumbnails.high.url,
};
});

if (results.length > 0) {
if (redisClient.connected) {
/!* Set the key in the redis cache. *!/

redisClient.set(
`playlist_videos_${hashStringMd5(playlistId)}`,
JSON.stringify({ videos: results }),
);

/!* After 24hrs expire the key. *!/

redisClient.expireat(
`playlist_videos_${hashStringMd5(playlistId)}`,
parseInt(`${+new Date() / 1000}`, 10) + 7200,
);
}

res.status(200).json({ videos: results });
} else {
res.status(500).json({ message: 'Aruppi lost in the shell' });
}
}

async getSectionVideos(req: Request, res: Response, next: NextFunction) {
const { type } = req.params;
let y1: any, y2: any, y3: any;
Expand Down
2 changes: 2 additions & 0 deletions src/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ routes.get('/api/v4/', (req: Request, res: Response) => {
Search: '/api/v4/search/:title',
Images: '/api/v4/images/:query',
Videos: '/api/v4/videos/:channelId',
Playlist: '/api/v4/playlistVideos/:playlistId',
'Type Videos': '/api/v4/sectionedVideos/:type',
Radios: '/api/v4/radio',
'All Themes': '/api/v4/allThemes',
Expand Down Expand Up @@ -104,6 +105,7 @@ routes.get('/api/v4/anitakume', utilsController.getAnitakume);
routes.get('/api/v4/news', utilsController.getNews);
routes.get('/api/v4/images/:title', utilsController.getImages);
routes.get('/api/v4/videos/:channelId', utilsController.getVideos);
routes.get('/api/v4/playlistVideos/:playlistId', utilsController.getPlaylists);
routes.get('/api/v4/sectionedVideos/:type', utilsController.getSectionVideos);
routes.get('/api/v4/radio', utilsController.getRadioStations);
routes.get('/api/v4/allThemes', utilsController.getAllThemes);
Expand Down
1 change: 1 addition & 0 deletions src/utils/urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export default {
BASE_JKANIME: 'https://jkanime.net/',
BASE_ANIMEFLV_JELU: 'https://aruppi.jeluchu.xyz/apis/animeflv/v1/',
BASE_YOUTUBE: 'https://aruppi.jeluchu.xyz/api/Youtube/?channelId=',
BASE_YOUTUBE_PLAYLIST: 'https://aruppi.jeluchu.xyz/api/Youtube/playlist/?playlistId=',
BASE_JIKAN: 'https://aruppi.jeluchu.xyz/apis/jikan/v3/',
BASE_IVOOX:
'https://www.ivoox.com/podcast-anitakume_fg_f1660716_filtro_1.xml',
Expand Down
12 changes: 6 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -353,9 +353,9 @@
"version" "4.1.1"

"ansi-regex@^5.0.0":
"integrity" "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg=="
"resolved" "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz"
"version" "5.0.0"
"integrity" "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ=="
"resolved" "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz"
"version" "5.0.1"

"ansi-styles@^3.2.1":
"integrity" "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA=="
Expand Down Expand Up @@ -1900,9 +1900,9 @@
"version" "6.1.0"

"nth-check@^2.0.0":
"integrity" "sha512-i4sc/Kj8htBrAiH1viZ0TgU8Y5XqCaV/FziYK6TBczxmeKm3AEFWqqF3195yKudrarqy7Zu80Ra5dobFjn9X/Q=="
"resolved" "https://registry.npmjs.org/nth-check/-/nth-check-2.0.0.tgz"
"version" "2.0.0"
"integrity" "sha512-it1vE95zF6dTT9lBsYbxvqh0Soy4SPowchj0UBGj/V6cTPnXXtQOPUbhZ6CmGzAD/rW22LQK6E96pcdJXk4A4w=="
"resolved" "https://registry.npmjs.org/nth-check/-/nth-check-2.0.1.tgz"
"version" "2.0.1"
dependencies:
"boolbase" "^1.0.0"

Expand Down

0 comments on commit 9ba3e10

Please sign in to comment.