|
|
@ -1,15 +1,13 @@ |
|
|
|
import Application from "@server/Application"; |
|
|
|
import TheMovieDb from "@lib/tmdb"; |
|
|
|
import { env, secret } from "@server/util"; |
|
|
|
import { readFile } from "fs/promises"; |
|
|
|
import TVDB from "tvdb-v4"; |
|
|
|
import { request } from "https"; |
|
|
|
import Service from "./Service"; |
|
|
|
import TvDb from "./TvDb"; |
|
|
|
import { IApiMovieDetails } from "@common/api_schema"; |
|
|
|
import { MovieInfo, MovieTicket } from "@server/database/entities"; |
|
|
|
import { MovieInfo } from "@server/database/entities"; |
|
|
|
|
|
|
|
const CACHE_CLEAR_INTERVAL = 1000*10; // 60 seconds
|
|
|
|
const CACHE_CLEAR_INTERVAL = 1000*60; // 60 seconds
|
|
|
|
|
|
|
|
export default class MovieSearch extends Service |
|
|
|
{ |
|
|
@ -120,10 +118,10 @@ export default class MovieSearch extends Service |
|
|
|
* Get the details of a movie |
|
|
|
*/ |
|
|
|
public async details(id: number) { |
|
|
|
let isRequested = false; |
|
|
|
if (id in this.movieCache) { |
|
|
|
console.log("Returning the cached movie"); |
|
|
|
if (!this.movieCache[id].movie.is_requested) { |
|
|
|
isRequested = await MovieInfo.count({tmdbId: id}) > 0; |
|
|
|
let isRequested = await MovieInfo.count({tmdbId: id}) > 0; |
|
|
|
this.movieCache[id].movie.is_requested = isRequested; |
|
|
|
} |
|
|
|
return this.movieCache[id].movie; |
|
|
@ -137,7 +135,7 @@ export default class MovieSearch extends Service |
|
|
|
release_date : movie.release_date, |
|
|
|
runtime : movie.runtime, |
|
|
|
title : movie.title, |
|
|
|
is_requested : isRequested |
|
|
|
is_requested : await MovieInfo.count({tmdbId: id}) > 0 |
|
|
|
}; |
|
|
|
return this.cacheMovie(id, result).movie; |
|
|
|
} |
|
|
|