fix: address unhandled promise rejections & bump node to v16.13 (#2398)

* fix: unhandled promise rejections

* build(deps): bump node from 14.18 to 16.13

* fix: unhandled promise rejection in new Plex users endpoint

* fix: build error

Co-authored-by: Ryan Cohen <ryan@sct.dev>
pull/2463/head
TheCatLady 3 years ago committed by GitHub
parent ca184728e9
commit 8cba486249
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -12,7 +12,7 @@ jobs:
test:
name: Lint & Test Build
runs-on: ubuntu-20.04
container: node:14.18-alpine
container: node:16.13-alpine
steps:
- name: Checkout
uses: actions/checkout@v2.4.0

@ -9,7 +9,7 @@ jobs:
test:
name: Lint & Test Build
runs-on: ubuntu-20.04
container: node:14.18-alpine
container: node:16.13-alpine
steps:
- name: Checkout
uses: actions/checkout@v2.4.0

@ -20,7 +20,7 @@ jobs:
name: Lint & Test Build
needs: jobs
runs-on: ubuntu-20.04
container: node:14.18-alpine
container: node:16.13-alpine
steps:
- name: Checkout
uses: actions/checkout@v2.4.0

@ -1,4 +1,4 @@
FROM node:14.18-alpine AS BUILD_IMAGE
FROM node:16.13-alpine AS BUILD_IMAGE
WORKDIR /app
@ -33,7 +33,7 @@ RUN touch config/DOCKER
RUN echo "{\"commitTag\": \"${COMMIT_TAG}\"}" > committag.json
FROM node:14.18-alpine
FROM node:16.13-alpine
WORKDIR /app

@ -1,4 +1,4 @@
FROM node:14.18-alpine
FROM node:16.13-alpine
COPY . /app
WORKDIR /app

@ -1,7 +1,7 @@
import logger from '../../logger';
import ServarrBase from './base';
interface RadarrMovieOptions {
export interface RadarrMovieOptions {
title: string;
qualityProfileId: number;
minimumAvailability: string;

@ -63,7 +63,7 @@ export interface SonarrSeries {
};
}
interface AddSeriesOptions {
export interface AddSeriesOptions {
tvdbid: number;
title: string;
profileId: number;

@ -13,8 +13,11 @@ import {
RelationCount,
UpdateDateColumn,
} from 'typeorm';
import RadarrAPI from '../api/servarr/radarr';
import SonarrAPI, { SonarrSeries } from '../api/servarr/sonarr';
import RadarrAPI, { RadarrMovieOptions } from '../api/servarr/radarr';
import SonarrAPI, {
AddSeriesOptions,
SonarrSeries,
} from '../api/servarr/sonarr';
import TheMovieDb from '../api/themoviedb';
import { ANIME_KEYWORD_ID } from '../api/themoviedb/constants';
import { MediaRequestStatus, MediaStatus, MediaType } from '../constants/media';
@ -135,55 +138,15 @@ export class MediaRequest {
where: { id: this.media.id },
});
if (!media) {
logger.error('No parent media!', { label: 'Media Request' });
return;
}
const tmdb = new TheMovieDb();
if (this.type === MediaType.MOVIE) {
const movie = await tmdb.getMovie({ movieId: media.tmdbId });
notificationManager.sendNotification(Notification.MEDIA_PENDING, {
event: `New ${this.is4k ? '4K ' : ''}Movie Request`,
subject: `${movie.title}${
movie.release_date ? ` (${movie.release_date.slice(0, 4)})` : ''
}`,
message: truncate(movie.overview, {
length: 500,
separator: /\s/,
omission: '…',
}),
image: `https://image.tmdb.org/t/p/w600_and_h900_bestv2${movie.poster_path}`,
media,
request: this,
notifyAdmin: true,
logger.error('Media data not found', {
label: 'Media Request',
requestId: this.id,
mediaId: this.media.id,
});
return;
}
if (this.type === MediaType.TV) {
const tv = await tmdb.getTvShow({ tvId: media.tmdbId });
notificationManager.sendNotification(Notification.MEDIA_PENDING, {
event: `New ${this.is4k ? '4K ' : ''}Series Request`,
subject: `${tv.name}${
tv.first_air_date ? ` (${tv.first_air_date.slice(0, 4)})` : ''
}`,
message: truncate(tv.overview, {
length: 500,
separator: /\s/,
omission: '…',
}),
image: `https://image.tmdb.org/t/p/w600_and_h900_bestv2${tv.poster_path}`,
media,
extra: [
{
name: 'Requested Seasons',
value: this.seasons
.map((season) => season.seasonNumber)
.join(', '),
},
],
request: this,
notifyAdmin: true,
});
}
this.sendNotification(media, Notification.MEDIA_PENDING);
}
}
@ -204,92 +167,32 @@ export class MediaRequest {
where: { id: this.media.id },
});
if (!media) {
logger.error('No parent media!', { label: 'Media Request' });
logger.error('Media data not found', {
label: 'Media Request',
requestId: this.id,
mediaId: this.media.id,
});
return;
}
if (media[this.is4k ? 'status4k' : 'status'] === MediaStatus.AVAILABLE) {
logger.warn(
'Media became available before request was approved. Approval notification will be skipped.',
{ label: 'Media Request' }
'Media became available before request was approved. Skipping approval notification',
{ label: 'Media Request', requestId: this.id, mediaId: this.media.id }
);
return;
}
const tmdb = new TheMovieDb();
if (this.media.mediaType === MediaType.MOVIE) {
const movie = await tmdb.getMovie({ movieId: this.media.tmdbId });
notificationManager.sendNotification(
this.status === MediaRequestStatus.APPROVED
? autoApproved
? Notification.MEDIA_AUTO_APPROVED
: Notification.MEDIA_APPROVED
: Notification.MEDIA_DECLINED,
{
event: `${this.is4k ? '4K ' : ''}Movie Request ${
this.status === MediaRequestStatus.APPROVED
? autoApproved
? 'Automatically Approved'
: 'Approved'
: 'Declined'
}`,
subject: `${movie.title}${
movie.release_date ? ` (${movie.release_date.slice(0, 4)})` : ''
}`,
message: truncate(movie.overview, {
length: 500,
separator: /\s/,
omission: '…',
}),
image: `https://image.tmdb.org/t/p/w600_and_h900_bestv2${movie.poster_path}`,
notifyAdmin: autoApproved,
notifyUser: autoApproved ? undefined : this.requestedBy,
this.sendNotification(
media,
request: this,
}
);
} else if (this.media.mediaType === MediaType.TV) {
const tv = await tmdb.getTvShow({ tvId: this.media.tmdbId });
notificationManager.sendNotification(
this.status === MediaRequestStatus.APPROVED
? autoApproved
? Notification.MEDIA_AUTO_APPROVED
: Notification.MEDIA_APPROVED
: Notification.MEDIA_DECLINED,
{
event: `${this.is4k ? '4K ' : ''}Series Request ${
this.status === MediaRequestStatus.APPROVED
? autoApproved
? 'Automatically Approved'
: 'Approved'
: 'Declined'
}`,
subject: `${tv.name}${
tv.first_air_date ? ` (${tv.first_air_date.slice(0, 4)})` : ''
}`,
message: truncate(tv.overview, {
length: 500,
separator: /\s/,
omission: '…',
}),
image: `https://image.tmdb.org/t/p/w600_and_h900_bestv2${tv.poster_path}`,
notifyAdmin: autoApproved,
notifyUser: autoApproved ? undefined : this.requestedBy,
media,
extra: [
{
name: 'Requested Seasons',
value: this.seasons
.map((season) => season.seasonNumber)
.join(', '),
},
],
request: this,
}
: Notification.MEDIA_DECLINED
);
}
}
}
@AfterInsert()
public async autoapprovalNotification(): Promise<void> {
@ -307,7 +210,11 @@ export class MediaRequest {
relations: ['requests'],
});
if (!media) {
logger.error('No parent media!', { label: 'Media Request' });
logger.error('Media data not found', {
label: 'Media Request',
requestId: this.id,
mediaId: this.media.id,
});
return;
}
const seasonRequestRepository = getRepository(SeasonRequest);
@ -395,8 +302,12 @@ export class MediaRequest {
const settings = getSettings();
if (settings.radarr.length === 0 && !settings.radarr[0]) {
logger.info(
'Skipped Radarr request as there is no Radarr server configured',
{ label: 'Media Request' }
'No Radarr server configured, skipping request processing',
{
label: 'Media Request',
requestId: this.id,
mediaId: this.media.id,
}
);
return;
}
@ -415,18 +326,26 @@ export class MediaRequest {
);
logger.info(
`Request has an override server: ${radarrSettings?.name}`,
{ label: 'Media Request' }
{
label: 'Media Request',
requestId: this.id,
mediaId: this.media.id,
}
);
}
if (!radarrSettings) {
logger.info(
logger.warn(
`There is no default ${
this.is4k ? '4K ' : ''
}Radarr server configured. Did you set any of your ${
this.is4k ? '4K ' : ''
}Radarr servers as default?`,
{ label: 'Media Request' }
{
label: 'Media Request',
requestId: this.id,
mediaId: this.media.id,
}
);
return;
}
@ -443,6 +362,8 @@ export class MediaRequest {
rootFolder = this.rootFolder;
logger.info(`Request has an override root folder: ${rootFolder}`, {
label: 'Media Request',
requestId: this.id,
mediaId: this.media.id,
});
}
@ -451,15 +372,22 @@ export class MediaRequest {
this.profileId !== radarrSettings.activeProfileId
) {
qualityProfile = this.profileId;
logger.info(`Request has an override profile id: ${qualityProfile}`, {
logger.info(
`Request has an override quality profile ID: ${qualityProfile}`,
{
label: 'Media Request',
});
requestId: this.id,
mediaId: this.media.id,
}
);
}
if (this.tags && !isEqual(this.tags, radarrSettings.tags)) {
tags = this.tags;
logger.info(`Request has override tags`, {
label: 'Media Request',
requestId: this.id,
mediaId: this.media.id,
tagIds: tags,
});
}
@ -476,7 +404,11 @@ export class MediaRequest {
});
if (!media) {
logger.error('Media not present');
logger.error('Media data not found', {
label: 'Media Request',
requestId: this.id,
mediaId: this.media.id,
});
return;
}
@ -486,9 +418,7 @@ export class MediaRequest {
throw new Error('Media already available');
}
// Run this asynchronously so we don't wait for it on the UI side
radarr
.addMovie({
const radarrMovieOptions: RadarrMovieOptions = {
profileId: qualityProfile,
qualityProfileId: qualityProfile,
rootFolderPath: rootFolder,
@ -499,7 +429,11 @@ export class MediaRequest {
monitored: true,
tags,
searchNow: !radarrSettings.preventSearch,
})
};
// Run this asynchronously so we don't wait for it on the UI side
radarr
.addMovie(radarrMovieOptions)
.then(async (radarrMovie) => {
// We grab media again here to make sure we have the latest version of it
const media = await mediaRepository.findOne({
@ -507,7 +441,7 @@ export class MediaRequest {
});
if (!media) {
throw new Error('Media data is missing');
throw new Error('Media data not found');
}
media[this.is4k ? 'externalServiceId4k' : 'externalServiceId'] =
@ -521,36 +455,30 @@ export class MediaRequest {
media[this.is4k ? 'status4k' : 'status'] = MediaStatus.UNKNOWN;
await mediaRepository.save(media);
logger.warn(
'Newly added movie request failed to add to Radarr, marking as unknown',
'Something went wrong sending movie request to Radarr, marking status as UNKNOWN',
{
label: 'Media Request',
requestId: this.id,
mediaId: this.media.id,
radarrMovieOptions,
}
);
notificationManager.sendNotification(Notification.MEDIA_FAILED, {
event: `${this.is4k ? '4K ' : ''}Movie Request Failed`,
subject: `${movie.title}${
movie.release_date ? ` (${movie.release_date.slice(0, 4)})` : ''
}`,
message: truncate(movie.overview, {
length: 500,
separator: /\s/,
omission: '…',
}),
media,
image: `https://image.tmdb.org/t/p/w600_and_h900_bestv2${movie.poster_path}`,
request: this,
notifyAdmin: true,
this.sendNotification(media, Notification.MEDIA_FAILED);
});
logger.info('Sent request to Radarr', {
label: 'Media Request',
requestId: this.id,
mediaId: this.media.id,
});
logger.info('Sent request to Radarr', { label: 'Media Request' });
} catch (e) {
const errorMessage = `Request failed to send to Radarr: ${e.message}`;
logger.error('Request failed to send to Radarr', {
logger.error('Something went wrong sending request to Radarr', {
label: 'Media Request',
errorMessage,
errorMessage: e.message,
requestId: this.id,
mediaId: this.media.id,
});
throw new Error(errorMessage);
throw new Error(e.message);
}
}
}
@ -564,9 +492,13 @@ export class MediaRequest {
const mediaRepository = getRepository(Media);
const settings = getSettings();
if (settings.sonarr.length === 0 && !settings.sonarr[0]) {
logger.info(
'Skipped Sonarr request as there is no Sonarr server configured',
{ label: 'Media Request' }
logger.warn(
'No Sonarr server configured, skipping request processing',
{
label: 'Media Request',
requestId: this.id,
mediaId: this.media.id,
}
);
return;
}
@ -585,18 +517,26 @@ export class MediaRequest {
);
logger.info(
`Request has an override server: ${sonarrSettings?.name}`,
{ label: 'Media Request' }
{
label: 'Media Request',
requestId: this.id,
mediaId: this.media.id,
}
);
}
if (!sonarrSettings) {
logger.info(
logger.warn(
`There is no default ${
this.is4k ? '4K ' : ''
}Sonarr server configured. Did you set any of your ${
this.is4k ? '4K ' : ''
}Sonarr servers as default?`,
{ label: 'Media Request' }
{
label: 'Media Request',
requestId: this.id,
mediaId: this.media.id,
}
);
return;
}
@ -607,7 +547,7 @@ export class MediaRequest {
});
if (!media) {
throw new Error('Media data is missing');
throw new Error('Media data not found');
}
if (
@ -628,7 +568,7 @@ export class MediaRequest {
const requestRepository = getRepository(MediaRequest);
await mediaRepository.remove(media);
await requestRepository.remove(this);
throw new Error('Series was missing tvdb id');
throw new Error('TVDB ID not found');
}
let seriesType: SonarrSeries['seriesType'] = 'standard';
@ -650,12 +590,10 @@ export class MediaRequest {
seriesType === 'anime' && sonarrSettings.activeAnimeProfileId
? sonarrSettings.activeAnimeProfileId
: sonarrSettings.activeProfileId;
let languageProfile =
seriesType === 'anime' && sonarrSettings.activeAnimeLanguageProfileId
? sonarrSettings.activeAnimeLanguageProfileId
: sonarrSettings.activeLanguageProfileId;
let tags =
seriesType === 'anime'
? sonarrSettings.animeTags
@ -669,14 +607,21 @@ export class MediaRequest {
rootFolder = this.rootFolder;
logger.info(`Request has an override root folder: ${rootFolder}`, {
label: 'Media Request',
requestId: this.id,
mediaId: this.media.id,
});
}
if (this.profileId && this.profileId !== qualityProfile) {
qualityProfile = this.profileId;
logger.info(`Request has an override profile ID: ${qualityProfile}`, {
logger.info(
`Request has an override quality profile ID: ${qualityProfile}`,
{
label: 'Media Request',
});
requestId: this.id,
mediaId: this.media.id,
}
);
}
if (
@ -685,9 +630,11 @@ export class MediaRequest {
) {
languageProfile = this.languageProfileId;
logger.info(
`Request has an override Language Profile: ${languageProfile}`,
`Request has an override language profile ID: ${languageProfile}`,
{
label: 'Media Request',
requestId: this.id,
mediaId: this.media.id,
}
);
}
@ -696,13 +643,13 @@ export class MediaRequest {
tags = this.tags;
logger.info(`Request has override tags`, {
label: 'Media Request',
requestId: this.id,
mediaId: this.media.id,
tagIds: tags,
});
}
// Run this asynchronously so we don't wait for it on the UI side
sonarr
.addSeries({
const sonarrSeriesOptions: AddSeriesOptions = {
profileId: qualityProfile,
languageProfileId: languageProfile,
rootFolderPath: rootFolder,
@ -714,7 +661,11 @@ export class MediaRequest {
tags,
monitored: true,
searchNow: !sonarrSettings.preventSearch,
})
};
// Run this asynchronously so we don't wait for it on the UI side
sonarr
.addSeries(sonarrSeriesOptions)
.then(async (sonarrSeries) => {
// We grab media again here to make sure we have the latest version of it
const media = await mediaRepository.findOne({
@ -723,7 +674,7 @@ export class MediaRequest {
});
if (!media) {
throw new Error('Media data is missing');
throw new Error('Media data not found');
}
media[this.is4k ? 'externalServiceId4k' : 'externalServiceId'] =
@ -737,26 +688,99 @@ export class MediaRequest {
media[this.is4k ? 'status4k' : 'status'] = MediaStatus.UNKNOWN;
await mediaRepository.save(media);
logger.warn(
'Newly added series request failed to add to Sonarr, marking as unknown',
'Something went wrong sending series request to Sonarr, marking status as UNKNOWN',
{
label: 'Media Request',
requestId: this.id,
mediaId: this.media.id,
sonarrSeriesOptions,
}
);
notificationManager.sendNotification(Notification.MEDIA_FAILED, {
event: `${this.is4k ? '4K ' : ''}Series Request Failed`,
subject: `${series.name}${
series.first_air_date
? ` (${series.first_air_date.slice(0, 4)})`
: ''
this.sendNotification(media, Notification.MEDIA_FAILED);
});
logger.info('Sent request to Sonarr', {
label: 'Media Request',
requestId: this.id,
mediaId: this.media.id,
});
} catch (e) {
logger.error('Something went wrong sending request to Sonarr', {
label: 'Media Request',
errorMessage: e.message,
requestId: this.id,
mediaId: this.media.id,
});
throw new Error(e.message);
}
}
}
private async sendNotification(media: Media, type: Notification) {
const tmdb = new TheMovieDb();
try {
const mediaType = this.type === MediaType.MOVIE ? 'Movie' : 'Series';
let event: string | undefined;
let notifyAdmin = true;
switch (type) {
case Notification.MEDIA_APPROVED:
event = `${this.is4k ? '4K ' : ''}${mediaType} Request Approved`;
notifyAdmin = false;
break;
case Notification.MEDIA_DECLINED:
event = `${this.is4k ? '4K ' : ''}${mediaType} Request Declined`;
notifyAdmin = false;
break;
case Notification.MEDIA_PENDING:
event = `New ${this.is4k ? '4K ' : ''}${mediaType} Request`;
break;
case Notification.MEDIA_AUTO_APPROVED:
event = `${
this.is4k ? '4K ' : ''
}${mediaType} Request Automatically Approved`;
break;
case Notification.MEDIA_FAILED:
event = `${this.is4k ? '4K ' : ''}${mediaType} Request Failed`;
break;
}
if (this.type === MediaType.MOVIE) {
const movie = await tmdb.getMovie({ movieId: media.tmdbId });
notificationManager.sendNotification(type, {
media,
request: this,
notifyAdmin,
notifyUser: notifyAdmin ? undefined : this.requestedBy,
event,
subject: `${movie.title}${
movie.release_date ? ` (${movie.release_date.slice(0, 4)})` : ''
}`,
message: truncate(series.overview, {
message: truncate(movie.overview, {
length: 500,
separator: /\s/,
omission: '…',
}),
image: `https://image.tmdb.org/t/p/w600_and_h900_bestv2${series.poster_path}`,
image: `https://image.tmdb.org/t/p/w600_and_h900_bestv2${movie.poster_path}`,
});
} else if (this.type === MediaType.TV) {
const tv = await tmdb.getTvShow({ tvId: media.tmdbId });
notificationManager.sendNotification(type, {
media,
request: this,
notifyAdmin,
notifyUser: notifyAdmin ? undefined : this.requestedBy,
event,
subject: `${tv.name}${
tv.first_air_date ? ` (${tv.first_air_date.slice(0, 4)})` : ''
}`,
message: truncate(tv.overview, {
length: 500,
separator: /\s/,
omission: '…',
}),
image: `https://image.tmdb.org/t/p/w600_and_h900_bestv2${tv.poster_path}`,
extra: [
{
name: 'Requested Seasons',
@ -765,19 +789,15 @@ export class MediaRequest {
.join(', '),
},
],
request: this,
notifyAdmin: true,
});
});
logger.info('Sent request to Sonarr', { label: 'Media Request' });
}
} catch (e) {
const errorMessage = `Request failed to send to Sonarr: ${e.message}`;
logger.error('Request failed to send to Sonarr', {
label: 'Media Request',
errorMessage,
logger.error('Something went wrong sending media notification(s)', {
label: 'Notifications',
errorMessage: e.message,
requestId: this.id,
mediaId: this.media.id,
});
throw new Error(errorMessage);
}
}
}
}

@ -1,6 +1,7 @@
import { Router } from 'express';
import TheMovieDb from '../api/themoviedb';
import Media from '../entity/Media';
import logger from '../logger';
import { mapCollection } from '../models/Collection';
const collectionRoutes = Router();
@ -20,7 +21,15 @@ collectionRoutes.get<{ id: string }>('/:id', async (req, res, next) => {
return res.status(200).json(mapCollection(collection, media));
} catch (e) {
return next({ status: 404, message: 'Collection does not exist' });
logger.debug('Something went wrong retrieving collection', {
label: 'API',
errorMessage: e.message,
collectionId: req.params.id,
});
return next({
status: 500,
message: 'Unable to retrieve collection.',
});
}
});

@ -37,9 +37,10 @@ export const createTmdbWithRegionLanguage = (user?: User): TheMovieDb => {
const discoverRoutes = Router();
discoverRoutes.get('/movies', async (req, res) => {
discoverRoutes.get('/movies', async (req, res, next) => {
const tmdb = createTmdbWithRegionLanguage(req.user);
try {
const data = await tmdb.getDiscoverMovies({
page: Number(req.query.page),
language: req.locale ?? (req.query.language as string),
@ -59,11 +60,22 @@ discoverRoutes.get('/movies', async (req, res) => {
mapMovieResult(
result,
media.find(
(req) => req.tmdbId === result.id && req.mediaType === MediaType.MOVIE
(req) =>
req.tmdbId === result.id && req.mediaType === MediaType.MOVIE
)
)
),
});
} catch (e) {
logger.debug('Something went wrong retrieving popular movies', {
label: 'API',
errorMessage: e.message,
});
return next({
status: 500,
message: 'Unable to retrieve popular movies.',
});
}
});
discoverRoutes.get<{ language: string }>(
@ -71,6 +83,7 @@ discoverRoutes.get<{ language: string }>(
async (req, res, next) => {
const tmdb = createTmdbWithRegionLanguage(req.user);
try {
const languages = await tmdb.getLanguages();
const language = languages.find(
@ -78,7 +91,7 @@ discoverRoutes.get<{ language: string }>(
);
if (!language) {
return next({ status: 404, message: 'Unable to retrieve language' });
return next({ status: 404, message: 'Language not found.' });
}
const data = await tmdb.getDiscoverMovies({
@ -106,6 +119,17 @@ discoverRoutes.get<{ language: string }>(
)
),
});
} catch (e) {
logger.debug('Something went wrong retrieving movies by language', {
label: 'API',
errorMessage: e.message,
language: req.params.language,
});
return next({
status: 500,
message: 'Unable to retrieve movies by language.',
});
}
}
);
@ -114,6 +138,7 @@ discoverRoutes.get<{ genreId: string }>(
async (req, res, next) => {
const tmdb = createTmdbWithRegionLanguage(req.user);
try {
const genres = await tmdb.getMovieGenres({
language: req.locale ?? (req.query.language as string),
});
@ -123,7 +148,7 @@ discoverRoutes.get<{ genreId: string }>(
);
if (!genre) {
return next({ status: 404, message: 'Unable to retrieve genre' });
return next({ status: 404, message: 'Genre not found.' });
}
const data = await tmdb.getDiscoverMovies({
@ -151,6 +176,17 @@ discoverRoutes.get<{ genreId: string }>(
)
),
});
} catch (e) {
logger.debug('Something went wrong retrieving movies by genre', {
label: 'API',
errorMessage: e.message,
genreId: req.params.genreId,
});
return next({
status: 500,
message: 'Unable to retrieve movies by genre.',
});
}
}
);
@ -188,12 +224,20 @@ discoverRoutes.get<{ studioId: string }>(
),
});
} catch (e) {
return next({ status: 404, message: 'Unable to retrieve studio' });
logger.debug('Something went wrong retrieving movies by studio', {
label: 'API',
errorMessage: e.message,
studioId: req.params.studioId,
});
return next({
status: 500,
message: 'Unable to retrieve movies by studio.',
});
}
}
);
discoverRoutes.get('/movies/upcoming', async (req, res) => {
discoverRoutes.get('/movies/upcoming', async (req, res, next) => {
const tmdb = createTmdbWithRegionLanguage(req.user);
const now = new Date();
@ -202,6 +246,7 @@ discoverRoutes.get('/movies/upcoming', async (req, res) => {
.toISOString()
.split('T')[0];
try {
const data = await tmdb.getDiscoverMovies({
page: Number(req.query.page),
language: req.locale ?? (req.query.language as string),
@ -220,16 +265,28 @@ discoverRoutes.get('/movies/upcoming', async (req, res) => {
mapMovieResult(
result,
media.find(
(med) => med.tmdbId === result.id && med.mediaType === MediaType.MOVIE
(med) =>
med.tmdbId === result.id && med.mediaType === MediaType.MOVIE
)
)
),
});
} catch (e) {
logger.debug('Something went wrong retrieving upcoming movies', {
label: 'API',
errorMessage: e.message,
});
return next({
status: 500,
message: 'Unable to retrieve upcoming movies.',
});
}
});
discoverRoutes.get('/tv', async (req, res) => {
discoverRoutes.get('/tv', async (req, res, next) => {
const tmdb = createTmdbWithRegionLanguage(req.user);
try {
const data = await tmdb.getDiscoverTv({
page: Number(req.query.page),
language: req.locale ?? (req.query.language as string),
@ -254,6 +311,16 @@ discoverRoutes.get('/tv', async (req, res) => {
)
),
});
} catch (e) {
logger.debug('Something went wrong retrieving popular series', {
label: 'API',
errorMessage: e.message,
});
return next({
status: 500,
message: 'Unable to retrieve popular series.',
});
}
});
discoverRoutes.get<{ language: string }>(
@ -261,6 +328,7 @@ discoverRoutes.get<{ language: string }>(
async (req, res, next) => {
const tmdb = createTmdbWithRegionLanguage(req.user);
try {
const languages = await tmdb.getLanguages();
const language = languages.find(
@ -268,7 +336,7 @@ discoverRoutes.get<{ language: string }>(
);
if (!language) {
return next({ status: 404, message: 'Unable to retrieve language' });
return next({ status: 404, message: 'Language not found.' });
}
const data = await tmdb.getDiscoverTv({
@ -290,11 +358,23 @@ discoverRoutes.get<{ language: string }>(
mapTvResult(
result,
media.find(
(med) => med.tmdbId === result.id && med.mediaType === MediaType.TV
(med) =>
med.tmdbId === result.id && med.mediaType === MediaType.TV
)
)
),
});
} catch (e) {
logger.debug('Something went wrong retrieving series by language', {
label: 'API',
errorMessage: e.message,
language: req.params.language,
});
return next({
status: 500,
message: 'Unable to retrieve series by language.',
});
}
}
);
@ -303,6 +383,7 @@ discoverRoutes.get<{ genreId: string }>(
async (req, res, next) => {
const tmdb = createTmdbWithRegionLanguage(req.user);
try {
const genres = await tmdb.getTvGenres({
language: req.locale ?? (req.query.language as string),
});
@ -312,7 +393,7 @@ discoverRoutes.get<{ genreId: string }>(
);
if (!genre) {
return next({ status: 404, message: 'Unable to retrieve genre' });
return next({ status: 404, message: 'Genre not found.' });
}
const data = await tmdb.getDiscoverTv({
@ -334,11 +415,23 @@ discoverRoutes.get<{ genreId: string }>(
mapTvResult(
result,
media.find(
(med) => med.tmdbId === result.id && med.mediaType === MediaType.TV
(med) =>
med.tmdbId === result.id && med.mediaType === MediaType.TV
)
)
),
});
} catch (e) {
logger.debug('Something went wrong retrieving series by genre', {
label: 'API',
errorMessage: e.message,
genreId: req.params.genreId,
});
return next({
status: 500,
message: 'Unable to retrieve series by genre.',
});
}
}
);
@ -376,12 +469,20 @@ discoverRoutes.get<{ networkId: string }>(
),
});
} catch (e) {
return next({ status: 404, message: 'Unable to retrieve network' });
logger.debug('Something went wrong retrieving series by network', {
label: 'API',
errorMessage: e.message,
networkId: req.params.networkId,
});
return next({
status: 500,
message: 'Unable to retrieve series by network.',
});
}
}
);
discoverRoutes.get('/tv/upcoming', async (req, res) => {
discoverRoutes.get('/tv/upcoming', async (req, res, next) => {
const tmdb = createTmdbWithRegionLanguage(req.user);
const now = new Date();
@ -390,6 +491,7 @@ discoverRoutes.get('/tv/upcoming', async (req, res) => {
.toISOString()
.split('T')[0];
try {
const data = await tmdb.getDiscoverTv({
page: Number(req.query.page),
language: req.locale ?? (req.query.language as string),
@ -413,11 +515,22 @@ discoverRoutes.get('/tv/upcoming', async (req, res) => {
)
),
});
} catch (e) {
logger.debug('Something went wrong retrieving upcoming series', {
label: 'API',
errorMessage: e.message,
});
return next({
status: 500,
message: 'Unable to retrieve upcoming series.',
});
}
});
discoverRoutes.get('/trending', async (req, res) => {
discoverRoutes.get('/trending', async (req, res, next) => {
const tmdb = createTmdbWithRegionLanguage(req.user);
try {
const data = await tmdb.getAllTrending({
page: Number(req.query.page),
language: req.locale ?? (req.query.language as string),
@ -451,13 +564,24 @@ discoverRoutes.get('/trending', async (req, res) => {
)
),
});
} catch (e) {
logger.debug('Something went wrong retrieving trending items', {
label: 'API',
errorMessage: e.message,
});
return next({
status: 500,
message: 'Unable to retrieve trending items.',
});
}
});
discoverRoutes.get<{ keywordId: string }>(
'/keyword/:keywordId/movies',
async (req, res) => {
async (req, res, next) => {
const tmdb = new TheMovieDb();
try {
const data = await tmdb.getMoviesByKeyword({
keywordId: Number(req.params.keywordId),
page: Number(req.query.page),
@ -482,6 +606,17 @@ discoverRoutes.get<{ keywordId: string }>(
)
),
});
} catch (e) {
logger.debug('Something went wrong retrieving movies by keyword', {
label: 'API',
errorMessage: e.message,
keywordId: req.params.keywordId,
});
return next({
status: 500,
message: 'Unable to retrieve movies by keyword.',
});
}
}
);
@ -515,7 +650,8 @@ discoverRoutes.get<{ language: string }, GenreSliderItem[]>(
return res.status(200).json(sortedData);
} catch (e) {
logger.error('Something went wrong retrieving the movie genre slider', {
logger.debug('Something went wrong retrieving the movie genre slider', {
label: 'API',
errorMessage: e.message,
});
return next({
@ -556,12 +692,13 @@ discoverRoutes.get<{ language: string }, GenreSliderItem[]>(
return res.status(200).json(sortedData);
} catch (e) {
logger.error('Something went wrong retrieving the tv genre slider', {
logger.debug('Something went wrong retrieving the series genre slider', {
label: 'API',
errorMessage: e.message,
});
return next({
status: 500,
message: 'Unable to retrieve tv genre slider.',
message: 'Unable to retrieve series genre slider.',
});
}
}

@ -5,6 +5,7 @@ import { TmdbMovieResult, TmdbTvResult } from '../api/themoviedb/interfaces';
import { StatusResponse } from '../interfaces/api/settingsInterfaces';
import { Permission } from '../lib/permissions';
import { getSettings } from '../lib/settings';
import logger from '../logger';
import { checkUser, isAuthenticated } from '../middleware/auth';
import { mapProductionCompany } from '../models/Movie';
import { mapNetwork } from '../models/Tv';
@ -114,61 +115,130 @@ router.use('/issue', isAuthenticated(), issueRoutes);
router.use('/issueComment', isAuthenticated(), issueCommentRoutes);
router.use('/auth', authRoutes);
router.get('/regions', isAuthenticated(), async (req, res) => {
router.get('/regions', isAuthenticated(), async (req, res, next) => {
const tmdb = new TheMovieDb();
try {
const regions = await tmdb.getRegions();
return res.status(200).json(regions);
} catch (e) {
logger.debug('Something went wrong retrieving regions', {
label: 'API',
errorMessage: e.message,
});
return next({
status: 500,
message: 'Unable to retrieve regions.',
});
}
});
router.get('/languages', isAuthenticated(), async (req, res) => {
router.get('/languages', isAuthenticated(), async (req, res, next) => {
const tmdb = new TheMovieDb();
try {
const languages = await tmdb.getLanguages();
return res.status(200).json(languages);
} catch (e) {
logger.debug('Something went wrong retrieving languages', {
label: 'API',
errorMessage: e.message,
});
return next({
status: 500,
message: 'Unable to retrieve languages.',
});
}
});
router.get<{ id: string }>('/studio/:id', async (req, res) => {
router.get<{ id: string }>('/studio/:id', async (req, res, next) => {
const tmdb = new TheMovieDb();
try {
const studio = await tmdb.getStudio(Number(req.params.id));
return res.status(200).json(mapProductionCompany(studio));
} catch (e) {
logger.debug('Something went wrong retrieving studio', {
label: 'API',
errorMessage: e.message,
studioId: req.params.id,
});
return next({
status: 500,
message: 'Unable to retrieve studio.',
});
}
});
router.get<{ id: string }>('/network/:id', async (req, res) => {
router.get<{ id: string }>('/network/:id', async (req, res, next) => {
const tmdb = new TheMovieDb();
try {
const network = await tmdb.getNetwork(Number(req.params.id));
return res.status(200).json(mapNetwork(network));
} catch (e) {
logger.debug('Something went wrong retrieving network', {
label: 'API',
errorMessage: e.message,
networkId: req.params.id,
});
return next({
status: 500,
message: 'Unable to retrieve network.',
});
}
});
router.get('/genres/movie', isAuthenticated(), async (req, res) => {
router.get('/genres/movie', isAuthenticated(), async (req, res, next) => {
const tmdb = new TheMovieDb();
try {
const genres = await tmdb.getMovieGenres({
language: req.locale ?? (req.query.language as string),
});
return res.status(200).json(genres);
} catch (e) {
logger.debug('Something went wrong retrieving movie genres', {
label: 'API',
errorMessage: e.message,
});
return next({
status: 500,
message: 'Unable to retrieve movie genres.',
});
}
});
router.get('/genres/tv', isAuthenticated(), async (req, res) => {
router.get('/genres/tv', isAuthenticated(), async (req, res, next) => {
const tmdb = new TheMovieDb();
try {
const genres = await tmdb.getTvGenres({
language: req.locale ?? (req.query.language as string),
});
return res.status(200).json(genres);
} catch (e) {
logger.debug('Something went wrong retrieving series genres', {
label: 'API',
errorMessage: e.message,
});
return next({
status: 500,
message: 'Unable to retrieve series genres.',
});
}
});
router.get('/backdrops', async (req, res) => {
router.get('/backdrops', async (req, res, next) => {
const tmdb = createTmdbWithRegionLanguage();
try {
const data = (
await tmdb.getAllTrending({
page: 1,
@ -186,6 +256,16 @@ router.get('/backdrops', async (req, res) => {
.map((result) => result.backdrop_path)
.filter((backdropPath) => !!backdropPath)
);
} catch (e) {
logger.debug('Something went wrong retrieving backdrops', {
label: 'API',
errorMessage: e.message,
});
return next({
status: 500,
message: 'Unable to retrieve backdrops.',
});
}
});
router.get('/', (_req, res) => {

@ -22,17 +22,22 @@ movieRoutes.get('/:id', async (req, res, next) => {
return res.status(200).json(mapMovieDetails(tmdbMovie, media));
} catch (e) {
logger.error('Something went wrong getting movie', {
label: 'Movie',
message: e.message,
logger.debug('Something went wrong retrieving movie', {
label: 'API',
errorMessage: e.message,
movieId: req.params.id,
});
return next({
status: 500,
message: 'Unable to retrieve movie.',
});
return next({ status: 404, message: 'Movie does not exist' });
}
});
movieRoutes.get('/:id/recommendations', async (req, res) => {
movieRoutes.get('/:id/recommendations', async (req, res, next) => {
const tmdb = new TheMovieDb();
try {
const results = await tmdb.getMovieRecommendations({
movieId: Number(req.params.id),
page: Number(req.query.page),
@ -51,16 +56,29 @@ movieRoutes.get('/:id/recommendations', async (req, res) => {
mapMovieResult(
result,
media.find(
(req) => req.tmdbId === result.id && req.mediaType === MediaType.MOVIE
(req) =>
req.tmdbId === result.id && req.mediaType === MediaType.MOVIE
)
)
),
});
} catch (e) {
logger.debug('Something went wrong retrieving movie recommendations', {
label: 'API',
errorMessage: e.message,
movieId: req.params.id,
});
return next({
status: 500,
message: 'Unable to retrieve movie recommendations.',
});
}
});
movieRoutes.get('/:id/similar', async (req, res) => {
movieRoutes.get('/:id/similar', async (req, res, next) => {
const tmdb = new TheMovieDb();
try {
const results = await tmdb.getMovieSimilar({
movieId: Number(req.params.id),
page: Number(req.query.page),
@ -79,18 +97,30 @@ movieRoutes.get('/:id/similar', async (req, res) => {
mapMovieResult(
result,
media.find(
(req) => req.tmdbId === result.id && req.mediaType === MediaType.MOVIE
(req) =>
req.tmdbId === result.id && req.mediaType === MediaType.MOVIE
)
)
),
});
} catch (e) {
logger.debug('Something went wrong retrieving similar movies', {
label: 'API',
errorMessage: e.message,
movieId: req.params.id,
});
return next({
status: 500,
message: 'Unable to retrieve similar movies.',
});
}
});
movieRoutes.get('/:id/ratings', async (req, res, next) => {
try {
const tmdb = new TheMovieDb();
const rtapi = new RottenTomatoes();
try {
const movie = await tmdb.getMovie({
movieId: Number(req.params.id),
});
@ -101,12 +131,23 @@ movieRoutes.get('/:id/ratings', async (req, res, next) => {
);
if (!rtratings) {
return next({ status: 404, message: 'Unable to retrieve ratings' });
return next({
status: 404,
message: 'Rotten Tomatoes ratings not found.',
});
}
return res.status(200).json(rtratings);
} catch (e) {
return next({ status: 404, message: 'Movie does not exist' });
logger.debug('Something went wrong retrieving movie ratings', {
label: 'API',
errorMessage: e.message,
movieId: req.params.id,
});
return next({
status: 500,
message: 'Unable to retrieve movie ratings.',
});
}
});

@ -20,14 +20,22 @@ personRoutes.get('/:id', async (req, res, next) => {
});
return res.status(200).json(mapPersonDetails(person));
} catch (e) {
logger.error(e.message);
next({ status: 404, message: 'Person not found' });
logger.debug('Something went wrong retrieving person', {
label: 'API',
errorMessage: e.message,
personId: req.params.id,
});
return next({
status: 500,
message: 'Unable to retrieve person.',
});
}
});
personRoutes.get('/:id/combined_credits', async (req, res) => {
personRoutes.get('/:id/combined_credits', async (req, res, next) => {
const tmdb = new TheMovieDb();
try {
const combinedCredits = await tmdb.getPersonCombinedCredits({
personId: Number(req.params.id),
language: req.locale ?? (req.query.language as string),
@ -66,6 +74,17 @@ personRoutes.get('/:id/combined_credits', async (req, res) => {
.filter((item) => !item.adult),
id: combinedCredits.id,
});
} catch (e) {
logger.debug('Something went wrong retrieving combined credits', {
label: 'API',
errorMessage: e.message,
personId: req.params.id,
});
return next({
status: 500,
message: 'Unable to retrieve combined credits.',
});
}
});
export default personRoutes;

@ -3,15 +3,17 @@ import TheMovieDb from '../api/themoviedb';
import { TmdbSearchMultiResponse } from '../api/themoviedb/interfaces';
import Media from '../entity/Media';
import { findSearchProvider } from '../lib/search';
import logger from '../logger';
import { mapSearchResults } from '../models/Search';
const searchRoutes = Router();
searchRoutes.get('/', async (req, res) => {
searchRoutes.get('/', async (req, res, next) => {
const queryString = req.query.query as string;
const searchProvider = findSearchProvider(queryString.toLowerCase());
let results: TmdbSearchMultiResponse;
try {
if (searchProvider) {
const [id] = queryString
.toLowerCase()
@ -40,6 +42,17 @@ searchRoutes.get('/', async (req, res) => {
totalResults: results.total_results,
results: mapSearchResults(results.results, media),
});
} catch (e) {
logger.debug('Something went wrong retrieving search results', {
label: 'API',
errorMessage: e.message,
query: req.query.query,
});
return next({
status: 500,
message: 'Unable to retrieve search results.',
});
}
});
export default searchRoutes;

@ -243,10 +243,11 @@ settingsRoutes.post('/tautulli', async (req, res) => {
settingsRoutes.get(
'/plex/users',
isAuthenticated(Permission.MANAGE_USERS),
async (req, res) => {
async (req, res, next) => {
const userRepository = getRepository(User);
const qb = userRepository.createQueryBuilder('user');
try {
const admin = await userRepository.findOneOrFail({
select: ['id', 'plexToken'],
order: { id: 'ASC' },
@ -289,6 +290,16 @@ settingsRoutes.get(
);
return res.status(200).json(sortBy(unimportedPlexUsers, 'username'));
} catch (e) {
logger.error('Something went wrong getting unimported Plex users', {
label: 'API',
errorMessage: e.message,
});
next({
status: 500,
message: 'Unable to retrieve unimported Plex users.',
});
}
}
);

@ -21,17 +21,22 @@ tvRoutes.get('/:id', async (req, res, next) => {
return res.status(200).json(mapTvDetails(tv, media));
} catch (e) {
logger.error('Failed to get tv show', {
logger.debug('Something went wrong retrieving series', {
label: 'API',
errorMessage: e.message,
tvId: req.params.id,
});
return next({
status: 500,
message: 'Unable to retrieve series.',
});
return next({ status: 404, message: 'TV Show does not exist' });
}
});
tvRoutes.get('/:id/season/:seasonNumber', async (req, res) => {
tvRoutes.get('/:id/season/:seasonNumber', async (req, res, next) => {
const tmdb = new TheMovieDb();
try {
const season = await tmdb.getTvSeason({
tvId: Number(req.params.id),
seasonNumber: Number(req.params.seasonNumber),
@ -39,11 +44,24 @@ tvRoutes.get('/:id/season/:seasonNumber', async (req, res) => {
});
return res.status(200).json(mapSeasonWithEpisodes(season));
} catch (e) {
logger.debug('Something went wrong retrieving season', {
label: 'API',
errorMessage: e.message,
tvId: req.params.id,
seasonNumber: req.params.seasonNumber,
});
return next({
status: 500,
message: 'Unable to retrieve season.',
});
}
});
tvRoutes.get('/:id/recommendations', async (req, res) => {
tvRoutes.get('/:id/recommendations', async (req, res, next) => {
const tmdb = new TheMovieDb();
try {
const results = await tmdb.getTvRecommendations({
tvId: Number(req.params.id),
page: Number(req.query.page),
@ -67,11 +85,23 @@ tvRoutes.get('/:id/recommendations', async (req, res) => {
)
),
});
} catch (e) {
logger.debug('Something went wrong retrieving series recommendations', {
label: 'API',
errorMessage: e.message,
tvId: req.params.id,
});
return next({
status: 500,
message: 'Unable to retrieve series recommendations.',
});
}
});
tvRoutes.get('/:id/similar', async (req, res) => {
tvRoutes.get('/:id/similar', async (req, res, next) => {
const tmdb = new TheMovieDb();
try {
const results = await tmdb.getTvSimilar({
tvId: Number(req.params.id),
page: Number(req.query.page),
@ -95,30 +125,52 @@ tvRoutes.get('/:id/similar', async (req, res) => {
)
),
});
} catch (e) {
logger.debug('Something went wrong retrieving similar series', {
label: 'API',
errorMessage: e.message,
tvId: req.params.id,
});
return next({
status: 500,
message: 'Unable to retrieve similar series.',
});
}
});
tvRoutes.get('/:id/ratings', async (req, res, next) => {
const tmdb = new TheMovieDb();
const rtapi = new RottenTomatoes();
try {
const tv = await tmdb.getTvShow({
tvId: Number(req.params.id),
});
if (!tv) {
return next({ status: 404, message: 'TV Show does not exist' });
}
const rtratings = await rtapi.getTVRatings(
tv.name,
tv.first_air_date ? Number(tv.first_air_date.slice(0, 4)) : undefined
);
if (!rtratings) {
return next({ status: 404, message: 'Unable to retrieve ratings' });
return next({
status: 404,
message: 'Rotten Tomatoes ratings not found.',
});
}
return res.status(200).json(rtratings);
} catch (e) {
logger.debug('Something went wrong retrieving series ratings', {
label: 'API',
errorMessage: e.message,
tvId: req.params.id,
});
return next({
status: 500,
message: 'Unable to retrieve series ratings.',
});
}
});
export default tvRoutes;

@ -12,6 +12,7 @@ import IssueComment from '../entity/IssueComment';
import Media from '../entity/Media';
import notificationManager, { Notification } from '../lib/notifications';
import { Permission } from '../lib/permissions';
import logger from '../logger';
@EventSubscriber()
export class IssueCommentSubscriber
@ -26,22 +27,17 @@ export class IssueCommentSubscriber
let image: string;
const tmdb = new TheMovieDb();
try {
const issue = (
await getRepository(IssueComment).findOne({
await getRepository(IssueComment).findOneOrFail({
where: { id: entity.id },
relations: ['issue'],
})
)?.issue;
if (!issue) {
return;
}
).issue;
const media = await getRepository(Media).findOne({
const media = await getRepository(Media).findOneOrFail({
where: { id: issue.media.id },
});
if (!media) {
return;
}
if (media.mediaType === MediaType.MOVIE) {
const movie = await tmdb.getMovie({ movieId: media.tmdbId });
@ -83,6 +79,16 @@ export class IssueCommentSubscriber
: undefined,
});
}
} catch (e) {
logger.error(
'Something went wrong sending issue comment notification(s)',
{
label: 'Notifications',
errorMessage: e.message,
commentId: entity.id,
}
);
}
}
public afterInsert(event: InsertEvent<IssueComment>): void {

@ -11,6 +11,7 @@ import { MediaType } from '../constants/media';
import Issue from '../entity/Issue';
import notificationManager, { Notification } from '../lib/notifications';
import { Permission } from '../lib/permissions';
import logger from '../logger';
@EventSubscriber()
export class IssueSubscriber implements EntitySubscriberInterface<Issue> {
@ -22,6 +23,8 @@ export class IssueSubscriber implements EntitySubscriberInterface<Issue> {
let title: string;
let image: string;
const tmdb = new TheMovieDb();
try {
if (entity.media.mediaType === MediaType.MOVIE) {
const movie = await tmdb.getMovie({ movieId: entity.media.tmdbId });
@ -88,6 +91,13 @@ export class IssueSubscriber implements EntitySubscriberInterface<Issue> {
? entity.createdBy
: undefined,
});
} catch (e) {
logger.error('Something went wrong sending issue notification(s)', {
label: 'Notifications',
errorMessage: e.message,
issueId: entity.id,
});
}
}
public afterInsert(event: InsertEvent<Issue>): void {

@ -12,6 +12,7 @@ import Media from '../entity/Media';
import { MediaRequest } from '../entity/MediaRequest';
import Season from '../entity/Season';
import notificationManager, { Notification } from '../lib/notifications';
import logger from '../logger';
@EventSubscriber()
export class MediaSubscriber implements EntitySubscriberInterface<Media> {
@ -36,15 +37,21 @@ export class MediaSubscriber implements EntitySubscriberInterface<Media> {
if (relatedRequests.length > 0) {
const tmdb = new TheMovieDb();
try {
const movie = await tmdb.getMovie({ movieId: entity.tmdbId });
relatedRequests.forEach((request) => {
notificationManager.sendNotification(Notification.MEDIA_AVAILABLE, {
notificationManager.sendNotification(
Notification.MEDIA_AVAILABLE,
{
event: `${is4k ? '4K ' : ''}Movie Request Now Available`,
notifyAdmin: false,
notifyUser: request.requestedBy,
subject: `${movie.title}${
movie.release_date ? ` (${movie.release_date.slice(0, 4)})` : ''
movie.release_date
? ` (${movie.release_date.slice(0, 4)})`
: ''
}`,
message: truncate(movie.overview, {
length: 500,
@ -54,12 +61,20 @@ export class MediaSubscriber implements EntitySubscriberInterface<Media> {
media: entity,
image: `https://image.tmdb.org/t/p/w600_and_h900_bestv2${movie.poster_path}`,
request,
}
);
});
} catch (e) {
logger.error('Something went wrong sending media notification(s)', {
label: 'Notifications',
errorMessage: e.message,
mediaId: entity.id,
});
}
}
}
}
}
private async notifyAvailableSeries(
entity: Media,
@ -114,6 +129,8 @@ export class MediaSubscriber implements EntitySubscriberInterface<Media> {
processedSeasons.push(
...request.seasons.map((season) => season.seasonNumber)
);
try {
const tv = await tmdb.getTvShow({ tvId: entity.tmdbId });
notificationManager.sendNotification(Notification.MEDIA_AVAILABLE, {
event: `${is4k ? '4K ' : ''}Series Request Now Available`,
@ -139,6 +156,13 @@ export class MediaSubscriber implements EntitySubscriberInterface<Media> {
],
request,
});
} catch (e) {
logger.error('Something went wrong sending media notification(s)', {
label: 'Notifications',
errorMessage: e.message,
mediaId: entity.id,
});
}
}
}
}

@ -11,7 +11,7 @@ confinement: strict
parts:
overseerr:
plugin: nodejs
nodejs-version: '14.18.1'
nodejs-version: '16.13.1'
nodejs-package-manager: 'yarn'
nodejs-yarn-version: v1.22.10
build-packages:

Loading…
Cancel
Save