2024-10-18 02:10:58 +02:00
|
|
|
import IMangaConnector from './interfaces/IMangaConnector';
|
|
|
|
import IManga from './interfaces/IManga';
|
|
|
|
import { getData } from '../App';
|
|
|
|
|
|
|
|
export class MangaConnector
|
|
|
|
{
|
|
|
|
static async GetAllConnectors(): Promise<IMangaConnector[]> {
|
2024-10-19 21:08:11 +02:00
|
|
|
console.info("Getting all MangaConnectors");
|
2024-10-18 02:10:58 +02:00
|
|
|
return getData("http://127.0.0.1:6531/v2/Connector/Types")
|
|
|
|
.then((json) => {
|
2024-10-19 21:08:11 +02:00
|
|
|
console.info("Got all MangaConnectors");
|
2024-10-18 02:10:58 +02:00
|
|
|
return (json as IMangaConnector[]);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
static async GetMangaFromConnectorByTitle(connector: IMangaConnector, name: string): Promise<IManga[]> {
|
2024-10-19 21:08:11 +02:00
|
|
|
console.info(`Getting Manga ${name}`);
|
2024-10-18 02:10:58 +02:00
|
|
|
return await getData(`http://127.0.0.1:6531/v2/Connector/${connector.name}/GetManga?title=${name}`)
|
|
|
|
.then((json) => {
|
2024-10-19 21:08:11 +02:00
|
|
|
console.info(`Got Manga ${name}`);
|
2024-10-18 02:10:58 +02:00
|
|
|
return (json as IManga[]);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
static async GetMangaFromConnectorByUrl(connector: IMangaConnector, url: string): Promise<IManga> {
|
2024-10-19 21:08:11 +02:00
|
|
|
console.info(`Getting Manga ${url}`);
|
2024-10-18 02:10:58 +02:00
|
|
|
return await getData(`http://127.0.0.1:6531/v2/Connector/${connector.name}/GetManga?url=${url}`)
|
|
|
|
.then((json) => {
|
2024-10-19 21:08:11 +02:00
|
|
|
console.info(`Got Manga ${url}`);
|
2024-10-18 02:10:58 +02:00
|
|
|
return (json as IManga);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|