From 7d8c32317f70ab178ce2bc7e7bf045fdd0f2c257 Mon Sep 17 00:00:00 2001 From: Aleksi Lassila Date: Sun, 9 Jun 2024 15:20:54 +0300 Subject: [PATCH] fix: Incorrect tmdb account details --- README.md | 7 +++++++ src/lib/apis/tmdb/tmdb-api.ts | 38 ++++++++++++++++++++++++++--------- 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 61363bf..ff978cb 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,13 @@ Contributions are welcome! See [contributing](#Contributing) for more informatio ![Demo Video](images/reiverr-demo.gif) +## Reiverr 1.0 + +This is the page for Reiverr 2.0, which is a rewrite of the project with TVs in mind. +It still lacks many features of the previous version. If you want a more stable experience, +or only care about the web app, you might want to check out the +[1.0 branch](https://github.com/aleksilassila/reiverr/tree/reiverr-1.0) for now. + # List of major features TMDB Discovery: diff --git a/src/lib/apis/tmdb/tmdb-api.ts b/src/lib/apis/tmdb/tmdb-api.ts index c176ed2..565c052 100644 --- a/src/lib/apis/tmdb/tmdb-api.ts +++ b/src/lib/apis/tmdb/tmdb-api.ts @@ -72,6 +72,17 @@ export class TmdbApi implements Api { }); } + static getClient4l() { + const sessionId = get(appState)?.user?.settings.tmdb.sessionId; + + return createClient({ + baseUrl: 'https://api.themoviedb.org', + headers: { + Authorization: `Bearer ${sessionId}` + } + }); + } + getClient() { return TmdbApi.getClient(); } @@ -80,6 +91,10 @@ export class TmdbApi implements Api { return TmdbApi.getClient4(); } + getClient4l() { + return TmdbApi.getClient4l(); + } + getSessionId() { return get(appState)?.user?.settings.tmdb.sessionId; } @@ -316,7 +331,7 @@ export class TmdbApi implements Api { const top100: TmdbMovieSmall[] = await Promise.all( [...Array(5).keys()].map((i) => - this.getClient4() + this.getClient4l() ?.GET('/4/account/{account_object_id}/movie/recommendations', { params: { path: { @@ -391,7 +406,7 @@ export class TmdbApi implements Api { const top100: TmdbSeriesSmall[] = await Promise.all( [...Array(5).keys()].map((i) => - this.getClient4() + this.getClient4l() ?.GET('/4/account/{account_object_id}/tv/recommendations', { params: { path: { @@ -463,15 +478,18 @@ export class TmdbApi implements Api { const userId = this.getUserId(); if (!userId) return undefined; - return this.getClient() - ?.GET('/3/account/{account_id}', { - params: { - path: { - account_id: Number(userId) + return ( + this.getClient4l() + // @ts-ignore + ?.GET('/4/account/{account_object_id}', { + params: { + path: { + account_object_id: userId + } } - } - }) - .then((res) => res.data); + }) + .then((res) => res.data) + ); }; }