import { ISource, SearchResult, SelectionData, ContentLinks, MediaType } from '../../src/types/source.js'; import { FlixArtAPI } from './api.js'; export class FlixartSource implements ISource { name = 'flixart'; displayName = 'FlixArt'; async search(query: string, mediaType?: MediaType): Promise { return FlixArtAPI.search(query, mediaType); } async getTrending(mediaType: MediaType): Promise { const type = mediaType === 'series' ? 'series' : 'movie'; return FlixArtAPI.getTrending(type); } async getRecent(): Promise { return this.getTrending('movie'); } async getSelection(identifier: string, type?: string, seasonValue?: string | number): Promise { return FlixArtAPI.getSelection(identifier); } async getContentLinks(identifier: string, season?: number): Promise { return FlixArtAPI.getContentLinks(identifier, season); } async healthCheck(): Promise { try { const results = await this.getTrending('movie'); return results.length > 0; } catch (e: any) { console.error(`[FlixArt] Healthcheck failed: ${e.message}`); return false; } } // Custom resolveLink that returns a Turnstile challenge instead of just the URL // Actually, Agora's activeSource.resolveLink only accepts string. // We will change ISource resolveLink to allow returning an object. async resolveLink(linkId: string, extraData?: any): Promise { const [url] = linkId.split('|'); // FlixArt requires a Cloudflare Turnstile challenge which cannot be resolved on localhost. // We directly return the manual redirection challenge. return { captcha: 'turnstile', url: url, sourceName: 'FlixArt' }; } } // Auto-registration import { sourceRegistry } from '../../src/core/registry.js'; sourceRegistry.register(new FlixartSource());