mirror of
https://github.com/mjrode/WhatToWatch.git
synced 2025-12-30 18:19:46 -06:00
Gsub show title info inside of parenthesis since it will typicall lead to failed poster requests
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
import { Router } from 'express';
|
||||
import models from '../db/models'
|
||||
import models from '../db/models';
|
||||
const router = Router();
|
||||
|
||||
router.get('/users', async (req, res) => {
|
||||
const users = await models.User.findAll()
|
||||
const users = await models.User.findAll();
|
||||
const filteredUsers = users.filter(user => user.plexToken);
|
||||
|
||||
res.send(users);
|
||||
res.send(filteredUsers);
|
||||
});
|
||||
|
||||
router.get('/login-as-user', async (req, res) => {
|
||||
|
||||
res.send(users);
|
||||
});
|
||||
|
||||
|
||||
@@ -64,9 +64,9 @@ const request = async function(url) {
|
||||
if (error.response) {
|
||||
logger.error(`Error: Status --, ${error.response.status}`);
|
||||
logger.error(
|
||||
`Error: Headers --, ${error.response.headers}`,
|
||||
`Error: URL --, ${inspect(error.request.path)}`,
|
||||
);
|
||||
logger.error(`Error: Response --, ${error.response}`);
|
||||
logger.error(`Error: Response --, ${error.response.data}`);
|
||||
return reject(error.response);
|
||||
}
|
||||
if (error.request) {
|
||||
|
||||
@@ -3,6 +3,7 @@ import plexApi from './plexApi';
|
||||
import models from '../../db/models';
|
||||
import config from '../../../config';
|
||||
import MovieDb from 'moviedb-promise';
|
||||
import logger from '../../../config/winston';
|
||||
import { Op } from 'sequelize';
|
||||
const mdb = new MovieDb(config.server.movieApiKey);
|
||||
|
||||
@@ -37,7 +38,10 @@ const importTvPosters = async user => {
|
||||
});
|
||||
|
||||
const imageUrls = await mostWatched.map(async show => {
|
||||
const res = await mdb.searchTv({ query: show.title });
|
||||
const res = await mdb.searchTv({
|
||||
query: show.title.replace(/ *\([^)]*\) */g, ''),
|
||||
});
|
||||
logger.info(`Poster response ${show.title} ${res.results}`);
|
||||
return models.PlexLibrary.update(
|
||||
{
|
||||
poster_path: res.results[0].poster_path,
|
||||
@@ -75,7 +79,7 @@ const createSections = async (sections, user) => {
|
||||
newSection,
|
||||
);
|
||||
}).catch(err => {
|
||||
console.log('create section error', err);
|
||||
logger.error(`createSections ${err}`);
|
||||
});
|
||||
return updatedSections;
|
||||
};
|
||||
@@ -85,7 +89,7 @@ const importLibraries = async user => {
|
||||
const dbSections = await createSections(sections, user);
|
||||
return Promise.map(sections, section => {
|
||||
return importLibrary(section.key, user);
|
||||
}).catch(err => console.log('ImportLibraries', err));
|
||||
}).catch(err => logger.error(`ImportLibraries ${err}`));
|
||||
};
|
||||
|
||||
const importLibrary = async (sectionKey, user) => {
|
||||
|
||||
@@ -12,7 +12,7 @@ const getPlexPin = async (req, res) => {
|
||||
const plexPinId = pinRes.pin.id['$t'];
|
||||
await models.User.update(
|
||||
{ plexPinId },
|
||||
{ where: { googleId: req.user.email } },
|
||||
{ where: { email: req.user.email } },
|
||||
);
|
||||
const pinCode = pinRes.pin.code;
|
||||
return res.json(pinCode);
|
||||
@@ -58,7 +58,7 @@ const getMostWatched = async (req, res) => {
|
||||
);
|
||||
res.json(mostWatched);
|
||||
} catch (error) {
|
||||
console.log('mike', error);
|
||||
logger.info(`getMostWatched ${error.stack}`);
|
||||
res.json(error);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user