@kaguya-anime/parsers
Advanced tools
Comparing version 1.13.10 to 1.14.0
@@ -87,6 +87,7 @@ import { Media } from '../types/anilist'; | ||
export declare const getTranslations: (media: Media) => Promise<Translation[]>; | ||
export declare const getEpisodes: (tmdbId: number, seasonNumber: number) => Promise<any>; | ||
export declare const getTMDBEpisodes: (tmdbId: number, seasonNumber: number, language?: string) => Promise<any>; | ||
export declare const getEpisodes: (tmdbId: number, seasonNumber: number, language?: string) => Promise<any>; | ||
export declare const getTMDBId: (anilistId: number) => Promise<number>; | ||
export declare const getSeason: (tmdbId: number, mapAirDate: string) => Promise<Season>; | ||
export declare const getEpisodeInfo: (anilist: Media) => Promise<any>; | ||
export declare const getEpisodeInfo: (anilist: Media, language?: string) => Promise<any>; | ||
export {}; |
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getEpisodeInfo = exports.getSeason = exports.getTMDBId = exports.getEpisodes = exports.getTranslations = exports.search = void 0; | ||
exports.getEpisodeInfo = exports.getSeason = exports.getTMDBId = exports.getEpisodes = exports.getTMDBEpisodes = exports.getTranslations = exports.search = void 0; | ||
const tslib_1 = require("tslib"); | ||
@@ -60,10 +60,43 @@ const axios_1 = tslib_1.__importDefault(require("axios")); | ||
exports.getTranslations = getTranslations; | ||
const getEpisodes = (tmdbId, seasonNumber) => tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const getTMDBEpisodes = (tmdbId, seasonNumber, language = 'en') => tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
var _b; | ||
const { data } = yield client.get(`/tv/${tmdbId}/season/${seasonNumber}`, { | ||
params: { | ||
language, | ||
}, | ||
}); | ||
if (!((_b = data === null || data === void 0 ? void 0 : data.episodes) === null || _b === void 0 ? void 0 : _b.length)) | ||
return []; | ||
return data.episodes; | ||
}); | ||
exports.getTMDBEpisodes = getTMDBEpisodes; | ||
const getEpisodes = (tmdbId, seasonNumber, language = 'en') => tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
try { | ||
const { data } = yield client.get(`/tv/${tmdbId}/season/${seasonNumber}`); | ||
if (!((_b = data === null || data === void 0 ? void 0 : data.episodes) === null || _b === void 0 ? void 0 : _b.length)) | ||
return []; | ||
const episodesWithThumbnail = data.episodes.filter((episode) => episode.overview); | ||
return episodesWithThumbnail.map((episode) => ({ | ||
const episodes = yield (() => tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const promises = []; | ||
const languageEpisodesPromise = (0, exports.getTMDBEpisodes)(tmdbId, seasonNumber, language); | ||
promises.push(languageEpisodesPromise); | ||
if (language !== 'en') { | ||
const fallbackEpisodesPromise = (0, exports.getTMDBEpisodes)(tmdbId, seasonNumber, 'en'); | ||
promises.push(fallbackEpisodesPromise); | ||
} | ||
else { | ||
promises.push(Promise.resolve([])); | ||
} | ||
const [languageEpisodes = [], fallbackEpisodes = []] = yield Promise.all(promises); | ||
const episodes = languageEpisodes.map((languageEpisode, index) => { | ||
var _a; | ||
const fallbackEpisode = fallbackEpisodes[index]; | ||
const name = !((_a = languageEpisode.name) === null || _a === void 0 ? void 0 : _a.startsWith('Episode')) | ||
? languageEpisode.name | ||
: (fallbackEpisode === null || fallbackEpisode === void 0 ? void 0 : fallbackEpisode.name) || languageEpisode.name; | ||
const overview = languageEpisode.overview | ||
? languageEpisode.overview | ||
: (fallbackEpisode === null || fallbackEpisode === void 0 ? void 0 : fallbackEpisode.overview) || languageEpisode.overview; | ||
return Object.assign(Object.assign({}, languageEpisode), { name: name, overview: overview }); | ||
}); | ||
return episodes; | ||
}))(); | ||
const validEpisodes = episodes.filter((episode) => { var _a; return !((_a = episode.name) === null || _a === void 0 ? void 0 : _a.startsWith('Episode')); }); | ||
return validEpisodes.map((episode) => ({ | ||
title: episode.name, | ||
@@ -131,3 +164,3 @@ description: episode.overview, | ||
exports.getSeason = getSeason; | ||
const getEpisodeInfo = (anilist) => tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const getEpisodeInfo = (anilist, language = 'en') => tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
try { | ||
@@ -143,3 +176,3 @@ const tmdbId = yield (0, exports.getTMDBId)(anilist.id); | ||
} | ||
const episodes = yield (0, exports.getEpisodes)(tmdbId, season === null || season === void 0 ? void 0 : season.season_number); | ||
const episodes = yield (0, exports.getEpisodes)(tmdbId, season === null || season === void 0 ? void 0 : season.season_number, language); | ||
return episodes; | ||
@@ -146,0 +179,0 @@ } |
{ | ||
"name": "@kaguya-anime/parsers", | ||
"version": "1.13.10", | ||
"version": "1.14.0", | ||
"main": "build/index.js", | ||
@@ -43,3 +43,3 @@ "license": "MIT", | ||
}, | ||
"gitHead": "036a823fedda2cc82b3c8c8a0f6d0e4ef367bd01" | ||
"gitHead": "000f906d62227cdff171bcfd70b8dd54ed6603ba" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
433866
7761