UNPKG

better-trakt

Version:

A Trakt.tv client with native Typescript support and quality of life features

256 lines 10.7 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Movies = void 0; const media_1 = require("../media"); const utils_1 = require("../utils"); /** * Movies api namespace */ class Movies { constructor(config) { this.config = { apiUrl: `${config.apiUrl}/movies`, client: config.client, }; } /** * Returns a single movie's details. * @param movieId movie id * @returns */ summary({ movieId }) { (0, utils_1.checkRequiredArg)(movieId, 'movieId', 'string'); return (0, media_1.getMediaSummary_Full)(this.config, movieId); } /** * Returns all cast and crew for a movie. * @param movieId movie id * @returns */ people({ movieId }) { (0, utils_1.checkRequiredArg)(movieId, 'movieId', 'string'); return (0, media_1.getMediaPeople)(this.config, movieId); } /** * Returns all movies being watched right now. * @param pagination * @returns */ trending({ pagination, filters, }) { (0, utils_1.checkRequiredArg)(pagination, 'pagination', 'object'); return (0, media_1.getTrendingMedia)(this.config, 'movies', { pagination, filters }); } /** * Returns the most popular movies. * @param pagination * @returns */ popular({ pagination, filters, }) { (0, utils_1.checkRequiredArg)(pagination, 'pagination', 'object'); return (0, media_1.getPopularMedia)(this.config, 'movies', { pagination, filters }); } /** * Returns the most recommended movies in the specified time period, defaulting to weekly. All stats are relative to the specific time period. * @param param0 * @returns */ recommended({ pagination, filters, period, }) { (0, utils_1.checkRequiredArg)(pagination, 'pagination', 'object'); return (0, media_1.getRecommendedMedia)(this.config, 'movies', { pagination, filters, period }); } /** * Returns the most played (a single user can watch multiple times) movies in the specified time period, defaulting to weekly. All stats are relative to the specific time period. * @param param0 * @returns */ played({ pagination, filters, period, }) { (0, utils_1.checkRequiredArg)(pagination, 'pagination', 'object'); return (0, media_1.getPlayedMedia)(this.config, 'movies', { pagination, filters, period }); } /** * Returns the most collected (unique users) shows in the specified time period, defaulting to weekly. All stats are relative to the specific time period. * @param param0 * @returns */ watched({ pagination, filters, period, }) { (0, utils_1.checkRequiredArg)(pagination, 'pagination', 'object'); return (0, media_1.getWatchedMedia)(this.config, 'movies', { pagination, filters, period }); } /** * Returns the most collected (unique users) movies in the specified time period, defaulting to weekly. All stats are relative to the specific time period. * @param param0 * @returns */ collected({ pagination, filters, period, }) { (0, utils_1.checkRequiredArg)(pagination, 'pagination', 'object'); return (0, media_1.getCollectedMedia)(this.config, 'movies', { pagination, filters, period }); } /** * Returns the most anticipated movies based on the number of lists a movie appears on. * @param param0 * @returns */ anticipated({ pagination, filters, }) { (0, utils_1.checkRequiredArg)(pagination, 'pagination', 'object'); return (0, media_1.getAnticipatedMedia)(this.config, 'movies', { pagination, filters }); } /** * Returns the top 10 grossing movies in the U.S. box office last weekend. Updated every Monday morning. * @returns */ boxOffice() { return (0, media_1.getBoxOfficeMedia)(this.config, 'movies'); } /** * Returns all shows updated since the specified UTC date and time. * We recommended storing the X-Start-Date header you can be efficient using this method moving forward. * By default, 10 results are returned. You can send a limit to get up to 100 results per page. * * **Important!** * The start_date is only accurate to the hour, for caching purposes. * Please drop the minutes and seconds from your timestamp to help optimize our cached data. * For example, use 2021-07-17T12:00:00Z and not 2021-07-17T12:23:34Z. * * Note: The start_date can only be a maximum of 30 days in the past. * @param param0 * @returns */ updates({ pagination, startDate, }) { (0, utils_1.checkRequiredArg)(pagination, 'pagination', 'object'); return (0, media_1.getUpdatesMedia)(this.config, 'movies', { pagination, startDate }); } /** * Returns all show Trakt IDs updated since the specified UTC date and time. * We recommended storing the X-Start-Date header you can be efficient using this method moving forward. * By default, 10 results are returned. You can send a limit to get up to 100 results per page. * * **Important!** * The start_date is only accurate to the hour, for caching purposes. * Please drop the minutes and seconds from your timestamp to help optimize our cached data. * For example, use 2021-07-17T12:00:00Z and not 2021-07-17T12:23:34Z. * * Note: The start_date can only be a maximum of 30 days in the past. * @param param0 * @returns */ updatedIDs({ pagination, startDate, }) { (0, utils_1.checkRequiredArg)(pagination, 'pagination', 'object'); return (0, media_1.getUpdatedIDsMedia)(this.config, 'movies', { pagination, startDate }); } /** * Returns all title aliases for a movie. Includes country where name is different. * @param param0 * @returns */ aliases({ movieID }) { (0, utils_1.checkRequiredArg)(movieID, 'movieID', 'string'); return (0, media_1.getAliasesMedia)(this.config, 'movies', { mediaID: movieID }); } /** * Returns all releases for a movie including country, * certification, release date, release type, and note. * The release type can be set to unknown, premiere, * limited, theatrical, digital, physical, or tv. * The note might have optional info such as the film festival * name for a premiere release or Blu-ray specs for a physical release. * We pull this info from TMDB. * @param param0 * @returns All the releases for a movie */ releases({ movieID, country, }) { return __awaiter(this, void 0, void 0, function* () { const url = `${this.config.apiUrl}/movies/${movieID}/releases`; const response = yield (0, utils_1.fetch)(this.config.client, url, { country }); return response; }); } /** * Returns all translations for a movie, including language and translated values for title, tagline and overview. * @param param0 * @returns */ translations({ movieID, language, }) { return __awaiter(this, void 0, void 0, function* () { (0, utils_1.checkRequiredArg)(movieID, 'movieID', 'string'); return (0, media_1.getMediaTranslations)(this.config, 'movies', movieID, language); }); } /** * Returns all top level comments for a movie. By default, the newest comments are returned first. * Other sorting options include oldest, most likes, most replies, highest rated, lowest rated, and most plays. * @param param0 * @returns */ comments({ movieID, pagination, sort, }) { return __awaiter(this, void 0, void 0, function* () { (0, utils_1.checkRequiredArg)(movieID, 'movieID', 'string'); return (0, media_1.getMediaComments)(this.config, 'movies', movieID, { pagination, sort }); }); } /** * Returns all lists that contain this movie. By default, personal lists are returned sorted by the most popular. * @param param0 * @returns */ lists({ movieID, pagination, sort, type, }) { return __awaiter(this, void 0, void 0, function* () { (0, utils_1.checkRequiredArg)(movieID, 'movieID', 'string'); return (0, media_1.getListsWithMedia)(this.config, 'movies', movieID, { pagination, sort, type }); }); } /** * Returns rating (between 0 and 10) and distribution for a movie. * @param param0 * @returns */ ratings({ movieID }) { return __awaiter(this, void 0, void 0, function* () { (0, utils_1.checkRequiredArg)(movieID, 'movieID', 'string'); return (0, media_1.getMediaRating)(this.config, 'movies', movieID); }); } /** * Returns related and similar movies. * @param param0 * @returns */ related({ movieID, pagination, }) { return __awaiter(this, void 0, void 0, function* () { (0, utils_1.checkRequiredArg)(movieID, 'movieID', 'string'); return (0, media_1.getRelatedMedia)(this.config, 'movies', movieID, { pagination }); }); } /** * Returns lots of movie stats. * @param param0 * @returns */ stats({ movieID }) { return __awaiter(this, void 0, void 0, function* () { (0, utils_1.checkRequiredArg)(movieID, 'movieID', 'string'); return (0, media_1.getMediaStats)(this.config, 'movies', movieID); }); } /** * Returns all users watching this movie right now. * @param param0 * @returns */ watching({ movieID }) { return __awaiter(this, void 0, void 0, function* () { (0, utils_1.checkRequiredArg)(movieID, 'movieID', 'string'); return (0, media_1.getWatchingMedia)(this.config, 'movies', movieID); }); } } exports.Movies = Movies; //# sourceMappingURL=index.js.map