mirror of
https://github.com/mjrode/WhatToWatch.git
synced 2026-05-08 05:29:09 -05:00
Endpoint for most watched and tests.
This commit is contained in:
@@ -4,5 +4,6 @@ import plexService from '../../../services/plexApi';
|
||||
const router = Router();
|
||||
|
||||
router.get('/users', plexService.getUsers);
|
||||
router.get('/most-watched', plexService.getMostWatched);
|
||||
|
||||
export default router;
|
||||
|
||||
@@ -6,6 +6,13 @@ const getUsers = async (req, res) => {
|
||||
res.json(users);
|
||||
};
|
||||
|
||||
const getMostWatched = async (req, res) => {
|
||||
const plexApi = plexApiClient();
|
||||
const mostWatched = await plexApi.getMostWatched(2);
|
||||
res.json(mostWatched);
|
||||
};
|
||||
|
||||
export default {
|
||||
getUsers,
|
||||
getMostWatched,
|
||||
};
|
||||
|
||||
@@ -90,9 +90,8 @@ PlexApiClient.prototype.getUsers = async function() {
|
||||
PlexApiClient.prototype.getMostWatched = async function(type, limit = 10) {
|
||||
const urlParams = this.mostWatchedUrlParams(type, limit);
|
||||
const mostWatchedUrl = this.buildUrl(urlParams);
|
||||
console.log(mostWatchedUrl);
|
||||
const response = await this.request(mostWatchedUrl);
|
||||
return response;
|
||||
return response.MediaContainer.Metadata;
|
||||
};
|
||||
|
||||
const plexApiClient = (options = []) => {
|
||||
|
||||
Reference in New Issue
Block a user