|
import { IMovie } from "@autoplex-api/request";
|
|
import { MovieTicket } from "@autoplex/database";
|
|
import { PlexIpc } from "services";
|
|
import Application from "./Application";
|
|
|
|
/**
|
|
* Convert a MovieTicket entity to a serialized IMovie object
|
|
*/
|
|
export async function convertTicketsToMovies(tickets: MovieTicket[]) {
|
|
let plex = Application.instance().service<PlexIpc>("Plex");
|
|
let plexLinks = await plex.movieLinks(tickets.map(ticket => ticket.tmdbId));
|
|
return tickets.map((ticket) => <IMovie>{
|
|
backdropPath : ticket.info?.backdropPath ?? null,
|
|
originalLanguage: ticket.info?.originalLanguage ?? null,
|
|
originalTitle : ticket.info?.originalTitle ?? null,
|
|
overview : ticket.info?.overview ?? null,
|
|
posterPath : ticket.info?.posterPath ?? null,
|
|
releaseDate : ticket.info?.releaseDate ?? null,
|
|
title : ticket.title,
|
|
plexLink : plexLinks[ticket.tmdbId],
|
|
tmdbId : ticket.tmdbId
|
|
});
|
|
}
|