mirror of
https://github.com/Viren070/AIOStreams.git
synced 2025-12-01 23:14:04 +01:00
fix: pass user provided TMDB access token to TMDBMetadata
This commit is contained in:
@@ -1136,7 +1136,9 @@ ${errorStreams.length > 0 ? ` ❌ Errors : ${errorStreams.map((s) => `
|
||||
let titles: string[] = [];
|
||||
if (this.userData.titleMatching && TYPES.includes(type as any)) {
|
||||
try {
|
||||
titles = await new TMDBMetadata().getTitles(id, type as any);
|
||||
titles = await new TMDBMetadata(
|
||||
this.userData.tmdbAccessToken
|
||||
).getTitles(id, type as any);
|
||||
logger.info(`Found ${titles.length} titles for ${id}`, { titles });
|
||||
} catch (error) {
|
||||
logger.error(`Error fetching titles for ${id}: ${error}`);
|
||||
|
||||
@@ -25,18 +25,20 @@ export class TMDBMetadata {
|
||||
private readonly IMDB_ID_REGEX = /^(?:tt)(\d+)(?::\d+:\d+)?$/;
|
||||
private readonly idCache: Cache<string, string>;
|
||||
private readonly titleCache: Cache<string, string[]>;
|
||||
private readonly accessToken: string;
|
||||
|
||||
public constructor() {
|
||||
if (!Env.TMDB_ACCESS_TOKEN) {
|
||||
public constructor(accessToken?: string) {
|
||||
if (!accessToken && !Env.TMDB_ACCESS_TOKEN) {
|
||||
throw new Error('TMDB Access Token is not set');
|
||||
}
|
||||
this.accessToken = (accessToken || Env.TMDB_ACCESS_TOKEN)!;
|
||||
this.idCache = Cache.getInstance<string, string>('tmdb_id_conversion');
|
||||
this.titleCache = Cache.getInstance<string, string[]>('alternative_titles');
|
||||
}
|
||||
|
||||
private getHeaders(): Record<string, string> {
|
||||
return {
|
||||
Authorization: `Bearer ${Env.TMDB_ACCESS_TOKEN}`,
|
||||
Authorization: `Bearer ${this.accessToken}`,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user