fix(extractor): use title from XPrime API

This commit is contained in:
WebStreamr 2025-08-15 13:43:30 +00:00
parent be33b0b3b9
commit a65b8fb507
No known key found for this signature in database
3 changed files with 17 additions and 7 deletions

View file

@ -20,7 +20,7 @@ describe('XPrime', () => {
});
test('primebox Alien: Earth', async () => {
expect(await extractorRegistry.handle(ctx, new URL('https://backend.xprime.tv/primebox?name=Alien%3A%20Earth&year=2025&season=1&episode=1'), CountryCode.en, 'Alien: Earth')).toMatchSnapshot();
expect(await extractorRegistry.handle(ctx, new URL('https://backend.xprime.tv/primebox?name=Alien%3A%20Earth&year=2025&season=1&episode=1'), CountryCode.en, 'Alien: Earth 1x1')).toMatchSnapshot();
});
test('primebox not found', async () => {

View file

@ -4,6 +4,13 @@ import { Extractor } from './Extractor';
interface XPrimePrimeboxResponsePartial {
streams: Record<string, string>;
series_info?: {
episode: number;
season: number;
title: string;
year: string;
};
title?: string;
}
export class XPrime extends Extractor {
@ -25,7 +32,7 @@ export class XPrime extends Extractor {
return null !== url.host.match(/xprime/);
}
protected async extractInternal(ctx: Context, url: URL, countryCode: CountryCode, title: string | undefined): Promise<UrlResult[]> {
protected async extractInternal(ctx: Context, url: URL, countryCode: CountryCode): Promise<UrlResult[]> {
const urlResults: UrlResult[] = [];
const referer = url.protocol + '//' + url.hostname.split('.').slice(-2).join('.'); // Strip subdomains
@ -35,6 +42,9 @@ export class XPrime extends Extractor {
for (const [resolution, stream] of Object.entries(jsonResponse.streams)) {
const url = new URL(stream);
const title = jsonResponse.series_info
? `${jsonResponse.series_info.title} ${jsonResponse.series_info.season}x${jsonResponse.series_info.episode} (${jsonResponse.series_info.year})`
: jsonResponse.title;
urlResults.push({
url,
@ -46,7 +56,7 @@ export class XPrime extends Extractor {
countryCodes: [countryCode],
bytes: parseInt((await this.fetcher.head(ctx, url, { headers: { Referer: referer }, minCacheTtl: this.ttl }))['content-length'] as string),
height: parseInt(resolution),
title: `${title}`,
title,
},
requestHeaders: {
Referer: referer,

View file

@ -11,7 +11,7 @@ exports[`XPrime primebox Alien: Earth 1`] = `
"en",
],
"height": 1080,
"title": "Alien: Earth",
"title": "Alien: Earth 1x1 (2025)",
},
"requestHeaders": {
"Referer": "https://xprime.tv",
@ -29,7 +29,7 @@ exports[`XPrime primebox Alien: Earth 1`] = `
"en",
],
"height": 480,
"title": "Alien: Earth",
"title": "Alien: Earth 1x1 (2025)",
},
"requestHeaders": {
"Referer": "https://xprime.tv",
@ -52,7 +52,7 @@ exports[`XPrime primebox Superman 1`] = `
"en",
],
"height": 480,
"title": "Superman (2025)",
"title": "Superman",
},
"requestHeaders": {
"Referer": "https://xprime.tv",
@ -70,7 +70,7 @@ exports[`XPrime primebox Superman 1`] = `
"en",
],
"height": 720,
"title": "Superman (2025)",
"title": "Superman",
},
"requestHeaders": {
"Referer": "https://xprime.tv",