better-trakt
Version:
A Trakt.tv client with native Typescript support and quality of life features
264 lines • 9.77 kB
JavaScript
;
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.getWatchingMedia = exports.getMediaStats = exports.getRelatedMedia = exports.getMediaRating = exports.getListsWithMedia = exports.getMediaComments = exports.getMediaTranslations = exports.getMediaSummary_Full = exports.getMediaPeople = exports.getCollectedMedia = exports.getBoxOfficeMedia = exports.getWatchedMedia = exports.getAnticipatedMedia = exports.getAliasesMedia = exports.getUpdatedIDsMedia = exports.getUpdatesMedia = exports.getPlayedMedia = exports.getRecommendedMedia = exports.getPopularMedia = exports.getTrendingMedia = void 0;
const utils_1 = require("../utils");
/**
*
* @param ApiConfig
* @param type
* @returns
* @internal
*/
function getTrendingMedia({ client, apiUrl }, type, { pagination, filters, }) {
return __awaiter(this, void 0, void 0, function* () {
const url = `${apiUrl}/${type}/trending`;
const response = yield (0, utils_1.fetch)(client, url, { pagination, filters });
return response;
});
}
exports.getTrendingMedia = getTrendingMedia;
/**
*
* @param ApiConfig
* @param type
* @returns
* @internal
*/
function getPopularMedia({ client, apiUrl }, type, { pagination, filters, }) {
return __awaiter(this, void 0, void 0, function* () {
const url = `${apiUrl}/${type}/popular`;
const response = yield (0, utils_1.fetch)(client, url, { pagination, filters });
return response;
});
}
exports.getPopularMedia = getPopularMedia;
/**
* Gets recommended media for shows and movies
* @param ApiConfig
* @param type
* @param options
* @returns
*/
function getRecommendedMedia({ client, apiUrl }, type, { pagination, filters, period, }) {
return __awaiter(this, void 0, void 0, function* () {
const url = `${apiUrl}/${type}/recommended`;
const response = yield (0, utils_1.fetch)(client, url, { pagination, filters, period });
return response;
});
}
exports.getRecommendedMedia = getRecommendedMedia;
/**
* Gets most played media for shows and movies
* @param ApiConfig
* @param type
* @param options
* @returns
*/
function getPlayedMedia({ client, apiUrl }, type, { pagination, filters, period, }) {
return __awaiter(this, void 0, void 0, function* () {
const url = `${apiUrl}/${type}/played`;
const response = yield (0, utils_1.fetch)(client, url, { pagination, filters, period });
return response;
});
}
exports.getPlayedMedia = getPlayedMedia;
/**
* Gets recently updated media
* @param ApiConfig
* @param type
* @param options
* @returns
*/
function getUpdatesMedia({ client, apiUrl }, type, { pagination, startDate, }) {
return __awaiter(this, void 0, void 0, function* () {
const url = `${apiUrl}/${type}/updates`;
const response = yield (0, utils_1.fetch)(client, url, { pagination, startDate });
return response;
});
}
exports.getUpdatesMedia = getUpdatesMedia;
/**
* Gets recently updated ids of media
* @param ApiConfig
* @param type
* @param options
* @returns
*/
function getUpdatedIDsMedia({ client, apiUrl }, type, { pagination, startDate, }) {
return __awaiter(this, void 0, void 0, function* () {
const url = `${apiUrl}/${type}/updates/id`;
const response = yield (0, utils_1.fetch)(client, url, { pagination, startDate });
return response;
});
}
exports.getUpdatedIDsMedia = getUpdatedIDsMedia;
/**
* Gets all title aliases for media
* @param ApiConfig
* @param type
* @param options
* @returns
*/
function getAliasesMedia({ client, apiUrl }, type, { mediaID, }) {
return __awaiter(this, void 0, void 0, function* () {
const url = `${apiUrl}/${type}/${mediaID}/aliases`;
const response = yield (0, utils_1.fetch)(client, url);
return response;
});
}
exports.getAliasesMedia = getAliasesMedia;
/**
* Gets most anticipated media for shows and movies
* @param ApiConfig
* @param type
* @param options
* @returns
*/
function getAnticipatedMedia({ client, apiUrl }, type, { pagination, filters, }) {
return __awaiter(this, void 0, void 0, function* () {
const url = `${apiUrl}/${type}/anticipated`;
const response = yield (0, utils_1.fetch)(client, url, { pagination, filters });
return response;
});
}
exports.getAnticipatedMedia = getAnticipatedMedia;
/**
* Gets most watched (unique users) media for shows and movies
* @param ApiConfig
* @param type
* @param options
* @returns
*/
function getWatchedMedia({ client, apiUrl }, type, { pagination, filters, period, }) {
return __awaiter(this, void 0, void 0, function* () {
const url = `${apiUrl}/${type}/watched`;
const response = yield (0, utils_1.fetch)(client, url, { pagination, filters, period });
return response;
});
}
exports.getWatchedMedia = getWatchedMedia;
/**
* Gets the media with the biggest box office revenue
* @param ApiConfig
* @param type
* @returns
*/
function getBoxOfficeMedia({ client, apiUrl }, type) {
return __awaiter(this, void 0, void 0, function* () {
const url = `${apiUrl}/${type}/boxoffice`;
const response = yield (0, utils_1.fetch)(client, url);
return response;
});
}
exports.getBoxOfficeMedia = getBoxOfficeMedia;
/**
* Gets most collected (unique users) media for shows and movies
* @param ApiConfig
* @param type
* @param options
* @returns
*/
function getCollectedMedia({ client, apiUrl }, type, { pagination, filters, period, }) {
return __awaiter(this, void 0, void 0, function* () {
const url = `${apiUrl}/${type}/collected`;
const response = yield (0, utils_1.fetch)(client, url, { pagination, filters, period });
return response;
});
}
exports.getCollectedMedia = getCollectedMedia;
/**
*
* @param ApiConfig
* @param movieId
* @returns
* @internal
*/
function getMediaPeople({ client, apiUrl }, movieId) {
return __awaiter(this, void 0, void 0, function* () {
const url = `${apiUrl}/${movieId}/people`;
const response = yield (0, utils_1.fetch)(client, url);
return response;
});
}
exports.getMediaPeople = getMediaPeople;
/**
*
* @param ApiConfig
* @param showId
* @returns
* @internal
*/
function getMediaSummary_Full({ client, apiUrl }, showId) {
return __awaiter(this, void 0, void 0, function* () {
const url = `${apiUrl}/${showId}?extended=full`;
const response = yield (0, utils_1.fetch)(client, url);
return response;
});
}
exports.getMediaSummary_Full = getMediaSummary_Full;
function getMediaTranslations({ client, apiUrl }, type, mediaId, language) {
return __awaiter(this, void 0, void 0, function* () {
const url = `${apiUrl}/${type}/${mediaId}/translations`;
const response = yield (0, utils_1.fetch)(client, url, { language });
return response;
});
}
exports.getMediaTranslations = getMediaTranslations;
function getMediaComments({ client, apiUrl }, type, mediaId, { pagination, sort, }) {
return __awaiter(this, void 0, void 0, function* () {
const url = `${apiUrl}/${type}/${mediaId}/translations`;
const response = yield (0, utils_1.fetch)(client, url, { pagination, sort });
return response;
});
}
exports.getMediaComments = getMediaComments;
function getListsWithMedia({ client, apiUrl }, type, mediaId, { pagination, type: listType, sort, }) {
return __awaiter(this, void 0, void 0, function* () {
const url = `${apiUrl}/${type}/${mediaId}/lists`;
const response = yield (0, utils_1.fetch)(client, url, { pagination, sort, type: listType });
return response;
});
}
exports.getListsWithMedia = getListsWithMedia;
function getMediaRating({ client, apiUrl }, type, mediaId) {
return __awaiter(this, void 0, void 0, function* () {
const url = `${apiUrl}/${type}/${mediaId}/ratings`;
const response = yield (0, utils_1.fetch)(client, url);
return response;
});
}
exports.getMediaRating = getMediaRating;
function getRelatedMedia({ client, apiUrl }, type, mediaId, { pagination, }) {
return __awaiter(this, void 0, void 0, function* () {
const url = `${apiUrl}/${type}/${mediaId}/related`;
const response = yield (0, utils_1.fetch)(client, url, { pagination });
return response;
});
}
exports.getRelatedMedia = getRelatedMedia;
function getMediaStats({ client, apiUrl }, type, mediaId) {
return __awaiter(this, void 0, void 0, function* () {
const url = `${apiUrl}/${type}/${mediaId}/stats`;
const response = yield (0, utils_1.fetch)(client, url);
return response;
});
}
exports.getMediaStats = getMediaStats;
function getWatchingMedia({ client, apiUrl }, type, mediaId) {
return __awaiter(this, void 0, void 0, function* () {
const url = `${apiUrl}/${type}/${mediaId}/watching`;
const response = yield (0, utils_1.fetch)(client, url);
return response;
});
}
exports.getWatchingMedia = getWatchingMedia;
//# sourceMappingURL=methods.js.map