discord-player-play-dl/src/Structures/ExtractorModel.ts

44 lines
1.1 KiB
TypeScript
Raw Normal View History

2021-04-08 19:42:08 +05:00
import { ExtractorModelData } from '../types/types';
2021-04-08 18:03:04 +05:00
class ExtractorModel {
name: string;
private _raw: any;
constructor(extractorName: string, data: any) {
this.name = extractorName;
2021-04-08 19:42:08 +05:00
Object.defineProperty(this, '_raw', { value: data, configurable: false, writable: false, enumerable: false });
2021-04-08 18:03:04 +05:00
}
async handle(query: string) {
const data = await this._raw.getInfo(query);
if (!data) return null;
return {
title: data.title,
duration: data.duration,
thumbnail: data.thumbnail,
engine: data.engine,
views: data.views,
author: data.author,
description: data.description,
url: data.url
} as ExtractorModelData;
}
validate(query: string) {
return Boolean(this._raw.validate(query));
}
get version() {
2021-04-08 19:42:08 +05:00
return this._raw.version ?? '0.0.0';
2021-04-08 18:03:04 +05:00
}
get important() {
return Boolean(this._raw.important);
}
}
export default ExtractorModel;
2021-04-08 19:42:08 +05:00
export { ExtractorModel };