Skip to content

Commit

Permalink
fix type error
Browse files Browse the repository at this point in the history
  • Loading branch information
kbagot committed Dec 30, 2024
1 parent 42bb45f commit 8b87e2d
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions server/api/movies/[id]/index.get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export default defineEventHandler(async (event) => {
//Fetch movie infos
const response = await fetch(
`${BASE_URL}find/${id}` +
`?external_source=imdb_id` +
`&api_key=${config.tmdbApiKey}`,
`?external_source=imdb_id` +
`&api_key=${config.tmdbApiKey}`,
);
const resData = await response.json();

Expand All @@ -32,14 +32,14 @@ export default defineEventHandler(async (event) => {
//Fetch movie credits
const resCredits = await fetch(
`${BASE_URL}movie/${resData.movie_results[0].id}/credits` +
`?api_key=${config.tmdbApiKey}`,
`?api_key=${config.tmdbApiKey}`,
);
const credits = await resCredits.json();

//Fetch movie details
const resDetails = await fetch(
`${BASE_URL}movie/${resData.movie_results[0].id}` +
`?api_key=${config.tmdbApiKey}`,
`?api_key=${config.tmdbApiKey}`,
);
const details = await resDetails.json();

Expand All @@ -63,7 +63,7 @@ export default defineEventHandler(async (event) => {

//Fetch Numbers of comments
const headers = getRequestHeaders(event) as HeadersInit;
const resComments = await $fetch(
const resComments = await $fetch<{ length: number }>(
`http://localhost:3000/api/movies/${id}/comments`,
{ headers },
);
Expand All @@ -79,10 +79,10 @@ export default defineEventHandler(async (event) => {
//Fetch torrents from title
const resTorrents = await fetch(
"http://jackett:9117/api/v2.0/indexers/all/results/torznab/api" +
`?apikey=${config.jackettApiKey}` +
`&t=movie&q=${encodeURI(movie_infos?.title)}` +
`&year=${movie_infos.release_date.slice(0, 4)}` +
`&cat=2000`,
`?apikey=${config.jackettApiKey}` +
`&t=movie&q=${encodeURI(movie_infos?.title)}` +
`&year=${movie_infos.release_date.slice(0, 4)}` +
`&cat=2000`,
);

if (!resTorrents.ok) {
Expand Down Expand Up @@ -116,7 +116,7 @@ export default defineEventHandler(async (event) => {
a["guid"].split(":")[0] === "magnet" &&
parseInt(
a["torznab:attr"].find((a: any) => a["@_name"] === "seeders")?.[
"@_value"
"@_value"
],
) >= 1 &&
(a["torznab:attr"].find((a: any) => a["@_name"] === "imdbid")?.[
Expand All @@ -134,12 +134,12 @@ export default defineEventHandler(async (event) => {
(a: any, b: any) =>
parseInt(
b["torznab:attr"].find((a: any) => a["@_name"] === "seeders")?.[
"@_value"
"@_value"
],
) -
parseInt(
a["torznab:attr"].find((a: any) => a["@_name"] === "seeders")?.[
"@_value"
"@_value"
],
),
)
Expand All @@ -150,7 +150,7 @@ export default defineEventHandler(async (event) => {
magnet: t["guid"],
seeders: parseInt(
t["torznab:attr"].find((a: any) => a["@_name"] === "seeders")?.[
"@_value"
"@_value"
],
),
description: t["title"],
Expand Down

0 comments on commit 8b87e2d

Please sign in to comment.