mirror of
https://github.com/Dictionarry-Hub/profilarr.git
synced 2026-01-22 19:01:02 +01:00
- 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.
54 lines
1.3 KiB
TypeScript
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}`);
|
|
}
|
|
}
|