refactor(extractor): move label format handling into central place
This commit is contained in:
parent
d7e82ceff3
commit
ef2b6721c7
9 changed files with 18 additions and 10 deletions
|
|
@ -27,7 +27,9 @@ export abstract class Extractor {
|
|||
|
||||
public async extract(ctx: Context, url: URL, meta: Meta): Promise<UrlResult[]> {
|
||||
try {
|
||||
return await this.extractInternal(ctx, url, meta);
|
||||
return (await this.extractInternal(ctx, url, meta)).map(
|
||||
urlResult => ({ ...urlResult, label: this.formatLabel(urlResult.label) }),
|
||||
);
|
||||
} catch (error) {
|
||||
if (error instanceof NotFoundError) {
|
||||
return [];
|
||||
|
|
@ -39,11 +41,15 @@ export abstract class Extractor {
|
|||
format: Format.unknown,
|
||||
isExternal: true,
|
||||
error,
|
||||
label: this.label,
|
||||
label: this.formatLabel(this.label),
|
||||
sourceId: `${this.id}`,
|
||||
meta,
|
||||
},
|
||||
];
|
||||
}
|
||||
};
|
||||
|
||||
private formatLabel(label: string): string {
|
||||
return this.viaMediaFlowProxy ? `${label} (MFP)` : label;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import { Extractor } from './Extractor';
|
|||
export class Fastream extends Extractor {
|
||||
public readonly id = 'fastream';
|
||||
|
||||
public readonly label = 'Fastream (MFP)';
|
||||
public readonly label = 'Fastream';
|
||||
|
||||
public override viaMediaFlowProxy = true;
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import { Extractor } from './Extractor';
|
|||
export class FileLions extends Extractor {
|
||||
public readonly id = 'filelions';
|
||||
|
||||
public readonly label = 'FileLions (MFP)';
|
||||
public readonly label = 'FileLions';
|
||||
|
||||
public override viaMediaFlowProxy = true;
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import { Extractor } from './Extractor';
|
|||
export class FileMoon extends Extractor {
|
||||
public readonly id = 'filemoon';
|
||||
|
||||
public readonly label = 'FileMoon (MFP)';
|
||||
public readonly label = 'FileMoon';
|
||||
|
||||
public override viaMediaFlowProxy = true;
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import { Extractor } from './Extractor';
|
|||
export class LuluStream extends Extractor {
|
||||
public readonly id = 'lulustream';
|
||||
|
||||
public readonly label = 'LuluStream (MFP)';
|
||||
public readonly label = 'LuluStream';
|
||||
|
||||
public override viaMediaFlowProxy = true;
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import { Extractor } from './Extractor';
|
|||
export class Mixdrop extends Extractor {
|
||||
public readonly id = 'mixdrop';
|
||||
|
||||
public readonly label = 'Mixdrop (MFP)';
|
||||
public readonly label = 'Mixdrop';
|
||||
|
||||
public override viaMediaFlowProxy = true;
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,9 @@ import { Extractor } from './Extractor';
|
|||
export class Streamtape extends Extractor {
|
||||
public readonly id = 'streamtape';
|
||||
|
||||
public readonly label = 'Streamtape (MFP)';
|
||||
public readonly label = 'Streamtape';
|
||||
|
||||
public override viaMediaFlowProxy = true;
|
||||
|
||||
public supports(ctx: Context, url: URL): boolean {
|
||||
const supportedDomain = null !== url.host.match(/streamtape/)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import { Extractor } from './Extractor';
|
|||
export class Uqload extends Extractor {
|
||||
public readonly id = 'uqload';
|
||||
|
||||
public readonly label = 'Uqload (MFP)';
|
||||
public readonly label = 'Uqload';
|
||||
|
||||
public override viaMediaFlowProxy = true;
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import { Extractor } from './Extractor';
|
|||
export class Voe extends Extractor {
|
||||
public readonly id = 'voe';
|
||||
|
||||
public readonly label = 'VOE (MFP)';
|
||||
public readonly label = 'VOE';
|
||||
|
||||
public override viaMediaFlowProxy = true;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue