Files
profilarr/src/lib/server/utils/tmdb/client.ts
Sam Chau 74b38df686 feat: add entity and release management components
- Created EntityTable component for displaying test entities with expandable rows for releases.
- Implemented ReleaseTable component to manage and display test releases with actions for editing and deleting.
- Added ReleaseModal component for creating and editing releases
- Introduced types for TestEntity, TestRelease, and related evaluations
- Enhanced general settings page to include TMDB API configuration with connection testing functionality.
- Added TMDBSettings component for managing TMDB API access token with reset and test connection features.
2026-01-14 23:50:20 +10:30

54 lines
1.3 KiB
TypeScript

import { BaseHttpClient } from '../http/client.ts';
import { logger } from '../logger/logger.ts';
import type { TMDBMovieSearchResponse, TMDBTVSearchResponse, TMDBAuthResponse } from './types.ts';
const TMDB_BASE_URL = 'https://api.themoviedb.org/3';
/**
* TMDB API client
*/
export class TMDBClient extends BaseHttpClient {
constructor(apiKey: string) {
super(TMDB_BASE_URL, {
headers: {
Authorization: `Bearer ${apiKey}`
}
});
}
/**
* Validate the API key
*/
async validateKey(): Promise<TMDBAuthResponse> {
return this.get<TMDBAuthResponse>('/authentication');
}
/**
* Search for movies
*/
async searchMovies(query: string, page = 1): Promise<TMDBMovieSearchResponse> {
logger.debug(`Searching movies: "${query}"`, { source: 'TMDB' });
const params = new URLSearchParams({
query,
include_adult: 'false',
language: 'en-US',
page: String(page)
});
return this.get<TMDBMovieSearchResponse>(`/search/movie?${params}`);
}
/**
* Search for TV shows
*/
async searchTVShows(query: string, page = 1): Promise<TMDBTVSearchResponse> {
logger.debug(`Searching TV shows: "${query}"`, { source: 'TMDB' });
const params = new URLSearchParams({
query,
include_adult: 'false',
language: 'en-US',
page: String(page)
});
return this.get<TMDBTVSearchResponse>(`/search/tv?${params}`);
}
}