refactor: rename language to countryCode to avoid confusion
This commit is contained in:
parent
9145e9c3f6
commit
8ba6fdb5df
10 changed files with 18 additions and 18 deletions
|
|
@ -18,7 +18,7 @@ export class Dropload implements EmbedExtractor {
|
|||
|
||||
readonly supports = (url: URL): boolean => null !== url.host.match(/dropload/);
|
||||
|
||||
readonly extract = async (ctx: Context, url: URL, language: string) => {
|
||||
readonly extract = async (ctx: Context, url: URL, countryCode: string) => {
|
||||
const normalizedUrl = url.toString().replace('/e/', '').replace('/embed-', '/');
|
||||
const html = await this.fetcher.text(ctx, new URL(normalizedUrl));
|
||||
|
||||
|
|
@ -32,7 +32,7 @@ export class Dropload implements EmbedExtractor {
|
|||
sourceId: this.id,
|
||||
height: parseInt(heightMatch[1] as string) as number,
|
||||
bytes: bytes.parse(sizeMatch[1] as string) as number,
|
||||
language,
|
||||
countryCode,
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ export class EmbedExtractors {
|
|||
this.urlResultCache = new TTLCache({ max: 1024 });
|
||||
}
|
||||
|
||||
readonly handle = async (ctx: Context, url: URL, language: string): Promise<UrlResult> => {
|
||||
readonly handle = async (ctx: Context, url: URL, countryCode: string): Promise<UrlResult> => {
|
||||
let urlResult = this.urlResultCache.get(url.href);
|
||||
if (urlResult) {
|
||||
return urlResult;
|
||||
|
|
@ -23,7 +23,7 @@ export class EmbedExtractors {
|
|||
throw new Error(`No embed extractor found that supports url ${url}`);
|
||||
}
|
||||
|
||||
urlResult = await embedExtractor.extract(ctx, url, language);
|
||||
urlResult = await embedExtractor.extract(ctx, url, countryCode);
|
||||
this.urlResultCache.set(url.href, urlResult, { ttl: embedExtractor.ttl });
|
||||
|
||||
return urlResult;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ export class SuperVideo implements EmbedExtractor {
|
|||
|
||||
readonly supports = (url: URL): boolean => null !== url.host.match(/supervideo/);
|
||||
|
||||
readonly extract = async (ctx: Context, url: URL, language: string) => {
|
||||
readonly extract = async (ctx: Context, url: URL, countryCode: string) => {
|
||||
const normalizedUrl = url.toString().replace('/e/', '/').replace('/embed-', '/');
|
||||
const html = await this.fetcher.text(ctx, new URL(normalizedUrl));
|
||||
|
||||
|
|
@ -30,7 +30,7 @@ export class SuperVideo implements EmbedExtractor {
|
|||
sourceId: this.id,
|
||||
height: parseInt(heightAndSizeMatch[1] as string) as number,
|
||||
bytes: bytes.parse(heightAndSizeMatch[2] as string) as number,
|
||||
language,
|
||||
countryCode,
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,5 +9,5 @@ export interface EmbedExtractor {
|
|||
|
||||
readonly supports: (url: URL) => boolean;
|
||||
|
||||
readonly extract: (ctx: Context, url: URL, language: string) => Promise<UrlResult>;
|
||||
readonly extract: (ctx: Context, url: URL, countryCode: string) => Promise<UrlResult>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ describe('FrenchCloud', () => {
|
|||
sourceId: 'supervideo',
|
||||
height: 720,
|
||||
bytes: 966682214,
|
||||
language: 'fr',
|
||||
countryCode: 'fr',
|
||||
});
|
||||
expect(streams[0]?.url.href).toMatch(/^https:\/\/.*?.m3u8/);
|
||||
expect(streams[1]).toStrictEqual({
|
||||
|
|
@ -41,7 +41,7 @@ describe('FrenchCloud', () => {
|
|||
sourceId: 'dropload',
|
||||
height: 720,
|
||||
bytes: 966682214,
|
||||
language: 'fr',
|
||||
countryCode: 'fr',
|
||||
});
|
||||
expect(streams[1]?.url.href).toMatch(/^https:\/\/.*?.m3u8/);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ describe('KinoKiste', () => {
|
|||
sourceId: 'supervideo',
|
||||
height: 720,
|
||||
bytes: 733793484,
|
||||
language: 'de',
|
||||
countryCode: 'de',
|
||||
});
|
||||
expect(streams[0]?.url.href).toMatch(/^https:\/\/.*?.m3u8/);
|
||||
expect(streams[1]).toStrictEqual({
|
||||
|
|
@ -41,7 +41,7 @@ describe('KinoKiste', () => {
|
|||
sourceId: 'dropload',
|
||||
height: 720,
|
||||
bytes: 733793484,
|
||||
language: 'de',
|
||||
countryCode: 'de',
|
||||
});
|
||||
expect(streams[1]?.url.href).toMatch(/^https:\/\/.*?.m3u8/);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ describe('MeineCloud', () => {
|
|||
sourceId: 'supervideo',
|
||||
height: 720,
|
||||
bytes: 1073741824,
|
||||
language: 'de',
|
||||
countryCode: 'de',
|
||||
});
|
||||
expect(streams[0]?.url.href).toMatch(/^https:\/\/.*?.m3u8/);
|
||||
expect(streams[1]).toStrictEqual({
|
||||
|
|
@ -41,7 +41,7 @@ describe('MeineCloud', () => {
|
|||
sourceId: 'dropload',
|
||||
height: 1080,
|
||||
bytes: 1395864371,
|
||||
language: 'de',
|
||||
countryCode: 'de',
|
||||
});
|
||||
expect(streams[1]?.url.href).toMatch(/^https:\/\/.*?.m3u8/);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ describe('MostraGuarda', () => {
|
|||
sourceId: 'supervideo',
|
||||
height: 720,
|
||||
bytes: 1181116006,
|
||||
language: 'it',
|
||||
countryCode: 'it',
|
||||
});
|
||||
expect(streams[0]?.url.href).toMatch(/^https:\/\/.*?.m3u8/);
|
||||
expect(streams[1]).toStrictEqual({
|
||||
|
|
@ -41,7 +41,7 @@ describe('MostraGuarda', () => {
|
|||
sourceId: 'dropload',
|
||||
height: 720,
|
||||
bytes: 1181116006,
|
||||
language: 'it',
|
||||
countryCode: 'it',
|
||||
});
|
||||
expect(streams[1]?.url.href).toMatch(/^https:\/\/.*?.m3u8/);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -154,8 +154,8 @@ addon.get('/:config/stream/:type/:id.json', async function (req: Request, res: R
|
|||
if (urlResult.bytes) {
|
||||
title += ` | 💾 ${bytes.format(urlResult.bytes, { unitSeparator: ' ' })}`;
|
||||
}
|
||||
if (urlResult.language) {
|
||||
title += ` | ${flag(urlResult.language)}`;
|
||||
if (urlResult.countryCode) {
|
||||
title += ` | ${flag(urlResult.countryCode)}`;
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -12,5 +12,5 @@ export interface UrlResult {
|
|||
sourceId: string;
|
||||
height: number | undefined;
|
||||
bytes: number | undefined;
|
||||
language: string | undefined;
|
||||
countryCode: string | undefined;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue