Skip to content

Commit

Permalink
Fix getName() bug
Browse files Browse the repository at this point in the history
  • Loading branch information
hyoretsu committed Jan 31, 2024
1 parent 392be46 commit a052b83
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"type": "module",
"name": "stremio-addon-jackett",
"version": "1.2.10",
"version": "1.2.11",
"description": "Stremio Jackett Addon",
"scripts": {
"build": "node esbuild.js",
Expand Down
17 changes: 10 additions & 7 deletions src/helpers/getName.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ export async function getName(id, type, tmdbApiKey, locale) {
if (typeof id !== "string") {
return id;
}
if (tmdbApiKey === undefined) {

if (!tmdbApiKey) {
const res = await fetch(`https://v3-cinemeta.strem.io/meta/${type}/${id}.json`);
// @ts-ignore
const { meta } = await res.json();
Expand All @@ -17,25 +18,27 @@ export async function getName(id, type, tmdbApiKey, locale) {
year: releaseInfo,
};
}

const res = await fetch(
`https://api.themoviedb.org/3/find/${id}?api_key=${tmdbApiKey}&external_source=imdb_id&language=${locale}`,
);

if (type === "movie") {
// @ts-ignore
const { movie_results } = await res.json();
const { title } = movie_results[0];
const { release_date } = movie_results[0];
const { release_date, title: name } = movie_results[0];

return {
name: title,
name,
year: release_date.substring(0, 4),
};
}

if (type === "series") {
// @ts-ignore
const { tv_results } = await res.json();
const { name } = tv_results[0];
return {
name: name,
};

return { name };
}
}

0 comments on commit a052b83

Please sign in to comment.